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