@Test public void shouldCalculateLoanInterestWithPrincipalOnlyGrace() { LoanInterestCalculationDetails loanInterestCalculationDetails = new LoanInterestCalculationDetailsBuilder().withLoanAmount("100.0") .withInterestRate("10.0") .withDurationInYears("1.0") .withGraceType(GraceType.PRINCIPALONLYGRACE) .withGraceDurationOf(0) .withNumberOfInstallments(6) .withInterestFractionalRatePerInstallmentOf("0.16") .build(); Money calculatedInterest = decliningBalanceWithEqualPrincipalInstallmentsLoanInterestCalculator.calculate(loanInterestCalculationDetails); assertThat(moneyOf(calculatedInterest), is(moneyOf(TestMoneyUtil.createMoney("56.0")))); }
@Override public Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails) { Money loanAmount = loanInterestCalculationDetails.getLoanAmount(); GraceType graceType = loanInterestCalculationDetails.getGraceType(); Integer gracePeriodDuration = loanInterestCalculationDetails.getGracePeriodDuration(); Integer numberOfInstallments = loanInterestCalculationDetails.getNumberOfInstallments(); Double interestFractionalRatePerInstallment = loanInterestCalculationDetails.getInterestFractionalRatePerInstallment(); return getDecliningEPIAmount_v2(graceType, gracePeriodDuration, numberOfInstallments, loanAmount, interestFractionalRatePerInstallment); }
DecliningBalanceWithEqualPrincipalInstallmentsLoanInterestCalculator implements LoanInterestCalculator { @Override public Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails) { Money loanAmount = loanInterestCalculationDetails.getLoanAmount(); GraceType graceType = loanInterestCalculationDetails.getGraceType(); Integer gracePeriodDuration = loanInterestCalculationDetails.getGracePeriodDuration(); Integer numberOfInstallments = loanInterestCalculationDetails.getNumberOfInstallments(); Double interestFractionalRatePerInstallment = loanInterestCalculationDetails.getInterestFractionalRatePerInstallment(); return getDecliningEPIAmount_v2(graceType, gracePeriodDuration, numberOfInstallments, loanAmount, interestFractionalRatePerInstallment); } }
DecliningBalanceWithEqualPrincipalInstallmentsLoanInterestCalculator implements LoanInterestCalculator { @Override public Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails) { Money loanAmount = loanInterestCalculationDetails.getLoanAmount(); GraceType graceType = loanInterestCalculationDetails.getGraceType(); Integer gracePeriodDuration = loanInterestCalculationDetails.getGracePeriodDuration(); Integer numberOfInstallments = loanInterestCalculationDetails.getNumberOfInstallments(); Double interestFractionalRatePerInstallment = loanInterestCalculationDetails.getInterestFractionalRatePerInstallment(); return getDecliningEPIAmount_v2(graceType, gracePeriodDuration, numberOfInstallments, loanAmount, interestFractionalRatePerInstallment); }  }
DecliningBalanceWithEqualPrincipalInstallmentsLoanInterestCalculator implements LoanInterestCalculator { @Override public Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails) { Money loanAmount = loanInterestCalculationDetails.getLoanAmount(); GraceType graceType = loanInterestCalculationDetails.getGraceType(); Integer gracePeriodDuration = loanInterestCalculationDetails.getGracePeriodDuration(); Integer numberOfInstallments = loanInterestCalculationDetails.getNumberOfInstallments(); Double interestFractionalRatePerInstallment = loanInterestCalculationDetails.getInterestFractionalRatePerInstallment(); return getDecliningEPIAmount_v2(graceType, gracePeriodDuration, numberOfInstallments, loanAmount, interestFractionalRatePerInstallment); }  @Override Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails); }
DecliningBalanceWithEqualPrincipalInstallmentsLoanInterestCalculator implements LoanInterestCalculator { @Override public Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails) { Money loanAmount = loanInterestCalculationDetails.getLoanAmount(); GraceType graceType = loanInterestCalculationDetails.getGraceType(); Integer gracePeriodDuration = loanInterestCalculationDetails.getGracePeriodDuration(); Integer numberOfInstallments = loanInterestCalculationDetails.getNumberOfInstallments(); Double interestFractionalRatePerInstallment = loanInterestCalculationDetails.getInterestFractionalRatePerInstallment(); return getDecliningEPIAmount_v2(graceType, gracePeriodDuration, numberOfInstallments, loanAmount, interestFractionalRatePerInstallment); }  @Override Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails);  }