public void GetMonthlyInstallmentShouldWorkCorrectly()
        {
            //Arrange
            var parameters = new CalculateMonthlyInstallmentParameters
            {
                MaturityInMonths         = 36,
                InterestRateAsPercentage = 1.5,
                LoanAmount  = 48000,
                ProductType = ProductType.PersonalLoan
            };

            //Act
            var sut = MonthlyInstallment.Get(parameters);

            //Assert
            sut.MonthlyInstallment.Should().NotBe(0);
        }
        public void WhenMaturityIsZero_GetMonthlyInstallmentShouldReturnEmptyReturnDto()
        {
            //Arrange
            var parameters = new CalculateMonthlyInstallmentParameters
            {
                MaturityInMonths         = 0,
                InterestRateAsPercentage = 1.5,
                LoanAmount  = 48000,
                ProductType = ProductType.PersonalLoan
            };

            //Act
            var sut = MonthlyInstallment.Get(parameters);

            //Assert
            sut.MonthlyInstallment.Should().Be(0);
        }
        public static CalculateMonthlyInstallmentReturnValues Get(CalculateMonthlyInstallmentParameters parameters)
        {
            var totalTaxRatio = TotalTaxRatio.Get(parameters.ProductType);

            if (parameters.MaturityInMonths == 0)
            {
                return(new CalculateMonthlyInstallmentReturnValues());
            }

            return(new CalculateMonthlyInstallmentReturnValues
            {
                MonthlyInstallment = -new Pmt().PaymentInternal(parameters.InterestRateAsPercentage / 100 * (1 + totalTaxRatio),
                                                                parameters.MaturityInMonths,
                                                                parameters.LoanAmount,
                                                                0,
                                                                DueDate.EndOfPeriod)
            });
        }