Skip to content

Commit e959bbc

Browse files
committed
FINERACT-2229: Fix incorrect repayment schedule in case of Merchant issued refund
1 parent a313608 commit e959bbc

File tree

6 files changed

+156
-72
lines changed

6 files changed

+156
-72
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,8 @@ public void initialize() throws Exception {
891891
PostLoanProductsRequest loanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedule = loanProductsRequestFactory
892892
.defaultLoanProductsRequestLP2InterestDailyRecalculation()//
893893
.name(name44)//
894+
.supportedInterestRefundTypes(Arrays.asList("MERCHANT_ISSUED_REFUND", "PAYOUT_REFUND"))//
895+
.enableAccrualActivityPosting(true) //
894896
.paymentAllocation(List.of(//
895897
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT",
896898
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_INTEREST, //
@@ -905,8 +907,8 @@ public void initialize() throws Exception {
905907
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL, //
906908
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PENALTY, //
907909
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE), //
908-
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
909-
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
910+
createPaymentAllocation("GOODWILL_CREDIT", "REAMORTIZATION"), //
911+
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "LAST_INSTALLMENT"), //
910912
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
911913
Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedule = loanProductsApi
912914
.createLoanProduct(loanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedule).execute();

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

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6442,3 +6442,86 @@ Feature: Loan
64426442
| 11 March 2025 | Merchant Issued Refund | 200.0 | 200.0 | 0.0 | 0.0 | 0.0 | 0.0 |
64436443
| 11 March 2025 | Disbursement | 200.0 | 0.0 | 0.0 | 0.0 | 0.0 | 200.0 |
64446444
When Admin set "LP2_DOWNPAYMENT_AUTO_ADVANCED_PAYMENT_ALLOCATION" loan product "MERCHANT_ISSUED_REFUND" transaction type to "NEXT_INSTALLMENT" future installment allocation rule
6445+
6446+
@TestRailId:C3570
6447+
Scenario: Verify Loan is fully paid and closed after full Merchant issued refund 1 day after disbursement
6448+
When Admin sets the business date to "29 March 2025"
6449+
When Admin creates a client with random data
6450+
When Admin creates a fully customized loan with the following data:
6451+
| 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 |
6452+
| LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL | 28 March 2025 | 1383 | 12.23 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 24 | MONTHS | 1 | MONTHS | 24 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
6453+
And Admin successfully approves the loan on "28 March 2025" with "1383" amount and expected disbursement date on "28 March 2025"
6454+
When Admin successfully disburse the loan on "28 March 2025" with "1383" EUR transaction amount
6455+
Then Loan Repayment schedule has 24 periods, with the following data for periods:
6456+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
6457+
| | | 28 March 2025 | | 1383.0 | | | 0.0 | | 0.0 | 0.0 | | | |
6458+
| 1 | 31 | 28 April 2025 | | 1331.85 | 51.15 | 14.1 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6459+
| 2 | 30 | 28 May 2025 | | 1280.17 | 51.68 | 13.57 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6460+
| 3 | 31 | 28 June 2025 | | 1227.97 | 52.2 | 13.05 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6461+
| 4 | 30 | 28 July 2025 | | 1175.24 | 52.73 | 12.52 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6462+
| 5 | 31 | 28 August 2025 | | 1121.97 | 53.27 | 11.98 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6463+
| 6 | 31 | 28 September 2025 | | 1068.15 | 53.82 | 11.43 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6464+
| 7 | 30 | 28 October 2025 | | 1013.79 | 54.36 | 10.89 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6465+
| 8 | 31 | 28 November 2025 | | 958.87 | 54.92 | 10.33 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6466+
| 9 | 30 | 28 December 2025 | | 903.39 | 55.48 | 9.77 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6467+
| 10 | 31 | 28 January 2026 | | 847.35 | 56.04 | 9.21 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6468+
| 11 | 31 | 28 February 2026 | | 790.74 | 56.61 | 8.64 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6469+
| 12 | 28 | 28 March 2026 | | 733.55 | 57.19 | 8.06 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6470+
| 13 | 31 | 28 April 2026 | | 675.78 | 57.77 | 7.48 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6471+
| 14 | 30 | 28 May 2026 | | 617.42 | 58.36 | 6.89 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6472+
| 15 | 31 | 28 June 2026 | | 558.46 | 58.96 | 6.29 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6473+
| 16 | 30 | 28 July 2026 | | 498.9 | 59.56 | 5.69 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6474+
| 17 | 31 | 28 August 2026 | | 438.73 | 60.17 | 5.08 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6475+
| 18 | 31 | 28 September 2026 | | 377.95 | 60.78 | 4.47 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6476+
| 19 | 30 | 28 October 2026 | | 316.55 | 61.4 | 3.85 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6477+
| 20 | 31 | 28 November 2026 | | 254.53 | 62.02 | 3.23 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6478+
| 21 | 30 | 28 December 2026 | | 191.87 | 62.66 | 2.59 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6479+
| 22 | 31 | 28 January 2027 | | 128.58 | 63.29 | 1.96 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6480+
| 23 | 31 | 28 February 2027 | | 64.64 | 63.94 | 1.31 | 0.0 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 |
6481+
| 24 | 28 | 28 March 2027 | | 0.0 | 64.64 | 0.66 | 0.0 | 0.0 | 65.3 | 0.0 | 0.0 | 0.0 | 65.3 |
6482+
Then Loan Repayment schedule has the following data in Total row:
6483+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
6484+
| 1383.0 | 183.05 | 0.0 | 0.0 | 1566.05 | 0.0 | 0.0 | 0.0 | 1566.05 |
6485+
Then Loan Transactions tab has the following data:
6486+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
6487+
| 28 March 2025 | Disbursement | 1383.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1383.0 | false | false |
6488+
And Customer makes "MERCHANT_ISSUED_REFUND" transaction with "AUTOPAY" payment type on "29 March 2025" with 1383 EUR transaction amount and self-generated Idempotency key
6489+
Then Loan Repayment schedule has 24 periods, with the following data for periods:
6490+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
6491+
| | | 28 March 2025 | | 1383.0 | | | 0.0 | | 0.0 | 0.0 | | | |
6492+
| 1 | 31 | 28 April 2025 | 29 March 2025 | 1383.0 | 0.0 | 0.45 | 0.0 | 0.0 | 0.45 | 0.45 | 0.45 | 0.0 | 0.0 |
6493+
| 2 | 30 | 28 May 2025 | 29 March 2025 | 1383.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
6494+
| 3 | 31 | 28 June 2025 | 29 March 2025 | 1370.25 | 12.75 | 0.0 | 0.0 | 0.0 | 12.75 | 12.75 | 12.75 | 0.0 | 0.0 |
6495+
| 4 | 30 | 28 July 2025 | 29 March 2025 | 1305.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6496+
| 5 | 31 | 28 August 2025 | 29 March 2025 | 1239.75 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6497+
| 6 | 31 | 28 September 2025 | 29 March 2025 | 1174.5 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6498+
| 7 | 30 | 28 October 2025 | 29 March 2025 | 1109.25 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6499+
| 8 | 31 | 28 November 2025 | 29 March 2025 | 1044.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6500+
| 9 | 30 | 28 December 2025 | 29 March 2025 | 978.75 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6501+
| 10 | 31 | 28 January 2026 | 29 March 2025 | 913.5 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6502+
| 11 | 31 | 28 February 2026 | 29 March 2025 | 848.25 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6503+
| 12 | 28 | 28 March 2026 | 29 March 2025 | 783.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6504+
| 13 | 31 | 28 April 2026 | 29 March 2025 | 717.75 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6505+
| 14 | 30 | 28 May 2026 | 29 March 2025 | 652.5 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6506+
| 15 | 31 | 28 June 2026 | 29 March 2025 | 587.25 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6507+
| 16 | 30 | 28 July 2026 | 29 March 2025 | 522.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6508+
| 17 | 31 | 28 August 2026 | 29 March 2025 | 456.75 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6509+
| 18 | 31 | 28 September 2026 | 29 March 2025 | 391.5 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6510+
| 19 | 30 | 28 October 2026 | 29 March 2025 | 326.25 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6511+
| 20 | 31 | 28 November 2026 | 29 March 2025 | 261.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6512+
| 21 | 30 | 28 December 2026 | 29 March 2025 | 195.75 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6513+
| 22 | 31 | 28 January 2027 | 29 March 2025 | 130.5 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6514+
| 23 | 31 | 28 February 2027 | 29 March 2025 | 65.25 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6515+
| 24 | 28 | 28 March 2027 | 29 March 2025 | 0.0 | 65.25 | 0.0 | 0.0 | 0.0 | 65.25 | 65.25 | 65.25 | 0.0 | 0.0 |
6516+
Then Loan Repayment schedule has the following data in Total row:
6517+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
6518+
| 1383.0 | 0.45 | 0.0 | 0.0 | 1383.45 | 1383.45 | 1383.45 | 0.0 | 0.0 |
6519+
Then Loan Transactions tab has the following data:
6520+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
6521+
| 28 March 2025 | Disbursement | 1383.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1383.0 | false | false |
6522+
| 29 March 2025 | Merchant Issued Refund | 1383.0 | 1383.0 | 0.0 | 0.0 | 0.0 | 0.0 | false | false |
6523+
| 29 March 2025 | Interest Refund | 0.45 | 0.0 | 0.45 | 0.0 | 0.0 | 0.0 | false | false |
6524+
| 29 March 2025 | Accrual Activity | 0.45 | 0.0 | 0.45 | 0.0 | 0.0 | 0.0 | false | false |
6525+
| 29 March 2025 | Accrual | 0.45 | 0.0 | 0.45 | 0.0 | 0.0 | 0.0 | false | false |
6526+
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
6527+
Then Loan has 0 outstanding amount

0 commit comments

Comments
 (0)