public ActionResult <GetPaymentAmountResult> GetPaymentAmount([FromBody] GetPaymentAmountInput input)
        {
            var interestRate      = new InterestRate(this.Configuration);
            var paymentCalculator = new PaymentCalculator(input, interestRate.Rate);

            return(new GetPaymentAmountResult {
                PaymentAmount = paymentCalculator.Calculate()
            });
        }
Ejemplo n.º 2
0
        public PaymentCalculator(GetPaymentAmountInput input, double interestRate)
        {
            this.AskingPrice        = input.AskingPrice;
            this.DownPayment        = input.DownPayment;
            this.PaymentSchedule    = input.PaymentSchedule;
            this.AmortizationPeriod = input.AmortizationPeriod;
            this.InterestRate       = interestRate;

            // Make sure the incoming parameters make sense
            this.Validate();
        }
Ejemplo n.º 3
0
        public void TestAnotherPaymentCalculation()
        {
            GetPaymentAmountInput testInput = new GetPaymentAmountInput
            {
                AskingPrice        = 360000.00,
                DownPayment        = 72000.00,
                PaymentSchedule    = PaymentScheduleOptions.monthly,
                AmortizationPeriod = 300
            };

            var paymentCalculator = new PaymentCalculator(testInput, 0.025);
            var paymentAmount     = paymentCalculator.Calculate();

            Assert.Equal <double>(1292.0161941406197, paymentAmount);
        }
Ejemplo n.º 4
0
        public void TestPaymentCalculation()
        {
            GetPaymentAmountInput testInput = new GetPaymentAmountInput
            {
                AskingPrice        = 750000.00,
                DownPayment        = 158000.00,
                PaymentSchedule    = PaymentScheduleOptions.monthly,
                AmortizationPeriod = 240
            };

            var paymentCalculator = new PaymentCalculator(testInput, 0.025);
            var paymentAmount     = paymentCalculator.Calculate();

            Assert.Equal <double>(3137.0251267506815, paymentAmount);
        }