Exemplo n.º 1
0
        public Result CreateStraightLineAmortizationSchedule()
        {
            if (LoanAmount == 0)
            {
                return(new Result(false, "Loan Amount cannot be zero."));
            }

            _amortizationSchedule = new List <ScheduledPayment>();

            decimal monthlyInterestRate   = AnnualInterestRate / 12m;
            decimal monthlyInterestAmount = LoanAmount * monthlyInterestRate;
            decimal principal             = LoanAmount / NumberOfPayments; // eto ung ibabawas monthly sa loan
            decimal monthlyPayment        = principal + monthlyInterestAmount;
            decimal runningBalance        = LoanAmount;

            for (int i = 1; i <= NumberOfPayments; i++)
            {
                var scheduledPayment = new ScheduledPayment
                {
                    PaymentNo = i,
                    Amount    = monthlyPayment,
                    Interest  = monthlyInterestAmount
                };
                scheduledPayment.Principal = principal;
                scheduledPayment.Date      = StartDate.AddMonths(i);
                scheduledPayment.Balance   = runningBalance - principal;
                _amortizationSchedule.Add(scheduledPayment);
                runningBalance = scheduledPayment.Balance;
            }
            // loan summary
            MonthlyPayment    = monthlyPayment;
            TotalPayments     = _amortizationSchedule.Sum(scheduledPayment => scheduledPayment.Amount);
            TotalInterestPaid = _amortizationSchedule.Sum(scheduledPayment => scheduledPayment.Interest);
            PayOffDate        = StartDate.AddMonths(NumberOfPayments);

            return(new Result(true, "CreateStraightLineAmortizationSchedule"));
        }
Exemplo n.º 2
0
        public void CreateDiminishingAmortizationSchedule()
        {
            if (LoanAmount == 0)
            {
                return;
            }
            _amortizationSchedule = new List <ScheduledPayment>();

            decimal monthlyInterestRate   = AnnualInterestRate / 12m;
            decimal presentValueOfAnnuity =
                Convert.ToDecimal(Math.Pow((double)(1 + monthlyInterestRate), NumberOfPayments));
            decimal monthlyPayment = ((monthlyInterestRate * LoanAmount * presentValueOfAnnuity) / (presentValueOfAnnuity - 1));

            decimal runningBalance = LoanAmount;

            for (int i = 1; i <= NumberOfPayments; i++)
            {
                var scheduledPayment = new ScheduledPayment
                {
                    PaymentNo = i,
                    Amount    = monthlyPayment,
                    Interest  = runningBalance * monthlyInterestRate
                };
                scheduledPayment.Principal = monthlyPayment - scheduledPayment.Interest;
                scheduledPayment.Date      = StartDate.AddMonths(i);
                scheduledPayment.Balance   = runningBalance - scheduledPayment.Principal;
                _amortizationSchedule.Add(scheduledPayment);
                runningBalance = scheduledPayment.Balance;
            }

            // loan summary
            MonthlyPayment    = monthlyPayment;
            TotalPayments     = _amortizationSchedule.Sum(scheduledPayment => scheduledPayment.Amount);
            TotalInterestPaid = _amortizationSchedule.Sum(scheduledPayment => scheduledPayment.Interest);
            PayOffDate        = StartDate.AddMonths(NumberOfPayments);
        }