Example #1
0
        public PaymentSummary(LoanCalculationInput input, FeeOptions feeOptions)
        {
            PaymentItems = new List <PaymentItem>();

            VehiclePrice           = input.VehiclePrice.Value;
            DepositAmount          = input.DepositAmount.Value;
            LoanAmount             = VehiclePrice - DepositAmount;
            RateOfInterest         = 0;
            MaximumRepaymentPeriod = input.FinanceYear.Value * 12;
            MonthlyPayment         = CalculateMonthlyPayment(input);
            DeliveryDate           = input.DeliveryDate.Value;
            ArrangementFee         = feeOptions.ArrangementFee;
            CompletionFee          = feeOptions.CompletionFee;

            decimal totalPayment = 0;

            for (int index = 0; index < MaximumRepaymentPeriod; index++)
            {
                decimal paymentAmount = MonthlyPayment;
                totalPayment += paymentAmount;

                if (index == 0)
                {
                    paymentAmount += ArrangementFee;
                }

                if (index == MaximumRepaymentPeriod - 1)
                {
                    paymentAmount += CompletionFee;
                }

                DateTime deliveryMonth = DeliveryDate.AddMonths(index + 1);
                PaymentItems.Add(new PaymentItem(GetFirstMonday(new DateTime(deliveryMonth.Year, deliveryMonth.Month, 1)), paymentAmount, LoanAmount - totalPayment));
            }
        }
Example #2
0
 private decimal CalculateMonthlyPayment(LoanCalculationInput input)
 {
     return(LoanAmount / (input.FinanceYear.Value * 12));
 }