Esempio n. 1
0
        protected void ResolveLastInstallment()
        {
            RepaymentSchedule lastInstallment = GetLastRepaymentInstallment();

            lastInstallment.InstallmentPrincipal = (decimal)Math.Round(Config.PrincipalBalance, 2);

            lastInstallment.InstallmentAmount += lastInstallment.InstallmentPrincipal;

            lastInstallment.Balance = lastInstallment.InstallmentInterest + lastInstallment.InstallmentPrincipal;
        }
        protected void ResolvePrincipalVariance()
        {
            decimal totalPrincipal = GetTotalPrincipal();

            decimal variance = Config.PrincipalBalance - totalPrincipal;

            RepaymentSchedule lastRepaymentInstallment = GetLastRepaymentInstallment();

            lastRepaymentInstallment.InstallmentPrincipal += variance;
        }
        public IEnumerable <RepaymentSchedule> Generate()
        {
            RepaymentSchedules = new List <RepaymentSchedule>();

            int numberOfAmortizations = Config.Term / Config.MonthsPerInstallment;

            double principalBalance = (double)Config.PrincipalBalance;

            double balance = principalBalance;

            int gracePeriods = Config.GracePeriods / Config.MonthsPerInstallment;

            int totalNumberOfAmortizations = numberOfAmortizations + gracePeriods;

            DateTime disbursalDate = Config.DisbursalDate;

            for (var amortizationNumber = 1; amortizationNumber <= totalNumberOfAmortizations; amortizationNumber++)
            {
                double interest = balance * InterestRate;

                double amortization = Math.Abs(Financial.Pmt(InterestRate, numberOfAmortizations, principalBalance));

                double principal = amortization - interest;

                if (amortizationNumber <= gracePeriods)
                {
                    amortization = interest;
                    principal    = 0;
                }

                balance -= principal;

                string installmentDate = disbursalDate.AddMonths(amortizationNumber * Config.MonthsPerInstallment).ToString();


                RepaymentSchedule repaymentSchedule = new RepaymentSchedule
                {
                    InstallmentAmount    = (decimal)Math.Round(amortization, 2),
                    InstallmentNumber    = amortizationNumber,
                    Balance              = (decimal)Math.Round(balance, 2),
                    InstallmentInterest  = (decimal)Math.Round(interest, 2),
                    InstallmentDate      = installmentDate,
                    InstallmentPrincipal = (decimal)Math.Round(principal, 2)
                };

                RepaymentSchedules.Add(repaymentSchedule);
            }

            return(RepaymentSchedules);
        }
        public IEnumerable <RepaymentSchedule> Generate()
        {
            int numberOfAmortizations = Config.Term;



            RepaymentSchedules = new List <RepaymentSchedule>();


            for (var amortizationNumber = 1; amortizationNumber <= numberOfAmortizations; amortizationNumber++)
            {
                decimal interest = Config.PrincipalBalance * InterestRate;

                decimal remainingBalance = Config.PrincipalBalance;

                string installmentDate = Config.DisbursalDate.AddMonths(amortizationNumber).ToString();

                decimal principal = 0;

                if (isPeriodicalAmortizationDate(amortizationNumber))
                {
                    principal = Config.PrincipalBalance;

                    remainingBalance = 0;
                }

                decimal amortization = principal + interest;

                RepaymentSchedule repaymentSchedule = new RepaymentSchedule
                {
                    InstallmentAmount    = amortization,
                    InstallmentNumber    = amortizationNumber,
                    InstallmentInterest  = interest,
                    InstallmentPrincipal = principal,
                    Balance         = remainingBalance,
                    InstallmentDate = installmentDate
                };


                RepaymentSchedules.Add(repaymentSchedule);
            }


            return(RepaymentSchedules);
        }
        public IEnumerable <RepaymentSchedule> Generate()
        {
            RepaymentSchedules = new List <RepaymentSchedule>();

            double principalBalance = (double)Config.PrincipalBalance;

            double balance = principalBalance;

            int numberOfInstallments = Config.NumberOfInstallments;

            DateTime disbursalDate = Config.DisbursalDate;

            for (int installmentNumber = 1; installmentNumber <= numberOfInstallments; installmentNumber++)
            {
                double principal = Math.Abs(Financial.PPmt(InterestRate, installmentNumber, numberOfInstallments, principalBalance));

                double interest = Math.Abs(Financial.IPmt(InterestRate, installmentNumber, numberOfInstallments, principalBalance));


                balance -= principal;

                string installmentDate = disbursalDate.AddMonths(installmentNumber * Config.MonthsPerInstallment).ToString();

                RepaymentSchedule repaymentSchedule = new RepaymentSchedule
                {
                    InstallmentAmount    = (decimal)Math.Round(Ammortization, 2),
                    InstallmentNumber    = installmentNumber,
                    Balance              = (decimal)Math.Round(balance, 2),
                    InstallmentInterest  = ResolveInterestVariance((decimal)Math.Round(principal, 2), (decimal)Math.Round(interest, 2), (decimal)Math.Round(Ammortization, 2)),
                    InstallmentPrincipal = (decimal)Math.Round(principal, 2),
                    InstallmentDate      = installmentDate
                };

                RepaymentSchedules.Add(repaymentSchedule);
            }

            ResolvePrincipalVariance();

            return(RepaymentSchedules);
        }
Esempio n. 6
0
        public IEnumerable <RepaymentSchedule> Generate()
        {
            RepaymentSchedules = new List <RepaymentSchedule>();

            int numberOfInstallments = Config.NumberOfInstallments;

            DateTime disbursalDate = Config.DisbursalDate;

            double remainingBalance = (double)Config.PrincipalBalance;


            for (var installmentNumber = 1; installmentNumber <= numberOfInstallments; installmentNumber++)
            {
                string installmentDate = disbursalDate.AddMonths(installmentNumber * Config.MonthsPerInstallment).ToString();

                double interest = (double)remainingBalance * (double)Config.AnnualInterestRate / OneHundredPercent / MonthsInAYear * Config.MonthsPerInstallment;


                double principal = Ammortization - interest;

                remainingBalance -= principal;


                RepaymentSchedule repaymentSchedule = new RepaymentSchedule
                {
                    InstallmentAmount    = (decimal)Math.Round(Ammortization, 2),
                    InstallmentNumber    = installmentNumber,
                    Balance              = (decimal)remainingBalance,
                    InstallmentInterest  = (decimal)Math.Round(interest, 2),
                    InstallmentPrincipal = (decimal)Math.Round(principal, 2),
                    InstallmentDate      = installmentDate
                };

                RepaymentSchedules.Add(repaymentSchedule);
            }


            return(RepaymentSchedules);
        }