public IEnumerable <PaymentPlanItemModel> CalculatePaymentPlan(Guid loanTypeId, Guid paymentSchemeTypeId, double loanAmount, int yearCount)
        {
            LoanTypeBO          loanType          = LoanTypeService.GetByGuid(loanTypeId);
            PaymentSchemeTypeBO paymentSchemeType =
                ServiceProvider.GetService <PaymentSchemeTypeService>().GetByGuid(paymentSchemeTypeId);

            return(LoanTypeService
                   .CalculatePaymentPlan(loanType, paymentSchemeType, loanAmount, yearCount)
                   .Select(p => new PaymentPlanItemModel()
            {
                Amortization = p.Amortization,
                Interest = p.Interest,
                MonthNumber = p.MonthNumber
            }));
        }
        public List <PaymentPlanItem> CalculatePaymentPlan(LoanTypeBO loanType, double loanAmount, int yearCount)
        {
            int monthCount = GetMonthCount(yearCount);

            List <PaymentPlanItem> paymentPlanItems = new List <PaymentPlanItem>();

            double amortization = loanAmount / monthCount;

            for (int i = 0; i < monthCount; i++)
            {
                double interest = loanAmount * GetPecentAsDecimal(loanType.Percent) / MONTHS_IN_YEAR;
                loanAmount -= amortization;
                paymentPlanItems.Add(new PaymentPlanItem()
                {
                    MonthNumber  = i + 1,
                    Amortization = amortization,
                    Interest     = interest
                });
            }

            return(paymentPlanItems);
        }
예제 #3
0
 public LoansController(EmployeeBO employeeBo, LoanBO loanBO, LoanTypeBO loanTypesBO)
 {
     _employeeBo  = employeeBo;
     _loanBO      = loanBO;
     _loanTypesBO = loanTypesBO;
 }