public void check_fees_on_experied_rollover2() { const int rolloverAmount = 50; var calculator = new LoanScheduleCalculator { Interest = 0.06M }; calculator.Calculate(1000, _loan, Parse("2012-12-05 00:00:00.000")); var rollover = new PaymentRollover { LoanSchedule = _loan.Schedule[0], Created = Parse("2013-01-08 13:35:59.000"), ExpiryDate = Parse("2013-01-09 00:00:00.000"), Payment = rolloverAmount }; _loan.Schedule[0].Rollovers.Add(rollover); var payEarlyCalc = new LoanRepaymentScheduleCalculator(_loan, Parse("2013-01-11 10:10:10.000"), 0); //state for expired rollover var state1 = payEarlyCalc.GetState(); var state = payEarlyCalc.GetState(); var model = LoanModel.FromLoan(_loan, payEarlyCalc, payEarlyCalc); Assert.That(state.Fees, Is.EqualTo(0)); Assert.That(state.AmountDue, Is.EqualTo(405.61m)); Assert.That(state.LateCharges, Is.EqualTo(0)); Assert.That(state.Interest, Is.EqualTo(405.61m - 334m)); Assert.That(model.Late, Is.EqualTo(405.61m)); }
public void fees_are_added_to_payments() { var loanAmount = 10000; var loan1 = new Loan(); _calculator.Calculate(loanAmount, loan1, Parse("2013-02-28 14:27:14.000")); loan1.Status = LoanStatus.Live; var charge = new LoanCharge() { Loan = loan1, Amount = 20, Date = Parse("2013-04-10 01:11:12.000") }; loan1.Charges.Add(charge); var now = Parse("2013-02-28 16:40:13.000"); var c1 = new LoanRepaymentScheduleCalculator(loan1, now, 0); var lm1 = LoanModel.FromLoan(loan1, c1, c1); Console.WriteLine(loan1); Assert.That(lm1.TotalEarlyPayment, Is.EqualTo(loanAmount)); }
public JsonResult Get(int id) { var customer = _context.Customer; var loan = customer.Loans.SingleOrDefault(l => l.Id == id); ILoanRepaymentScheduleCalculator calculator = new LoanRepaymentScheduleCalculator(loan, DateTime.UtcNow, CurrentValues.Instance.AmountToChargeFrom); var loanModel = LoanModel.FromLoan(loan, calculator); return(Json(loanModel, JsonRequestBehavior.AllowGet)); }
public override void ExecuteResult(ControllerContext context) { var generator = new ExelReportGenarator.LoanHistoryExelReportGenerator(); var loans = _customer.Loans.Select(l => LoanModel.FromLoan(l, new LoanRepaymentScheduleCalculator(l, null, CurrentValues.Instance.AmountToChargeFrom))).ToList(); var content = generator.GenerateReport(loans, _customer.PersonalInfo.Fullname); var f = new FileContentResult(content, "application/xls") { FileDownloadName = "LoanHistory(" + _customer.PersonalInfo.Fullname + ").xls" }; f.ExecuteResult(context); }
public JsonResult Index(int id) { Customer customer = this.customerRepository.Get(id); var loans = customer .Loans .Select(l => LoanModel.FromLoan(l, new LoanRepaymentScheduleCalculator(l, null, CurrentValues.Instance.AmountToChargeFrom))).ToList(); var decisions = this.serviceClient.Instance.LoadDecisionHistory(customer.Id, this.context.UserId); var offers = decisions.Model .Select(CashRequestModel.Create) .ToList(); return(Json(new { offers = offers, loans = loans }, JsonRequestBehavior.AllowGet)); }
public void delinquency_for_almost_paid_installment4() { _calculator.Interest = 0.069m; CreateLoan(Parse("2013-07-25 00:00:00.000"), 1000); MakePayment(236.0m, Parse("2013-08-25 00:00:00.000")); MakePayment(164.0m, Parse("2013-08-25 00:00:00.000")); LoanModel.FromLoan(_loan, new LoanRepaymentScheduleCalculator(_loan, Parse("2013-08-30 16:52:00.000"), 0)); Console.Write(_loan); Assert.That(_loan.MaxDelinquencyDays, Is.EqualTo(5)); Assert.That(_loan.Customer.CreditResult, Is.EqualTo(CreditResultStatus.Late)); }
public JsonResult Index(int id) { var customer = this.customerRepository.Get(id); var collectionStatus = customer.CollectionStatus; var loans = customer.Loans.Select(l => LoanModel.FromLoan(l, new LoanRepaymentScheduleCalculator(l, null, CurrentValues.Instance.AmountToChargeFrom))).ToList(); var loansNonClosed = loans.Where(l => l.DateClosed == null).ToList(); var data = new CollectionStatusModel { CurrentStatus = collectionStatus.Id, CollectionDescription = customer.CollectionDescription, Items = loansNonClosed.Select(loan => new CollectionStatusItem { LoanId = loan.Id, LoanRefNumber = loan.RefNumber }).ToList() }; return(Json(data, JsonRequestBehavior.AllowGet)); }
public void check_total_early_payment() { var calculator = new LoanScheduleCalculator() { Interest = 0.06M, Term = 3 }; var now = Parse("2012-12-26 01:11:16.000"); calculator.Calculate(1000, _loan, Parse("2012-12-22 13:52:25.000")); _loan.Status = LoanStatus.Live; Console.WriteLine(_loan); MakePayment(1003.87m, Parse("2012-12-24 14:56:16.000")); var model = LoanModel.FromLoan(_loan, new LoanRepaymentScheduleCalculator(_loan, now, 0), new LoanRepaymentScheduleCalculator(_loan, now, 0)); Assert.That(_loan.TotalEarlyPayment(now), Is.EqualTo(0)); Assert.That(model.TotalEarlyPayment, Is.EqualTo(0)); }
public void build_model_for_halfway_loan() { var now = new DateTime(2013, 01, 01); var type = new HalfWayLoanType(); var loan = new Loan() { LoanType = type, LoanAmount = 1000, Date = now }; var schedule = _calculator.Calculate(1000m, loan, now); Console.WriteLine(loan); var pc = new LoanRepaymentScheduleCalculator(loan, now, 0); var model = LoanModel.FromLoan(loan, pc); Console.WriteLine(loan); Assert.That(schedule[0].Interest, Is.EqualTo(60)); Assert.That(schedule[1].Interest, Is.EqualTo(60)); }
public void pay_total_late_loans_pays_only_layte_loans() { var loan1 = new Loan(); _calculator.Calculate(100, loan1, Parse("2013-01-01 10:34:41.000")); loan1.Status = LoanStatus.Live; var loan2 = new Loan(); _calculator.Calculate(2000, loan2, Parse("2012-11-19 19:52:25.000")); loan2.Status = LoanStatus.Live; var now = Parse("2013-01-15 13:52:25.000"); var c1 = new LoanRepaymentScheduleCalculator(loan1, now, 0); var lm1 = LoanModel.FromLoan(loan1, c1, c1); var c2 = new LoanRepaymentScheduleCalculator(loan2, now, 0); var lm2 = LoanModel.FromLoan(loan2, c2, c2); _customer.Loans.Add(loan1); _customer.Loans.Add(loan2); Console.WriteLine(loan1); Console.WriteLine(loan2); var lates = lm2.Late; _facade.MakePayment("", lates, "", "totalLate", 0, _customer, now); Console.WriteLine(loan1); Console.WriteLine(loan2); Assert.That(loan1.Transactions.Count, Is.EqualTo(0)); Assert.That(loan2.Transactions.Count, Is.EqualTo(1)); Assert.That(loan1.Schedule[0].Status, Is.EqualTo(LoanScheduleStatus.StillToPay)); Assert.That(loan2.Schedule[0].Status, Is.EqualTo(LoanScheduleStatus.Paid)); }
//https://trello.com/c/x2e8DXJ8 public void trello_card_244() { var calculator = new LoanScheduleCalculator() { Interest = 0.06M, Term = 3 }; calculator.Calculate(1000, _loan, Parse("2012-11-08 00:00:00.000")); _loan.Status = LoanStatus.Live; Console.WriteLine(_loan); var payEarlyCalc = new LoanRepaymentScheduleCalculator(_loan, Parse("2013-01-08 16:03:42.000"), 0); var state = payEarlyCalc.GetState(); var earlyPayment = payEarlyCalc.TotalEarlyPayment(); var model = LoanModel.FromLoan(_loan, payEarlyCalc, payEarlyCalc); Assert.That(state.AmountDue, Is.EqualTo(787)); Assert.That(earlyPayment, Is.EqualTo(1120m)); Assert.That(model.Late, Is.EqualTo(454)); }
} // BuildWizardModel private void BuildProfileModel(CustomerModel customerModel, Customer customer) { customerModel.FirstName = string.Empty; customerModel.MiddleName = string.Empty; customerModel.LastName = string.Empty; if (customer.PersonalInfo != null) { customerModel.FirstName = customer.PersonalInfo.FirstName; customerModel.MiddleName = customer.PersonalInfo.MiddleInitial; customerModel.LastName = customer.PersonalInfo.Surname; } // if customerModel.bankAccountAdded = customer.HasBankAccount; if (customer.HasBankAccount) { customerModel.BankAccountNumber = customer.BankAccount.AccountNumber; customerModel.SortCode = customer.BankAccount.SortCode; } // if customerModel.LastApprovedLoanTypeID = 0; customerModel.LastApprovedRepaymentPeriod = 0; customerModel.IsLastApprovedLoanSourceEu = false; customerModel.IsLastApprovedLoanSourceCOSME = false; customerModel.SignedLegalID = 0; customerModel.LastApprovedAmount = 0; customerModel.HasApprovalChance = customer.HasApprovalChance; customerModel.IsLoanTypeSelectionAllowed = customer.IsLoanTypeSelectionAllowed; if (customer.LastCashRequest != null) { customerModel.LastApprovedAmount = (int)(customer.LastCashRequest.ManagerApprovedSum ?? 0); customerModel.LastApprovedLoanTypeID = customer.LastCashRequest.LoanType.Id; customerModel.LastRepaymentPeriod = customer.LastCashRequest.RepaymentPeriod; customerModel.LastApprovedRepaymentPeriod = customer.LastCashRequest.ApprovedRepaymentPeriod ?? customer.LastCashRequest.RepaymentPeriod; customerModel.IsLastApprovedLoanSourceEu = customer.LastCashRequest.LoanSource.Name == LoanSourceName.EU.ToString(); customerModel.IsLastApprovedLoanSourceCOSME = customer.LastCashRequest.LoanSource.Name == LoanSourceName.COSME.ToString(); LoanLegal lastll = customer.LastCashRequest.LoanLegals.LastOrDefault(); customerModel.SignedLegalID = (lastll == null) ? 0 : lastll.Id; customerModel.IsCustomerRepaymentPeriodSelectionAllowed = customer.LastCashRequest.IsCustomerRepaymentPeriodSelectionAllowed; } // if customerModel.Medal = customer.Medal.HasValue ? customer.Medal.ToString() : ""; customerModel.OfferStart = customer.OfferStart; customerModel.OfferValidUntil = customer.OfferValidUntil; customerModel.Loans = customer.Loans .OrderBy(l => l.Status) .ThenByDescending(l => l.Date) .Select(l => LoanModel.FromLoan(l, new LoanRepaymentScheduleCalculator(l, null, CurrentValues.Instance.AmountToChargeFrom), new LoanRepaymentScheduleCalculator(l, DateTime.UtcNow, CurrentValues.Instance.AmountToChargeFrom))) .ToList(); customerModel.TotalBalance = customerModel.Loans.Sum(l => l.Balance); customerModel.PrincipalBalance = customer.ActiveLoans.Sum(l => l.LoanAmount); customerModel.TotalEarlyPayment = customerModel.Loans.Sum(l => l.TotalEarlyPayment); customerModel.TotalLatePayment = customerModel.Loans .Where(l => l.Status == LoanStatus.Late.ToString()) .Sum(l => l.Late); var nextPayment = ( from loan in customer.ActiveLoans from repayment in loan.Schedule where repayment.AmountDue > 0 where repayment.Status == LoanScheduleStatus.StillToPay || repayment.Status == LoanScheduleStatus.Late orderby repayment.Date select repayment ).FirstOrDefault(); if (nextPayment != null) { customerModel.NextPayment = nextPayment.AmountDue; customerModel.NextPaymentDate = nextPayment.Date; customerModel.IsEarly = nextPayment.Date > DateTime.UtcNow && ( nextPayment.Date.Year != DateTime.UtcNow.Year || nextPayment.Date.Month != DateTime.UtcNow.Month || nextPayment.Date.Day != DateTime.UtcNow.Day ); } // if try { customerModel.TotalPayEarlySavings = new LoanPaymentFacade().CalculateSavings(customer, DateTime.UtcNow); } catch (Exception) { //do nothing } // try var payments = from loan in customer.Loans from tran in loan.Transactions where tran is PaypointTransaction orderby tran.PostDate descending select tran; var lastPayment = payments.OfType <PaypointTransaction>().FirstOrDefault(); if (lastPayment != null) { customerModel.LastPaymentTotal = lastPayment.Amount; customerModel.LastPaymentPrincipal = lastPayment.Principal; customerModel.LastPaymentInterest = lastPayment.Interest; customerModel.LastPaymentFees = lastPayment.Fees; } // if var isDefault = customer.CollectionStatus != null && customer.CollectionStatus.IsDefault; customerModel.BlockTakingLoan = customer.BlockTakingLoan; //customerModel.Perks = isDefault ? null : m_oPerksRepository.GetActivePerk(); customerModel.TrustPilotStatusID = customer.TrustPilotStatus.ID; // Currently disabled trust pilot for EVL customers customerModel.TrustPilotReviewEnabled = CurrentValues.Instance.TrustPilotReviewEnabled && customer.CustomerOrigin.IsEzbob(); customerModel.PayPointCards = FillPayPointCards(customer); customerModel.ActiveRollovers = m_oPaymentRolloverRepository .GetRolloversForCustomer(customer.Id) .Where(x => x.Status == RolloverStatus.New) .Select(x => new RolloverModel { Created = x.Created, CreatorName = x.CreatorName, CustomerConfirmationDate = x.CustomerConfirmationDate, ExpiryDate = x.ExpiryDate, Id = x.Id, LoanScheduleId = x.LoanSchedule.Id, PaidPaymentAmount = x.PaidPaymentAmount, Payment = x.Payment, PaymentDueDate = x.PaymentDueDate, PaymentNewDate = x.PaymentNewDate, Status = x.Status, LoanId = x.LoanSchedule.Loan.Id, RolloverPayValue = GetRolloverPayValue(x.LoanSchedule.Loan) }); customerModel.ApplyCount = customer.ApplyCount; customerModel.IsDefaultCustomerStatus = customer.CollectionStatus.IsDefault; customerModel.HasRollovers = customerModel.ActiveRollovers.Any(); var lastTurnover = customer.Turnovers.OrderByDescending(x => x.Timestamp) .FirstOrDefault(); if (lastTurnover != null) { customerModel.Turnover = lastTurnover.Turnover; customerModel.IsTurnoverExpired = (DateTime.Today - lastTurnover.Timestamp).TotalDays > (365.0 / 2); //half year } else { customerModel.Turnover = 0; customerModel.IsTurnoverExpired = true; } SafeReader sr = DbConnectionGenerator.Get(new SafeILog(this)).GetFirst( "LoadActiveLotteries", CommandSpecies.StoredProcedure, new QueryParameter("UserID", customer.Id), new QueryParameter("Now", DateTime.UtcNow) ); customerModel.LotteryPlayerID = sr.IsEmpty ? string.Empty : ((Guid)sr["UniqueID"]).ToString("N"); customerModel.LotteryCode = sr["LotteryCode"]; } // BuildProfileModel