public void TestClosureEventWithCurrency() { EventStock eventStock = new EventStock { new LoanDisbursmentEvent { Id = 1, Date = new DateTime(2000, 1, 1), Amount = 100, PaymentMethod = new PaymentMethod { Id = 0 }, ClientType = OClientTypes.Person, EconomicActivity = new EconomicActivity(1, "Agriculture", null, false), Currency = new Currency { Id = 1 } }, new RepaymentEvent { Id = 2, Principal = 100, Interests = 5, Penalties = 1, Commissions = 0, Date = new DateTime(2000, 1, 1), Currency = new Currency { Id = 1 }, ClientType = OClientTypes.Person }, }; eventStock.GetRepaymentEvents()[0].LoanProduct = new LoanProduct { Id = 2, Code = "EDE60", Name = "EDEN 60", Currency = new Currency { Id = 1 } }; AccountingClosure closure = new AccountingClosure(); List <FiscalYear> fYears = new List <FiscalYear> { new FiscalYear { OpenDate = new DateTime(1900, 1, 1) } }; List <Booking> bookings = closure.GetBookings(_rules, eventStock, null, null, null, fYears); Assert.AreEqual(bookings[0].Amount, 100); Assert.AreEqual(bookings[0].DebitAccount.Number, "1052"); Assert.AreEqual(bookings[0].CreditAccount.Number, "1020"); }
public void TestClosureTellerEvents() { EventStock eventStock = new EventStock { new TellerCashInEvent { Id = 1, Amount = 1000, Currency = new Currency { Id = 1 }, Date = new DateTime(2000, 1, 1), TellerId = 2 } }; eventStock.Add(new EventStock { new TellerCashOutEvent { Id = 2, Amount = 267, Currency = new Currency { Id = 1 }, Date = new DateTime(2000, 1, 1), TellerId = 3 } }); List <FiscalYear> fYears = new List <FiscalYear> { new FiscalYear { OpenDate = new DateTime(1900, 1, 1) } }; AccountingClosure closure = new AccountingClosure(); List <Booking> bookings = closure.GetBookings(_rules, eventStock, _tellers, null, null, fYears); Assert.AreEqual(bookings[0].Amount, 1000); Assert.AreEqual(bookings[0].CreditAccount.Number, "1991"); Assert.AreEqual(bookings[0].DebitAccount.Number, "1999"); Assert.AreEqual(bookings[1].Amount, 267); Assert.AreEqual(bookings[1].CreditAccount.Number, "1999"); Assert.AreEqual(bookings[1].DebitAccountNumber, "1992"); }
public void TestClosureLodeEvent() { EventStock eventStock = new EventStock { new LoanDisbursmentEvent { Id = 1, Amount = 100, Date = new DateTime(2000, 1, 1), EconomicActivity = new EconomicActivity(1, "Agriculture", null, false), ClientType = OClientTypes.Person, PaymentMethod = new PaymentMethod { Id = 0 }, LoanProduct = new LoanProduct { Id = 1, Code = "EDE34", Name = "EDEN 34", Currency = new Currency { Id = 1 } }, Currency = new Currency { Id = 0 } } }; List <FiscalYear> fYears = new List <FiscalYear> { new FiscalYear { OpenDate = new DateTime(1900, 1, 1) } }; AccountingClosure closure = new AccountingClosure(); List <Booking> bookings = closure.GetBookings(_rules, eventStock, null, null, null, fYears); Assert.AreEqual(bookings[0].Amount, 100); Assert.AreEqual(bookings[0].DebitAccount.Number, "1052"); Assert.AreEqual(bookings[0].CreditAccount.Number, "1020"); }
private void GetBookings(ClosureOptions options) { List <Booking> bookings = new List <Booking>(); EventStock eventStock = new EventStock(); AccountingRuleCollection rules = ServicesProvider.GetInstance().GetAccountingRuleServices().SelectAll(); rules.SortByOrder(); if (options.DoLoanClosure) { UpdateStatus("LoanClosureProcessing", ""); eventStock = ServicesProvider.GetInstance().GetEventProcessorServices().SelectEventsForClosure(_beginDate, _endDate, _branch); UpdateStatus("LoanClosureProcessing", eventStock.GetEvents().Count.ToString()); //add generated events for processing } if (options.DoSavingClosure) { UpdateStatus("SavingsClosureProcessing", ""); eventStock.AddRange( ServicesProvider.GetInstance().GetSavingServices().SelectEventsForClosure( _beginDate, _endDate, _branch)); UpdateStatus("SavingsClosureProcessing", eventStock.GetEvents().Count.ToString()); } if (options.DoTellerManagementClosure) { UpdateStatus("TellerManagementProcessing", ""); eventStock.AddRange(ServicesProvider.GetInstance().GetEventProcessorServices().GetTellerEventsForClosure( _beginDate, _endDate)); UpdateStatus("EventClosureProcessing", eventStock.GetEvents().Count.ToString()); } //important to have sorted list eventStock.SortEventsById(); //closure procesing timerClosure.Start(); timerClosure.Enabled = true; //set ex rate List <ExchangeRate> rates = ServicesProvider.GetInstance().GetExchangeRateServices().SelectRatesByDate(_beginDate, _endDate); List <CoreDomain.Accounting.FiscalYear> fiscalYears = ServicesProvider.GetInstance().GetChartOfAccountsServices().SelectFiscalYears(); bookings.AddRange( _accountingClosure.GetBookings( rules, eventStock, ServicesProvider.GetInstance().GetTellerServices().FindAllTellers(), ServicesProvider.GetInstance().GetPaymentMethodServices().GetAllPaymentMethodsForClosure(), rates, fiscalYears)); timerClosure.Stop(); timerClosure.Enabled = false; //manual transactions if (options.DoManualEntries) { bookings.AddRange(ServicesProvider.GetInstance().GetAccountingServices().SelectMovements(false, rates, fiscalYears)); } #region Reversal if (options.DoReversalTransactions) { UpdateStatus("ReversalTransactionProcessing", ""); bookings.AddRange(ServicesProvider.GetInstance().GetAccountingServices().SelectMovementsForReverse( rates, fiscalYears)); } #endregion //add reversal provision booking if (options.DoLoanClosure) { bookings.AddRange( _generatedEvents.GetProvisionEvents().Select( provisionEvent => ServicesProvider.GetInstance().GetAccountingServices().SelectProvisionMovments( provisionEvent.ContracId, rates, fiscalYears)).Where(b => b != null)); } SortBookingsByDate(bookings); FillListView(bookings); }