public void Select_Added_loanDisbursmentEvent() { EventManager eventManager = (EventManager)container["EventManager"]; LoanDisbursmentEvent loanDisbursmentEvent = new LoanDisbursmentEvent { Id = 100, User = new User { Id = 1 }, Date = new DateTime(2006, 7, 21), Amount = 100, }; var commission = new LoanEntryFeeEvent(); commission.Fee = 10; loanDisbursmentEvent.Commissions = new List<LoanEntryFeeEvent>(); loanDisbursmentEvent.Commissions.Add(commission); PaymentMethod method = new PaymentMethod(1, "Savings", "Savings method", false); loanDisbursmentEvent.PaymentMethod = method; eventManager.AddLoanEvent(loanDisbursmentEvent, 2); EventStock eventStock = eventManager.SelectEvents(2); foreach (Event e in eventStock.GetEvents()) { if (e is LoanDisbursmentEvent) _AssertLoanDisbursmentEvent(e as LoanDisbursmentEvent, new DateTime(2006, 7, 21), 100, 10); } }
private bool InitializeLoanDisburseEvent() { try { _loanDisbursmentEvent = ServicesProvider.GetInstance().GetContractServices().DisburseSimulation(_loan, _alignInstallmentsDatesOnRealDisbursmentDate, _newStartDate, _disableFees); if (_loanDisbursmentEvent != null) { _lbAmountValue.Text = _loanDisbursmentEvent.Amount.GetFormatedValue(_loan.UseCents); lblAmountCurrency.Text = _loan.Product.Currency.Code; _lbLoanCodeValue.Text = _loan.Code; if (!_feeModified) { SetFeeAmount(); } lblEntryFeeCurrency.Text = _loan.Product.Currency.Code; InitializeExternalCurrency(); } } catch (Exception ex) { new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog(); _exchangeRate = null; InitializeExternalCurrency(); return(false); } return(true); }
private void LoanDisbursmentOrigination(LoanDisbursmentEvent loanDisbursmentEvent, Loan loanContract, SqlTransaction sqlTransac) { int eventId = _eventManagement.AddLoanEvent(loanDisbursmentEvent, loanContract.Id, sqlTransac); loanDisbursmentEvent.Id = eventId; if (loanDisbursmentEvent.Commissions != null) { foreach (LoanEntryFeeEvent entryFeeEvent in loanDisbursmentEvent.Commissions) { if (entryFeeEvent.Fee == 0) { continue; } entryFeeEvent.DisbursementEventId = eventId; entryFeeEvent.User = loanDisbursmentEvent.User; entryFeeEvent.TellerId = loanDisbursmentEvent.TellerId; if (loanContract.CompulsorySavings != null) { entryFeeEvent.Comment = loanContract.CompulsorySavings.Code; } int feeEventId = _eventManagement.AddLoanEventHead(entryFeeEvent, loanContract.Id, sqlTransac); entryFeeEvent.Id = feeEventId; if (entryFeeEvent.Fee != 0) { _eventManagement.AddLoanEntryFeesEvent(entryFeeEvent, sqlTransac); } } } }
public void AddLoanDisbursmentEvent() { EventManager eventManager = (EventManager)container["EventManager"]; LoanDisbursmentEvent loanDisbursmentEvent = new LoanDisbursmentEvent { Id = 10, User = new User { Id = 1 }, Date = new DateTime(2006, 7, 21), Amount = 100, }; loanDisbursmentEvent.Commissions = new List <LoanEntryFeeEvent>(); LoanEntryFeeEvent commission = new LoanEntryFeeEvent(); commission.Fee = 10; loanDisbursmentEvent.Commissions.Add(commission); PaymentMethod method = new PaymentMethod(1, "Savings", "Savings method", false); loanDisbursmentEvent.PaymentMethod = method; eventManager.AddLoanEvent(loanDisbursmentEvent, 1); Assert.AreNotEqual(0, loanDisbursmentEvent.Id); }
private void DisplayEvent() { listViewEvents.Items.Clear(); ListViewItem listViewItem = new ListViewItem(_event.Date.ToShortDateString()); listViewItem.SubItems.Add(_event.Code); listViewItem.Tag = _event; if (_event is LoanDisbursmentEvent) { LoanDisbursmentEvent evt = _event as LoanDisbursmentEvent; listViewItem.SubItems.Add(evt.Amount.GetFormatedValue(true)); listViewItem.SubItems.Add("-"); listViewItem.SubItems.Add("-"); } else if (_event is RepaymentEvent) { RepaymentEvent evt = _event as RepaymentEvent; listViewItem.SubItems.Add(evt.Principal.GetFormatedValue(true)); listViewItem.SubItems.Add(evt.Interests.GetFormatedValue(true)); listViewItem.SubItems.Add(evt.Fees.GetFormatedValue(true)); } else if (_event is BadLoanRepaymentEvent) { BadLoanRepaymentEvent evt = _event as BadLoanRepaymentEvent; listViewItem.SubItems.Add(evt.Principal.GetFormatedValue(true)); listViewItem.SubItems.Add(evt.Interests.GetFormatedValue(true)); listViewItem.SubItems.Add(evt.Fees.GetFormatedValue(true)); } else if (_event is TrancheEvent) { TrancheEvent evt = _event as TrancheEvent; listViewItem.SubItems.Add(evt.Amount.GetFormatedValue(true)); listViewItem.SubItems.Add(evt.InterestRate.GetFormatedValue(true)); listViewItem.SubItems.Add("-"); } else if (_event is RegEvent || _event is WriteOffEvent || _event is LoanValidationEvent) { listViewItem.SubItems.Add("-"); listViewItem.SubItems.Add("-"); listViewItem.SubItems.Add("-"); } else if (_event is RescheduleLoanEvent) { RescheduleLoanEvent evt = _event as RescheduleLoanEvent; listViewItem.SubItems.Add(evt.Amount.GetFormatedValue(true)); listViewItem.SubItems.Add("-"); listViewItem.SubItems.Add("-"); } listViewItem.SubItems.Add(_event.Cancelable.ToString()); if (_event.Deleted) { listViewItem.BackColor = Color.FromArgb(188, 209, 199); listViewItem.ForeColor = Color.White; } listViewEvents.Items.Add(listViewItem); }
public void TestLoanDisbursmentEventAmount() { LoanDisbursmentEvent LDIE = new LoanDisbursmentEvent { Amount = 432.3m }; Assert.AreEqual(432.3m, LDIE.Amount.Value); }
public static LoanDisbursmentEvent GenerateLoanDisbursmentEvent(Loan pLoan, ApplicationSettings pGeneralSettings, DateTime pDisburseDate, bool pAlignInstallmentsDatesOnRealDisbursmentDate, bool pDisableFees, User pUser) { if (pAlignInstallmentsDatesOnRealDisbursmentDate) { //pLoan.StartDate = pDisburseDate; //for (int i = 1; i <= pLoan.NbOfInstallments; i++) //{ // pLoan.InstallmentList[i - 1].ExpectedDate = pLoan.CalculateInstallmentDate(pLoan.StartDate, i); //} } else { if (pGeneralSettings.PayFirstInterestRealValue) { TimeSpan time = pDisburseDate - pLoan.StartDate; int diffDays = Math.Abs(time.Days); int nbOfDaysInPeriod = pLoan.InstallmentType.NbOfMonths * AVERAGE_NB_OF_DAYS_IN_MONTH + pLoan.InstallmentType.NbOfDays; if (pDisburseDate.CompareTo(pLoan.StartDate) < 0) { pLoan.GetInstallment(0).InterestsRepayment += (Convert.ToDecimal(pLoan.InterestRate) * diffDays * pLoan.Amount / (double)nbOfDaysInPeriod); } else { pLoan.GetInstallment(0).InterestsRepayment -= (Convert.ToDecimal(pLoan.InterestRate) * diffDays * pLoan.Amount / (double)nbOfDaysInPeriod); } if (AmountComparer.Compare(pLoan.GetInstallment(0).InterestsRepayment, 0) < 0) { pLoan.GetInstallment(0).InterestsRepayment = 0; } pLoan.GetInstallment(0).InterestsRepayment = Math.Round(pLoan.GetInstallment(0).InterestsRepayment.Value, 2); } } pLoan.Disbursed = true; LoanDisbursmentEvent lDe = !pDisableFees ? new LoanDisbursmentEvent { Date = pDisburseDate, Amount = pLoan.Amount, ClientType = pLoan.ClientType } : new LoanDisbursmentEvent { Date = pDisburseDate, Amount = pLoan.Amount, Commissions = null, ClientType = pLoan.ClientType }; pLoan.Events.Add(lDe); return(lDe); }
private static OCurrency GetValue(LoanDisbursmentEvent eventItem, ContractAccountingRule rule) { OCurrency amount = 0; if (rule.EventAttribute.Name.ToLower() == "amount") { amount = eventItem.Amount; } if (rule.EventAttribute.Name.ToLower() == "fees") { amount = eventItem.Fee; } if (rule.EventAttribute.Name.ToLower() == "interest") { amount = eventItem.Interest; } return(amount); }
public void TestIfLoanDisbursmentEventCodeCorrectlySetAndRetrieved() { LoanDisbursmentEvent lODE = new LoanDisbursmentEvent(); Assert.AreEqual("LODE", lODE.Code); }
public void SetUp() { loanDisbursmentEvent = new LoanDisbursmentEvent(); }
private static void _AssertLoanDisbursmentEvent(LoanDisbursmentEvent pEvent, DateTime pDate, OCurrency pAmount, OCurrency pCommission) { Assert.AreEqual("LODE", pEvent.Code); Assert.AreEqual(pDate, pEvent.Date); Assert.AreEqual(pAmount.Value, pEvent.Amount.Value); }