Skip to content

Commit

Permalink
FINERACT-1981: EMI calculator rework
Browse files Browse the repository at this point in the history
  • Loading branch information
janez89 authored and adamsaghy committed Oct 16, 2024
1 parent d4190ed commit bb07270
Show file tree
Hide file tree
Showing 17 changed files with 1,080 additions and 1,144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,14 @@ public static BigDecimal percentageOf(final BigDecimal value, final BigDecimal p
public static BigDecimal stripTrailingZeros(final BigDecimal value) {
return value == null ? null : new BigDecimal(value.stripTrailingZeros().toPlainString());
}

/**
* @return calculates maximum of the two values considering null values
* @param notNull
* if true then null parameter is omitted, otherwise returns null
*/
public static Money max(Money first, Money second, boolean notNull) {
return notNull ? first == null ? second : second == null ? first : max(first, second, false)
: isGreaterThan(first, second) ? first : second;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,7 @@ public void initialize() throws Exception {
.recalculationRestFrequencyType(2)//
.recalculationRestFrequencyInterval(1)//
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), //
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")));//
Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcTillPreClose = loanProductsApi
.createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcTillPreclose).execute();
TestContext.INSTANCE.set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5539,7 +5539,6 @@ Feature: Loan
Scenario: Early pay-off loan with interest, TILL_PRECLOSE product
When Admin sets the business date to "01 January 2024"
When Admin creates a client with random data
When Admin set "LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_TILL_PRECLOSE" loan product "DEFAULT" transaction type to "NEXT_INSTALLMENT" future installment allocation rule
When Admin creates a fully customized loan with the following data:
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_TILL_PRECLOSE | 01 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
Expand Down Expand Up @@ -5595,7 +5594,6 @@ Feature: Loan
| 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 83.57 | false |
| 15 February 2024 | Repayment | 83.81 | 83.57 | 0.24 | 0.0 | 0.0 | 0.0 | false |
Then Loan's all installments have obligations met
When Admin set "LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_TILL_PRECLOSE" loan product "DEFAULT" transaction type to "LAST_INSTALLMENT" future installment allocation rule

Scenario: Early pay-off loan with interest, TILL_REST_FREQUENCY_DATE product
When Admin sets the business date to "01 January 2024"
Expand Down Expand Up @@ -5756,4 +5754,4 @@ Feature: Loan
Then Loan term variations has 2 variation, with the following data:
| Term Type Id | Term Type Code | Term Type Value | Applicable From | Decimal Value | Date Value | Is Specific To Installment | Is Processed |
| 1 | loanTermType.emiAmount | emiAmount | 01 January 2023 | 50.0 | | false | |
| 4 | loanTermType.dueDate | dueDate | 01 February 2023 | 50.0 | 15 January 2023 | false | |
| 4 | loanTermType.dueDate | dueDate | 01 February 2023 | 50.0 | 15 January 2023 | false | |
Loading

0 comments on commit bb07270

Please sign in to comment.