public List<Installment> SimulateScheduleCreation(Loan loan) { var scheduleConfiguration = _configurationFactory .Init() .WithLoan(loan) .Finish() .GetConfiguration(); var scheduleBuilder = new ScheduleBuilder(); var installmentList = scheduleBuilder.BuildSchedule(scheduleConfiguration); var schedule = Mapper.Map<IEnumerable<IInstallment>, List<Installment>>(installmentList); return schedule; }
public Loan SimulateTranche(Loan loan, ITrancheConfiguration trancheConfiguration) { var copyOfLoan = loan.Copy(); var scheduleConfiguration = _configurationFactory .Init() .WithLoan(copyOfLoan) .Finish() .GetConfiguration(); var schedule = Mapper.Map<IEnumerable<Installment>, IEnumerable<IInstallment>>(copyOfLoan.InstallmentList); var scheduleBuilder = new ScheduleBuilder(); var trancheBuilder = new TrancheBuilder(); var trancheAssembler = new TrancheAssembler(); var copyOfTrancheConfiguration = (ITrancheConfiguration) trancheConfiguration.Clone(); copyOfTrancheConfiguration.InterestRate *= (decimal) scheduleConfiguration.PeriodPolicy.GetNumberOfPeriodsInYear( copyOfTrancheConfiguration.StartDate, scheduleConfiguration.YearPolicy); schedule = trancheAssembler.AssembleTranche( schedule, scheduleConfiguration, copyOfTrancheConfiguration, scheduleBuilder, trancheBuilder); var newSchedule = Mapper.Map<IEnumerable<IInstallment>, List<Installment>>(schedule); foreach (var installment in newSchedule) { var oldInstallment = copyOfLoan.InstallmentList.Find(i => i.Number == installment.Number); if (oldInstallment == null) break; installment.Comment = oldInstallment.Comment; installment.PaidFees = oldInstallment.PaidFees; installment.PaidCommissions = oldInstallment.PaidCommissions; installment.FeesUnpaid = oldInstallment.FeesUnpaid; installment.CommissionsUnpaid = oldInstallment.CommissionsUnpaid; installment.IsPending = oldInstallment.IsPending; //installment.PaidDate = oldInstallment.PaidDate; } copyOfLoan.InstallmentList = newSchedule; copyOfLoan.NbOfInstallments = newSchedule.Count(); copyOfLoan.Amount += trancheConfiguration.Amount; return copyOfLoan; }
public Loan SimulateRescheduling(Loan loan, ScheduleConfiguration rescheduleConfiguration) { var copyOfLoan = loan.Copy(); var scheduleConfiguration = _configurationFactory .Init() .WithLoan(copyOfLoan) .Finish() .GetConfiguration(); var schedule = Mapper.Map<IEnumerable<Installment>, IEnumerable<IInstallment>>(copyOfLoan.InstallmentList); var scheduleBuilder = new ScheduleBuilder(); var rescheduleAssembler = new RescheduleAssembler(); var copyOfRescheduleConfiguration = (IScheduleConfiguration) rescheduleConfiguration.Clone(); copyOfRescheduleConfiguration.InterestRate *= (decimal) scheduleConfiguration.PeriodPolicy.GetNumberOfPeriodsInYear( copyOfRescheduleConfiguration.StartDate, scheduleConfiguration.YearPolicy); schedule = rescheduleAssembler.AssembleRescheduling( schedule, scheduleConfiguration, copyOfRescheduleConfiguration, scheduleBuilder, loan.CalculateActualOlb().Value); var newSchedule = Mapper.Map<IEnumerable<IInstallment>, List<Installment>>(schedule); copyOfLoan.InstallmentList = newSchedule; copyOfLoan.NbOfInstallments = newSchedule.Count(); return copyOfLoan; }
public Loan SimulateTranche(Loan loan, ITrancheConfiguration trancheConfiguration) { var copyOfLoan = loan.Copy(); var scheduleConfiguration = _configurationFactory .Init() .WithLoan(copyOfLoan) .Finish() .GetConfiguration(); var schedule = copyOfLoan.InstallmentList; var scheduleBuilder = new ScheduleBuilder(); var trancheBuilder = new TrancheBuilder(); var trancheAssembler = new TrancheAssembler(); var copyOfTrancheConfiguration = (ITrancheConfiguration)trancheConfiguration.Clone(); var newSchedule = new List<Installment>(); if (loan.Product.ScriptName == null) newSchedule = trancheAssembler.AssembleTranche( schedule, scheduleConfiguration, copyOfTrancheConfiguration, scheduleBuilder, trancheBuilder).ToList(); else newSchedule = AssembleTranche(copyOfLoan, scheduleConfiguration, trancheConfiguration); foreach (var installment in newSchedule) { var oldInstallment = copyOfLoan.InstallmentList.Find(i => i.Number == installment.Number); if (oldInstallment == null) break; installment.Comment = oldInstallment.Comment; installment.PaidFees = oldInstallment.PaidFees; installment.PaidCommissions = oldInstallment.PaidCommissions; installment.FeesUnpaid = oldInstallment.FeesUnpaid; installment.CommissionsUnpaid = oldInstallment.CommissionsUnpaid; installment.IsPending = oldInstallment.IsPending; //installment.PaidDate = oldInstallment.PaidDate; } copyOfLoan.InstallmentList = newSchedule; copyOfLoan.NbOfInstallments = newSchedule.Count(); copyOfLoan.Amount += trancheConfiguration.Amount; return copyOfLoan; }
public List<Installment> SimulateScheduleCreation(Loan loan) { try { if (loan.Product.ScriptName != null) return SimulateScriptSchedule(loan); var scheduleConfiguration = _configurationFactory .Init() .WithLoan(loan) .Finish() .GetConfiguration(); var scheduleBuilder = new ScheduleBuilder(); var installmentList = scheduleBuilder.BuildSchedule(scheduleConfiguration); //var schedule = Mapper.Map<IEnumerable<IInstallment>, List<Installment>>(installmentList); return installmentList; } catch (Exception ex) { MessageBox.Show(ex.Message); return null; } }
public Loan SimulateRescheduling(Loan loan, ScheduleConfiguration rescheduleConfiguration) { var copyOfLoan = loan.Copy(); var scheduleConfiguration = _configurationFactory .Init() .WithLoan(copyOfLoan) .Finish() .GetConfiguration(); var schedule = copyOfLoan.InstallmentList; var scheduleBuilder = new ScheduleBuilder(); var rescheduleAssembler = new RescheduleAssembler(); var copyOfRescheduleConfiguration = (IScheduleConfiguration)rescheduleConfiguration.Clone(); if (loan.Product.ScriptName == null) schedule = rescheduleAssembler.AssembleRescheduling( schedule, scheduleConfiguration, copyOfRescheduleConfiguration, scheduleBuilder, loan.CalculateActualOlb().Value).ToList(); else schedule = AssembleRescheduling(loan, rescheduleConfiguration, scheduleConfiguration); copyOfLoan.InstallmentList = schedule; copyOfLoan.NbOfInstallments = schedule.Count(); return copyOfLoan; }
public List<Installment> SimulateScheduleCreation(Loan loan) { try { if (loan.ScriptName != null) { var scheduleGenerator = ScheduleGenerators .Where(x => x.Metadata.ContainsKey("Implementation") && x.Metadata["Implementation"].ToString() == loan.ScriptName) .Select(x => x.Value) .FirstOrDefault(); return scheduleGenerator != null ? scheduleGenerator.GetSchedule(loan) : SimulateScriptSchedule(loan); } var scheduleConfiguration = _configurationFactory .Init() .WithLoan(loan) .Finish() .GetConfiguration(); var scheduleBuilder = new ScheduleBuilder(); var installmentList = scheduleBuilder.BuildSchedule(scheduleConfiguration); return installmentList; } catch (Exception ex) { MessageBox.Show(ex.Message); return null; } }