Skip to content

Commit 47e8674

Browse files
Jose Alberto Hernandezadamsaghy
authored andcommitted
FINERACT-2405: totalUnpaidPayableNotDueInterest resets to 0 on Charge-Off
1 parent 2681ee3 commit 47e8674

File tree

7 files changed

+177
-4
lines changed

7 files changed

+177
-4
lines changed

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public enum DefaultLoanProduct implements LoanProduct {
177177
LP2_ADV_CUSTOM_PMT_ALLOC_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_RECALC_ZERO_CHARGE_OFF_ACCRUAL, //
178178
LP1_INTEREST_FLAT_DAILY_RECALCULATION_SAR_MULTIDISB_EXPECT_TRANCHES, //
179179
LP1_INTEREST_FLAT_DAILY_ACTUAL_ACTUAL_MULTIDISB_EXPECT_TRANCHES, //
180+
LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY, //
180181
;
181182

182183
@Override

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,14 @@ public static String wrongAmountInTotalUnpaidPayableDueInterest(Double actual, D
403403
actualToStr, expectedToStr);
404404
}
405405

406+
public static String wrongAmountInTotalUnpaidPayableNotDueInterest(Double actual, Double expected) {
407+
String actualToStr = actual.toString();
408+
String expectedToStr = expected.toString();
409+
return String.format(
410+
"Wrong amount in Loan total unpaid payable not due interest. Actual amount is: %s - But expected amount is: %s",
411+
actualToStr, expectedToStr);
412+
}
413+
406414
public static String wrongAmountInTotalOverdue(Double actual, Double expected) {
407415
String actualToStr = actual.toString();
408416
String expectedToStr = expected.toString();

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4172,10 +4172,9 @@ public void initialize() throws Exception {
41724172

41734173
// LP2 advanced + progressive loan schedule + horizontal + interest recalculation
41744174
// Frequency for recalculate Outstanding Principal: Daily, Frequency Interval for recalculation: 1
4175-
String name150 = DefaultLoanProduct.LP2_ADV_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_RECALC_ZERO_CHARGE_OF_ACCRUAL.getName();
41764175
PostLoanProductsRequest loanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffChargebackAccruals = loanProductsRequestFactory
41774176
.defaultLoanProductsRequestLP2Emi()//
4178-
.name(name150)//
4177+
.name(DefaultLoanProduct.LP2_ADV_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_RECALC_ZERO_CHARGE_OF_ACCRUAL.getName())//
41794178
.supportedInterestRefundTypes(supportedInterestRefundTypes).installmentAmountInMultiplesOf(null) //
41804179
.daysInYearType(DaysInYearType.ACTUAL.value)//
41814180
.daysInMonthType(DaysInMonthType.ACTUAL.value)//
@@ -4218,6 +4217,23 @@ public void initialize() throws Exception {
42184217
TestContext.INSTANCE.set(TestContextKey.LP1_INTEREST_FLAT_DAILY_RECALCULATION_SAR_MULTIDISB_EXPECT_TRANCHES,
42194218
responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementExpectsTranches);
42204219

4220+
// LP2 + zero-interest chargeOff behaviour + progressive loan schedule + horizontal
4221+
// (LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY)
4222+
final PostLoanProductsRequest loanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity = loanProductsRequestFactory
4223+
.defaultLoanProductsRequestLP2Emi()//
4224+
.name(DefaultLoanProduct.LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY.getName())//
4225+
.daysInYearType(DaysInYearType.DAYS360.value)//
4226+
.daysInMonthType(DaysInMonthType.DAYS30.value)//
4227+
.paymentAllocation(List.of(//
4228+
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")))
4229+
.enableAccrualActivityPosting(true)//
4230+
.chargeOffBehaviour("ZERO_INTEREST");//
4231+
final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity = loanProductsApi
4232+
.createLoanProduct(loanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity).execute();
4233+
TestContext.INSTANCE.set(
4234+
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY,
4235+
responseLoanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity);
4236+
42214237
// LP1 with 12% Flat interest, interest period: Daily, Interest recalculation- Actual
42224238
// Multi-disbursement that expects tranches
42234239
PostLoanProductsRequest loanProductsRequestInterestFlatActualActualMultiDisbursementExpectsTranches = loanProductsRequestFactory

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6060,6 +6060,23 @@ public void checkLoanAmortizationAllocationMapping(final String nthTransactionSt
60606060
checkLoanAmortizationAllocationMappingData(resourceId, loanAmortizationAllocationResponse.body(), table);
60616061
}
60626062

6063+
@Then("Loan has {double} total unpaid payable not due interest")
6064+
public void loanTotalUnpaidPayableNotDueInterest(double totalUnpaidPayableNotDueInterestExpected) throws IOException {
6065+
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
6066+
long loanId = loanCreateResponse.body().getLoanId();
6067+
6068+
Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "repaymentSchedule", "", "").execute();
6069+
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
6070+
testContext().set(TestContextKey.LOAN_RESPONSE, loanDetailsResponse);
6071+
6072+
Double totalUnpaidPayableNotDueInterestActual = loanDetailsResponse.body().getSummary().getTotalUnpaidPayableNotDueInterest()
6073+
.doubleValue();
6074+
assertThat(totalUnpaidPayableNotDueInterestActual)
6075+
.as(ErrorMessageHelper.wrongAmountInTotalUnpaidPayableNotDueInterest(totalUnpaidPayableNotDueInterestActual,
6076+
totalUnpaidPayableNotDueInterestExpected))
6077+
.isEqualTo(totalUnpaidPayableNotDueInterestExpected);
6078+
}
6079+
60636080
private void checkLoanAmortizationAllocationMappingData(final String resourceId,
60646081
final LoanAmortizationAllocationResponse amortizationAllocationResponse, final DataTable table) {
60656082
final List<List<String>> data = table.asLists();

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,5 @@ public abstract class TestContextKey {
284284
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_CUSTOM_PMT_ALLOC_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_RECALC_ZERO_CHARGE_OFF_ACCRUAL = "loanProductCreateResponseLP2AdvancedPaymentCustomAllocationInterestDailyEmiActualInterestRecalcChargeOffAccruals";
285285
public static final String LP1_INTEREST_FLAT_DAILY_RECALCULATION_SAR_MULTIDISB_EXPECT_TRANCHES = "loanProductCreateResponseLP1InterestFlatDailyRecalculationSameAsRepaymentMultiDisbursementExpectTranches";
286286
public static final String LP1_INTEREST_FLAT_DAILY_ACTUAL_ACTUAL_MULTIDISB_EXPECT_TRANCHES = "loanProductCreateResponseLP1InterestFlatDailyActualActualMultiDisbursementExpectTranches";
287+
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY = "loanProductCreateResponseLP2AdvancedPaymentZeroInterestChargeOffBehaviourAccrualActivity";
287288
}

fineract-e2e-tests-runner/src/test/resources/features/LoanChargeOff.feature

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9949,3 +9949,130 @@ Feature: Charge-off
99499949
Then Loan Repayment schedule has the following data in Total row:
99509950
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
99519951
| 546.14 | 24.69 | 0.0 | 10.0 | 580.83 | 308.59 | 308.59 | 0.0 | 272.24 |
9952+
9953+
@TestRailId:C4153
9954+
Scenario: Verify that totalUnpaidPayableNotDueInterest doesn't get reset to 0 on the charge-off date
9955+
When Admin sets the business date to "01 May 2025"
9956+
And Admin creates a client with random data
9957+
And Admin creates a fully customized loan with the following data:
9958+
| 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 |
9959+
| LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY | 01 May 2025 | 423.38 | 12.25 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 24 | MONTHS | 1 | MONTHS | 24 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
9960+
And Admin successfully approves the loan on "01 May 2025" with "423.38" amount and expected disbursement date on "01 May 2025"
9961+
And Admin successfully disburse the loan on "01 May 2025" with "423.38" EUR transaction amount
9962+
Then Loan Repayment schedule has the following data in Total row:
9963+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
9964+
| 423.38 | 56.13 | 0.0 | 0.0 | 479.51 | 0.0 | 0.0 | 0.0 | 479.51 |
9965+
Then Loan Transactions tab has the following data:
9966+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
9967+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
9968+
When Admin sets the business date to "01 June 2025"
9969+
When Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on "01 June 2025" with 19.98 EUR transaction amount and system-generated Idempotency key
9970+
Then Loan Repayment schedule has the following data in Total row:
9971+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
9972+
| 423.38 | 56.13 | 0.0 | 0.0 | 479.51 | 19.98 | 0.0 | 0.0 | 459.53 |
9973+
Then Loan Transactions tab has the following data:
9974+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
9975+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
9976+
| 01 June 2025 | Repayment | 19.98 | 15.66 | 4.32 | 0.0 | 0.0 | 407.72 |
9977+
When Admin sets the business date to "01 July 2025"
9978+
When Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on "01 July 2025" with 19.98 EUR transaction amount and system-generated Idempotency key
9979+
Then Loan Repayment schedule has the following data in Total row:
9980+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
9981+
| 423.38 | 56.13 | 0.0 | 0.0 | 479.51 | 39.96 | 0.0 | 0.0 | 439.55 |
9982+
Then Loan Transactions tab has the following data:
9983+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
9984+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
9985+
| 01 June 2025 | Repayment | 19.98 | 15.66 | 4.32 | 0.0 | 0.0 | 407.72 |
9986+
| 01 July 2025 | Repayment | 19.98 | 15.82 | 4.16 | 0.0 | 0.0 | 391.9 |
9987+
When Admin sets the business date to "08 October 2025"
9988+
When Admin runs inline COB job for Loan
9989+
Then Loan has 11.51 total unpaid payable due interest
9990+
Then Loan has 0.79 total unpaid payable not due interest
9991+
Then Loan Repayment schedule has the following data in Total row:
9992+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
9993+
| 423.38 | 56.13 | 0.0 | 0.0 | 479.51 | 39.96 | 0.0 | 0.0 | 439.55 |
9994+
Then Loan Transactions tab has the following data:
9995+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
9996+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
9997+
| 01 June 2025 | Repayment | 19.98 | 15.66 | 4.32 | 0.0 | 0.0 | 407.72 |
9998+
| 01 June 2025 | Accrual Activity | 4.32 | 0.0 | 4.32 | 0.0 | 0.0 | 0.0 |
9999+
| 01 July 2025 | Repayment | 19.98 | 15.82 | 4.16 | 0.0 | 0.0 | 391.9 |
10000+
| 01 July 2025 | Accrual Activity | 4.16 | 0.0 | 4.16 | 0.0 | 0.0 | 0.0 |
10001+
| 01 August 2025 | Accrual Activity | 4.0 | 0.0 | 4.0 | 0.0 | 0.0 | 0.0 |
10002+
| 01 September 2025 | Accrual Activity | 3.84 | 0.0 | 3.84 | 0.0 | 0.0 | 0.0 |
10003+
| 01 October 2025 | Accrual Activity | 3.67 | 0.0 | 3.67 | 0.0 | 0.0 | 0.0 |
10004+
| 07 October 2025 | Accrual | 20.67 | 0.0 | 20.67 | 0.0 | 0.0 | 0.0 |
10005+
And Admin does charge-off the loan on "08 October 2025"
10006+
Then Loan has 11.51 total unpaid payable due interest
10007+
Then Loan has 0.79 total unpaid payable not due interest
10008+
Then Loan Repayment schedule has the following data in Total row:
10009+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
10010+
| 423.38 | 20.78 | 0.0 | 0.0 | 444.16 | 39.96 | 0.0 | 0.0 | 404.2 |
10011+
Then Loan Transactions tab has the following data:
10012+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
10013+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
10014+
| 01 June 2025 | Repayment | 19.98 | 15.66 | 4.32 | 0.0 | 0.0 | 407.72 |
10015+
| 01 June 2025 | Accrual Activity | 4.32 | 0.0 | 4.32 | 0.0 | 0.0 | 0.0 |
10016+
| 01 July 2025 | Repayment | 19.98 | 15.82 | 4.16 | 0.0 | 0.0 | 391.9 |
10017+
| 01 July 2025 | Accrual Activity | 4.16 | 0.0 | 4.16 | 0.0 | 0.0 | 0.0 |
10018+
| 01 August 2025 | Accrual Activity | 4.0 | 0.0 | 4.0 | 0.0 | 0.0 | 0.0 |
10019+
| 01 September 2025 | Accrual Activity | 3.84 | 0.0 | 3.84 | 0.0 | 0.0 | 0.0 |
10020+
| 01 October 2025 | Accrual Activity | 3.67 | 0.0 | 3.67 | 0.0 | 0.0 | 0.0 |
10021+
| 07 October 2025 | Accrual | 20.67 | 0.0 | 20.67 | 0.0 | 0.0 | 0.0 |
10022+
| 08 October 2025 | Accrual | 0.11 | 0.0 | 0.11 | 0.0 | 0.0 | 0.0 |
10023+
| 08 October 2025 | Charge-off | 404.2 | 391.9 | 12.3 | 0.0 | 0.0 | 0.0 |
10024+
10025+
@TestRailId:C4228
10026+
Scenario: Verify that totalUnpaidPayableNotDueInterest is correct when charge-off falls on a due date of an open repayment period
10027+
When Admin sets the business date to "01 May 2025"
10028+
And Admin creates a client with random data
10029+
And Admin creates a fully customized loan with the following data:
10030+
| 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 |
10031+
| LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY | 01 May 2025 | 423.38 | 12.25 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 24 | MONTHS | 1 | MONTHS | 24 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
10032+
And Admin successfully approves the loan on "01 May 2025" with "423.38" amount and expected disbursement date on "01 May 2025"
10033+
And Admin successfully disburse the loan on "01 May 2025" with "423.38" EUR transaction amount
10034+
Then Loan Repayment schedule has the following data in Total row:
10035+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
10036+
| 423.38 | 56.13 | 0.0 | 0.0 | 479.51 | 0.0 | 0.0 | 0.0 | 479.51 |
10037+
Then Loan Transactions tab has the following data:
10038+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
10039+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
10040+
When Admin sets the business date to "01 June 2025"
10041+
When Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on "01 June 2025" with 19.98 EUR transaction amount and system-generated Idempotency key
10042+
Then Loan Repayment schedule has the following data in Total row:
10043+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
10044+
| 423.38 | 56.13 | 0.0 | 0.0 | 479.51 | 19.98 | 0.0 | 0.0 | 459.53 |
10045+
Then Loan Transactions tab has the following data:
10046+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
10047+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
10048+
| 01 June 2025 | Repayment | 19.98 | 15.66 | 4.32 | 0.0 | 0.0 | 407.72 |
10049+
When Admin sets the business date to "01 July 2025"
10050+
When Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on "01 July 2025" with 19.98 EUR transaction amount and system-generated Idempotency key
10051+
Then Loan Repayment schedule has the following data in Total row:
10052+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
10053+
| 423.38 | 56.13 | 0.0 | 0.0 | 479.51 | 39.96 | 0.0 | 0.0 | 439.55 |
10054+
Then Loan Transactions tab has the following data:
10055+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
10056+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
10057+
| 01 June 2025 | Repayment | 19.98 | 15.66 | 4.32 | 0.0 | 0.0 | 407.72 |
10058+
| 01 July 2025 | Repayment | 19.98 | 15.82 | 4.16 | 0.0 | 0.0 | 391.9 |
10059+
When Admin sets the business date to "01 October 2025"
10060+
When Admin runs inline COB job for Loan
10061+
Then Loan has 11.51 total unpaid payable due interest
10062+
Then Loan has 0.0 total unpaid payable not due interest
10063+
Then Loan Repayment schedule has the following data in Total row:
10064+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
10065+
| 423.38 | 56.13 | 0.0 | 0.0 | 479.51 | 39.96 | 0.0 | 0.0 | 439.55 |
10066+
Then Loan Transactions tab has the following data:
10067+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
10068+
| 01 May 2025 | Disbursement | 423.38 | 0.0 | 0.0 | 0.0 | 0.0 | 423.38 |
10069+
| 01 June 2025 | Repayment | 19.98 | 15.66 | 4.32 | 0.0 | 0.0 | 407.72 |
10070+
| 01 June 2025 | Accrual Activity | 4.32 | 0.0 | 4.32 | 0.0 | 0.0 | 0.0 |
10071+
| 01 July 2025 | Repayment | 19.98 | 15.82 | 4.16 | 0.0 | 0.0 | 391.9 |
10072+
| 01 July 2025 | Accrual Activity | 4.16 | 0.0 | 4.16 | 0.0 | 0.0 | 0.0 |
10073+
| 01 August 2025 | Accrual Activity | 4.0 | 0.0 | 4.0 | 0.0 | 0.0 | 0.0 |
10074+
| 01 September 2025 | Accrual Activity | 3.84 | 0.0 | 3.84 | 0.0 | 0.0 | 0.0 |
10075+
| 30 September 2025 | Accrual | 19.87 | 0.0 | 19.87 | 0.0 | 0.0 | 0.0 |
10076+
And Admin does charge-off the loan on "01 October 2025"
10077+
Then Loan has 11.51 total unpaid payable due interest
10078+
Then Loan has 0.0 total unpaid payable not due interest

0 commit comments

Comments
 (0)