コード例 #1
0
        public RefinancingCalcResults Calculate(RefinancingCalcParams p)
        {
            IsParamsValid(p);
            RefinancingCalcResults res = new RefinancingCalcResults();

            res.CurrRate   = p.CurrentCreditRate.Value;
            res.NewRate    = p.NewCreditRate.Value;
            res.CurrPeriod = p.CurrentCreditPeriod.Value;
            res.NewPeriod  = p.CurrentCreditPeriod.Value - p.CurrentCreditMadeInstallments.Value;

            decimal principalInstallments = p.CurrentCreditAmount.Value - GetPrincipalInstalments(p.CurrentCreditAmount.Value, p.CurrentCreditPeriod.Value, p.CurrentCreditMadeInstallments.Value, p.CurrentCreditRate.Value);

            res.CurrPreTermFee         = (p.CurrentCreditAmount.Value - principalInstallments) * p.CurrentCreditPreTermFee.Value / 100;
            res.CurrMonthlyInstallment = PMT(p.CurrentCreditRate.Value, p.CurrentCreditPeriod.Value, p.CurrentCreditAmount.Value);
            int newCreditPeriod = (p.CurrentCreditPeriod.Value - p.CurrentCreditMadeInstallments.Value);

            res.CurrTotalPaid         = Math.Round(PMT(p.CurrentCreditRate.Value, p.CurrentCreditPeriod.Value, p.CurrentCreditAmount.Value) * newCreditPeriod, 2);
            res.NewMonthlyInstallment = PMT(p.NewCreditRate.Value, newCreditPeriod, p.CurrentCreditAmount.Value - principalInstallments);

            decimal newCreditFees     = getFeeAmount(p.CurrentCreditAmount.Value, p.NewCreditInitialFeesPercent, true) + p.NewCreditInitialFeesCurrency.Value;
            decimal newCreditToBePaid = res.NewMonthlyInstallment * newCreditPeriod;

            res.NewTotalPaid = newCreditToBePaid + newCreditFees + res.CurrPreTermFee;

            res.CurrPreTermFee         = Math.Round(res.CurrPreTermFee, 2);
            res.NewTotalPaid           = Math.Round(res.NewTotalPaid, 2);
            res.NewMonthlyInstallment  = Math.Round(res.NewMonthlyInstallment, 2);
            res.CurrMonthlyInstallment = Math.Round(res.CurrMonthlyInstallment, 2);
            return(res);
        }
コード例 #2
0
        public ActionResult RefinancingCalculator(RefinancingCalcParamsVM model)
        {
            if (!model.IsModelValid(ModelState))
            {
                return(PartialView("_InvalidRefinancingParamsPartial", model));
            }

            var parameters = GetParamsFromModel(model);
            RefinancingCalcResults   refinancingResult          = this.calculatorService.CalculateRefinancing(parameters);
            RefinancingCalcResultsVM refinancingViewModelResult = GetResultsForModel(refinancingResult);

            return(PartialView("_RefinancingResultsPartial", refinancingViewModelResult));
        }
コード例 #3
0
        private RefinancingCalcResultsVM GetResultsForModel(RefinancingCalcResults res)
        {
            RefinancingCalcResultsVM mRes = new RefinancingCalcResultsVM();

            mRes.CurrMonthlyInstallment = res.CurrMonthlyInstallment;
            mRes.CurrPeriod             = res.CurrPeriod;
            mRes.CurrPreTermFee         = res.CurrPreTermFee;
            mRes.CurrRate              = res.CurrRate;
            mRes.CurrTotalPaid         = res.CurrTotalPaid;
            mRes.NewMonthlyInstallment = res.NewMonthlyInstallment;
            mRes.NewPeriod             = res.NewPeriod;
            mRes.NewRate      = res.NewRate;
            mRes.NewTotalPaid = res.NewTotalPaid;

            return(mRes);
        }