示例#1
0
 public PeriodicReporting(ReportingPeriodDetail reportingPeriod, DateTime endTermDate, string createdBy)
     : this()
 {
     this.ReportingPeriod = reportingPeriod;
     this.EndTermDate = endTermDate;
     this.CreatedBy = createdBy;
     this.CreationDate = DateTime.Now;
 }
示例#2
0
        public static IPeriodicReporting GetReportingPeriod(IDalSession session, ReportingPeriodDetail reportingPeriodDetail)
        {
            Hashtable parameters = new Hashtable(2);
            if(reportingPeriodDetail.TermType == EndTermType.FullYear)
                parameters.Add("termType", EndTermType.FourthQtr);
            else
                parameters.Add("termType", reportingPeriodDetail.TermType);
            parameters.Add("endTermYear", reportingPeriodDetail.EndTermYear);

            string hql = string.Format(
                @"from PeriodicReporting P
                where P.ReportingPeriod.TermType = :termType
                and P.ReportingPeriod.EndTermYear = :endTermYear");
            IList result = session.GetListByHQL(hql, parameters);
            if ((result != null) && (result.Count > 0))
                return (IPeriodicReporting)result[0];
            else
                return null;
        }
示例#3
0
 public ReportingPeriodDetail getNextReportingPeriodDetail()
 {
     ReportingPeriodDetail returnValue = null;
     switch (this.TermType)
     {
         case EndTermType.FirstQtr:
             returnValue= new ReportingPeriodDetail(EndTermType.SecondQtr, this.EndTermYear);
             break;
         case EndTermType.SecondQtr:
             returnValue = new ReportingPeriodDetail(EndTermType.ThirdQtr, this.EndTermYear);
             break;
         case EndTermType.ThirdQtr:
             returnValue = new ReportingPeriodDetail(EndTermType.FourthQtr, this.EndTermYear);
             break;
         case EndTermType.FourthQtr:
             returnValue = new ReportingPeriodDetail(EndTermType.FirstQtr, this.EndTermYear + 1);
             break;
         case EndTermType.FullYear:
             returnValue = new ReportingPeriodDetail(EndTermType.FirstQtr, this.EndTermYear + 1);
             break;
     }
     return returnValue;
 }
示例#4
0
        public static void CreateDividWepFileforYear(int year)
        {
            ReportingPeriodDetail period = new ReportingPeriodDetail(EndTermType.FourthQtr, year);
            IDalSession session = NHSessionFactory.CreateSession();
            IList<int> listOfAccounts = AccountMapper.GetCustomerAccountKeysActiveforDividWEP(session, period);
            string pathName =  Utility.GetPathFromConfigFile("DividWepFilePath");
            IDividWepFile file = new DividWepFile(year, pathName);
            file.CreateCloseRecord();
            session.InsertOrUpdate(file);
            int fileID = file.Key;
            session.Close();

            foreach (int i in listOfAccounts)
            {
                session = NHSessionFactory.CreateSession();
                ICustomerAccount acct = (ICustomerAccount) AccountMapper.GetAccount(session, i);

                IEndTermValue etv = acct.EndTermValues.Where(e => ((e.EndTermDate.Year == year)
                                       && ((e.TermType == B4F.TotalGiro.Valuations.ReportedData.EndTermType.FullYear) || (e.TermType == B4F.TotalGiro.Valuations.ReportedData.EndTermType.FourthQtr)))).ElementAt(0);

                file = DividWepFileMapper.GetDividWepFile(session, fileID);
                IDividWepRecord record = new DividWepRecord(acct, etv);
                string test = record.SingleRecord;
                record.ParentFile = file;
                session.InsertOrUpdate(record);
                etv.DividWepRecord = record;
                session.InsertOrUpdate(etv);
                session.Close();
            }
            session = NHSessionFactory.CreateSession();
            file = DividWepFileMapper.GetDividWepFile(session, fileID);
            file.CreateCloseRecord();
            file.CreateOutputFile();
            session.InsertOrUpdate(file);
            session.Close();
        }
示例#5
0
        public static void CloseAccountsInBookYear(int bookYear, int bookYearClosureID)
        {
            IDalSession session = NHSessionFactory.CreateSession();
            ReportingPeriodDetail reportingPeriodDetail = new ReportingPeriodDetail(EndTermType.FourthQtr, bookYear);

            IList<int> listOfAccounts = AccountMapper.GetAccountKeystoCloseFinancialYear(session, reportingPeriodDetail.EndTermYear);
            session.Close();

            foreach (int iAccount in listOfAccounts)
            {
            session = NHSessionFactory.CreateSession();
            IList<IJournalEntryLine> lines = JournalEntryMapper.GetBookingsToCloseForFinancialYear(session, reportingPeriodDetail.GetEndDate(), iAccount);
            IAccountTypeInternal customer = (IAccountTypeInternal) AccountMapper.GetAccount(session, iAccount);
            IBookYearClosure closure = BookYearClosureMapper.GetBookYearClosure(session, bookYearClosureID);
            IClientBookYearClosure clientClosure = new ClientBookYearClosure(customer);
            clientClosure.ParentClosure = closure;

            if (lines.Count > 0)
            {

                //First Calculate the Totals per Currency for the account.
                IList<IGLAccount> balanceAccounts = GLAccountMapper.GetClientBalanceGLAccounts(session);
                var Total = from l in lines
                            group new { balanceTotal = l.Balance } by l.Balance.Underlying.Key into g
                            let firstchoice = new
                            {
                                currencyID = g.Key,
                                balanceTotal = g.Select(c => c.balanceTotal).Sum()
                            }
                            where (firstchoice.balanceTotal).IsNotZero
                            select firstchoice;

                foreach (var balance in Total)
                {
                    IGLAccount account = balanceAccounts.Where(a => a.DefaultCurrency.Key == balance.balanceTotal.Underlying.Key).First();
                    IJournalEntryLine newLine = new JournalEntryLine();
                    newLine.GLAccount = account;
                    newLine.GiroAccount = customer;
                    newLine.Balance = balance.balanceTotal.Negate();
                    lines.Add(newLine);
                }

                //Now summarize and total each line
                var summary = from s in lines
                              group new { Balance = s.Balance, Glaccount = s.GLAccount, GiroAccount = s.GiroAccount } by
                              new
                              {
                                  glaccount = s.GLAccount.Key,
                                  giroacct = s.GiroAccount.Key,
                                  Currency = ((ICurrency)s.Credit.Underlying).Key
                              }
                                  into g
                                  let firstchoice = new
                                  {

                                      glaccount = g.Key.glaccount,
                                      giroacct = g.Key.giroacct,
                                      Glaccount = g.First().Glaccount,
                                      GiroAccount = g.First().GiroAccount,
                                      Total = g.Select(m => m.Balance).Sum()
                                  }
                                  where (firstchoice.Total).IsNotZero
                                  select firstchoice;

                //Create new negative entries
                if (summary.Count() != 0)
                {
                    //Create a new Booking for the Next Year
                    DateTime bookDate = reportingPeriodDetail.GetEndDate().AddDays(1);
                    int journalAdmin = int.Parse(Utils.ConfigSettingsInfo.GetInfo("DefaultClientAdminJournal"));
                    int newBookingKey = (int) MemorialBookingsAdapter.CreateMemorialBooking(journalAdmin);
                    IMemorialBooking newBooking =(IMemorialBooking) JournalEntryMapper.GetJournalEntry(session, newBookingKey);
                    string description = string.Format(@"{0} - afsluiting Boekjaar {1}", customer.Number, reportingPeriodDetail.EndTermYear.ToString());

                    newBooking.TransactionDate = bookDate;
                    newBooking.Description = description;

                    foreach (var unit in summary.OrderBy(a => a.Glaccount.GLAccountNumber))
                    {
                        IJournalEntryLine newLine = new JournalEntryLine();
                        newLine.GLAccount = unit.Glaccount;
                        newLine.GiroAccount = customer;
                        newLine.Balance = unit.Total.Negate();
                        newBooking.Lines.AddJournalEntryLine(newLine);
                    }

                    newBooking.BookLines();
                    clientClosure.ClosureBooking = newBooking;
                    clientClosure.ClosureNotRequired = false;

                    session.InsertOrUpdate(newBooking);
                }
            }

            if (clientClosure.ClosureBooking == null) clientClosure.ClosureNotRequired = true;
            session.InsertOrUpdate(clientClosure);
            session.Close();
            }
        }
示例#6
0
 private static IPeriodicReporting getReportingPeriod(IDalSession session, ReportingPeriodDetail reportingPeriodDetail, DateTime endTermDate, string currentUser)
 {
     IPeriodicReporting reportingPeriod = PeriodicReportingMapper.GetReportingPeriod(session, reportingPeriodDetail);
     if (reportingPeriod == null)
         reportingPeriod = new PeriodicReporting(reportingPeriodDetail, endTermDate, currentUser);
     return reportingPeriod;
 }
示例#7
0
        public static void StoreEndTermValues(ReportingPeriodDetail reportingPeriodDetail)
        {
            DateTime endDate = reportingPeriodDetail.GetEndDate();
            DateTime startDate = new DateTime(reportingPeriodDetail.EndTermYear, 1, 1);

            IDalSession session1 = NHSessionFactory.CreateSession();
            IInternalEmployeeLogin employee = LoginMapper.GetCurrentEmployee(session1);
            IList<int> listOfAccounts = AccountMapper.GetAccountKeysActiveinFinancialYear(session1, reportingPeriodDetail.EndTermYear);
            IList<IHistoricalPrice> prices = HistoricalPriceMapper.GetHistoricalPrices(session1, endDate);
            IList<IHistoricalExRate> rates = HistoricalExRateMapper.GetHistoricalExRates(session1, endDate);

            IList<IJournalEntryLine> dividends = null;
            if ((reportingPeriodDetail.TermType == EndTermType.FourthQtr) || (reportingPeriodDetail.TermType == EndTermType.FullYear))
                dividends = JournalEntryMapper.GetDividendBookingsForPeriod(session1, startDate, endDate);
            IPeriodicReporting reportingPeriod = getReportingPeriod(session1, reportingPeriodDetail, endDate, employee.UserName);
            session1.InsertOrUpdate(reportingPeriod);
            int reportingPeriodID = reportingPeriod.Key;

            foreach (int i in listOfAccounts)
            {
                IDalSession session2 = NHSessionFactory.CreateSession();
                IAccountTypeInternal account = (IAccountTypeInternal)AccountMapper.GetAccount(session2, i);
                reportingPeriod = PeriodicReportingMapper.GetReportingPeriod(session2, reportingPeriodID);
                if (!account.EndTermValues.EndTermValueExists(reportingPeriodDetail))
                {
                    IPortfolioHistorical portfolio = HistoricalPositionAdapter.GetHistoricalPortfolio(session2, account, endDate, prices, rates);
                    InsertEndTermValue(session2, portfolio, dividends, reportingPeriod);
                }
                session2.Close();
            }
            session1.Close();
        }
示例#8
0
        public static IList GetEndValues(IDalSession session, IAccountTypeInternal account, EndTermType term, int year, bool ForcedSet)
        {
            IEndTermValue getter;
            IList returnValue = new EndTermValue[2];
            DateTime[] dates = GetEndDates(term, year);
            ReportingPeriodDetail reportingPeriodDetail = new ReportingPeriodDetail(term, year);
            IPeriodicReporting reportingPeriod = PeriodicReportingMapper.GetReportingPeriod(session, reportingPeriodDetail);

            getter = GetEndValue(session, dates[0], account);
            if (getter != null)
                returnValue[0] = getter;
            else
                returnValue[0] = new EndTermValue(account, reportingPeriod, new Money(0m, account.BaseCurrency), new Money(0m, account.BaseCurrency), new Money(0m, account.BaseCurrency));

            getter = GetEndValue(session, dates[1], account);
            if (getter != null)
                returnValue[1] = getter;
            else
                returnValue[1] = new EndTermValue(account, reportingPeriod, new Money(0m, account.BaseCurrency), new Money(0m, account.BaseCurrency), new Money(0m, account.BaseCurrency));

            return returnValue;
        }
示例#9
0
        public static DataSet GetEndValueDividWepComparison(int year)
        {
            using (IDalSession session = NHSessionFactory.CreateSession())
            {
                ReportingPeriodDetail detail = new ReportingPeriodDetail(EndTermType.FourthQtr, year);
                IList<IEndTermValue> endValues = EndTermValueMapper.GetYearEndValues(session, detail.GetEndDate());

                IReportEndTermDividWep reportData = new ReportEndTermDividWep(detail, endValues);

                return reportData.Records
                    .Select(r => new
                    {
                        r.AccoutNumber,
                        r.AccoutShortName,
                        r.CashValue,
                        r.FundValue,
                        r.FullValue,
                        r.IncludedinDividWep,
                        r.FullValueForDividWep,
                        r.WEP,
                        r.RoundingError,
                        r.ValuesNotIncludedinWEP
                    }).ToDataSet();

            }
        }