Skip to content

Commit 4e7ac7d

Browse files
FINERACT-2354: Fifth step - Partially paid installment - adjust to last edge case of re-aging for Interest bearing loans - Default Behavior, interestRecalculation = true, without dueDate change
1 parent 9a16a26 commit 4e7ac7d

File tree

21 files changed

+399
-100
lines changed

21 files changed

+399
-100
lines changed

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

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,6 +4058,7 @@ Feature: LoanReAging
40584058
| 01 February 2024 | Chargeback | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 100.0 | false | false |
40594059
| 15 March 2024 | Re-age | 101.42 | 100.0 | 1.42 | 0.0 | 0.0 | 0.0 | false | false |
40604060
| 15 March 2024 | Repayment | 101.42 | 100.0 | 1.42 | 0.0 | 0.0 | 0.0 | false | false |
4061+
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
40614062

40624063
@TestRailId:C4135 @AdvancedPaymentAllocation
40634064
Scenario: Verify allowing Re-aging on interest bearing loan - Interest calculation: Default Behavior - Charge-back before re-aging and installment is partially paid - UC3.1
@@ -4154,6 +4155,7 @@ Feature: LoanReAging
41544155
| 01 March 2024 | Repayment | 10.0 | 10.0 | 0.0 | 0.0 | 0.0 | 90.0 | false | false |
41554156
| 15 March 2024 | Re-age | 91.4 | 90.0 | 1.4 | 0.0 | 0.0 | 0.0 | false | false |
41564157
| 15 March 2024 | Repayment | 91.4 | 90.0 | 1.4 | 0.0 | 0.0 | 0.0 | false | false |
4158+
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
41574159

41584160
@TestRailId:C4083 @AdvancedPaymentAllocation
41594161
Scenario: Verify allowing Re-aging on interest bearing loan - Interest calculation: Default Behavior - N+1 Scenario - UC4
@@ -4317,6 +4319,100 @@ Feature: LoanReAging
43174319
When Loan Pay-off is made on "15 March 2024"
43184320
Then Loan is closed with zero outstanding balance and it's all installments have obligations met
43194321

4322+
Scenario: Verify allowing Re-aging on interest bearing loan - Interest calculation: Default Behavior - with LAST_INSTALLMENT allocation rule and partial repayment - UC5.1
4323+
When Admin sets the business date to "01 January 2024"
4324+
When Admin creates a client with random data
4325+
When Admin set "LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL" loan product "DEFAULT" transaction type to "LAST_INSTALLMENT" future installment allocation rule
4326+
When Admin creates a fully customized loan with the following data:
4327+
| 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 |
4328+
| LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL | 01 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
4329+
And Admin successfully approves the loan on "01 January 2024" with "100" amount and expected disbursement date on "01 January 2024"
4330+
When Admin successfully disburse the loan on "01 January 2024" with "100" EUR transaction amount
4331+
Then Loan Repayment schedule has 6 periods, with the following data for periods:
4332+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4333+
| | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
4334+
| 1 | 31 | 01 February 2024 | | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4335+
| 2 | 29 | 01 March 2024 | | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4336+
| 3 | 31 | 01 April 2024 | | 50.43 | 16.62 | 0.39 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4337+
| 4 | 30 | 01 May 2024 | | 33.71 | 16.72 | 0.29 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4338+
| 5 | 31 | 01 June 2024 | | 16.9 | 16.81 | 0.2 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4339+
| 6 | 30 | 01 July 2024 | | 0.0 | 16.9 | 0.1 | 0.0 | 0.0 | 17.0 | 0.0 | 0.0 | 0.0 | 17.0 |
4340+
Then Loan Repayment schedule has the following data in Total row:
4341+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4342+
| 100.0 | 2.05 | 0.0 | 0.0 | 102.05 | 0.0 | 0.0 | 0.0 | 102.05 |
4343+
Then Loan Transactions tab has the following data:
4344+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
4345+
| 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false |
4346+
When Admin sets the business date to "01 February 2024"
4347+
And Customer makes "AUTOPAY" repayment on "01 February 2024" with 25.0 EUR transaction amount
4348+
Then Loan Repayment schedule has 6 periods, with the following data for periods:
4349+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4350+
| | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
4351+
| 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 |
4352+
| 2 | 29 | 01 March 2024 | | 67.0 | 16.57 | 0.44 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4353+
| 3 | 31 | 01 April 2024 | | 50.33 | 16.67 | 0.34 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4354+
| 4 | 30 | 01 May 2024 | | 33.57 | 16.76 | 0.25 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4355+
| 5 | 31 | 01 June 2024 | | 16.71 | 16.86 | 0.15 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 |
4356+
| 6 | 30 | 01 July 2024 | | 0.0 | 16.71 | 0.05 | 0.0 | 0.0 | 16.76 | 7.99 | 7.99 | 0.0 | 8.77 |
4357+
Then Loan Repayment schedule has the following data in Total row:
4358+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4359+
| 100.0 | 1.81 | 0.0 | 0.0 | 101.81 | 25.0 | 7.99 | 0.0 | 76.81 |
4360+
Then Loan Transactions tab has the following data:
4361+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
4362+
| 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false |
4363+
| 01 February 2024 | Repayment | 25.0 | 24.42 | 0.58 | 0.0 | 0.0 | 75.58 | false |
4364+
When Admin sets the business date to "15 March 2024"
4365+
When Admin creates a Loan re-aging transaction with the following data:
4366+
| frequencyNumber | frequencyType | startDate | numberOfInstallments |
4367+
| 1 | MONTHS | 01 April 2024| 6 |
4368+
Then Loan Repayment schedule has 9 periods, with the following data for periods:
4369+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4370+
| | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
4371+
| 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 |
4372+
| 2 | 29 | 01 March 2024 | 15 March 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
4373+
| 3 | 0 | 01 April 2024 | 15 March 2024 | 75.58 | 7.99 | 0.0 | 0.0 | 0.0 | 7.99 | 7.99 | 7.99 | 0.0 | 0.0 |
4374+
| 4 | 31 | 01 April 2024 | | 63.53 | 12.05 | 0.88 | 0.0 | 0.0 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 |
4375+
| 5 | 30 | 01 May 2024 | | 50.97 | 12.56 | 0.37 | 0.0 | 0.0 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 |
4376+
| 6 | 31 | 01 June 2024 | | 38.34 | 12.63 | 0.3 | 0.0 | 0.0 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 |
4377+
| 7 | 30 | 01 July 2024 | | 25.63 | 12.71 | 0.22 | 0.0 | 0.0 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 |
4378+
| 8 | 31 | 01 August 2024 | | 12.85 | 12.78 | 0.15 | 0.0 | 0.0 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 |
4379+
| 9 | 31 | 01 September 2024| | 0.0 | 12.85 | 0.07 | 0.0 | 0.0 | 12.92 | 0.0 | 0.0 | 0.0 | 12.92 |
4380+
Then Loan Repayment schedule has the following data in Total row:
4381+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4382+
| 100.0 | 2.57 | 0.0 | 0.0 | 102.57 | 25.0 | 7.99 | 0.0 | 77.57 |
4383+
Then Loan Transactions tab has the following data:
4384+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
4385+
| 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false |
4386+
| 01 February 2024 | Repayment | 25.0 | 24.42 | 0.58 | 0.0 | 0.0 | 75.58 | false | false |
4387+
| 15 March 2024 | Re-age | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
4388+
When Loan Pay-off is made on "15 March 2024"
4389+
Then Loan is closed with zero outstanding balance and it's all installments have obligations met
4390+
Then Loan Repayment schedule has 9 periods, with the following data for periods:
4391+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4392+
| | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
4393+
| 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 |
4394+
| 2 | 29 | 01 March 2024 | 15 March 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
4395+
| 3 | 0 | 01 April 2024 | 15 March 2024 | 75.58 | 7.99 | 0.0 | 0.0 | 0.0 | 7.99 | 7.99 | 7.99 | 0.0 | 0.0 |
4396+
| 4 | 31 | 01 April 2024 | 15 March 2024 | 64.64 | 10.94 | 0.64 | 0.0 | 0.0 | 11.58 | 11.58 | 11.58 | 0.0 | 0.0 |
4397+
| 5 | 30 | 01 May 2024 | 15 March 2024 | 51.71 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 | 12.93 | 12.93 | 0.0 | 0.0 |
4398+
| 6 | 31 | 01 June 2024 | 15 March 2024 | 38.78 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 | 12.93 | 12.93 | 0.0 | 0.0 |
4399+
| 7 | 30 | 01 July 2024 | 15 March 2024 | 25.85 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 | 12.93 | 12.93 | 0.0 | 0.0 |
4400+
| 8 | 31 | 01 August 2024 | 15 March 2024 | 12.92 | 12.93 | 0.0 | 0.0 | 0.0 | 12.93 | 12.93 | 12.93 | 0.0 | 0.0 |
4401+
| 9 | 31 | 01 September 2024| 15 March 2024 | 0.0 | 12.92 | 0.0 | 0.0 | 0.0 | 12.92 | 12.92 | 12.92 | 0.0 | 0.0 |
4402+
Then Loan Repayment schedule has the following data in Total row:
4403+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
4404+
| 100.0 | 1.22 | 0.0 | 0.0 | 101.22 | 101.22 | 84.21 | 0.0 | 0.0 |
4405+
Then Loan Transactions tab has the following data:
4406+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
4407+
| 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false |
4408+
| 01 February 2024 | Repayment | 25.0 | 24.42 | 0.58 | 0.0 | 0.0 | 75.58 | false | false |
4409+
| 01 February 2024 | Accrual Activity | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
4410+
| 15 March 2024 | Re-age | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
4411+
| 15 March 2024 | Repayment | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
4412+
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
4413+
| 15 March 2024 | Accrual Activity | 0.64 | 0.0 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
4414+
When Admin set "LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL" loan product "DEFAULT" transaction type to "NEXT_INSTALLMENT" future installment allocation rule
4415+
43204416
@TestRailId:C4085 @AdvancedPaymentAllocation
43214417
Scenario: Verify allowing Re-aging on interest bearing loan - Interest calculation: Default Behavior - Chargeback after re-aging - UC6
43224418
When Admin sets the business date to "01 January 2024"

fineract-loan/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyReadPlatformServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ private LocalDate getEarliestUnpaidInstallmentDate(final Loan loan) {
325325
}
326326

327327
private LocalDate getNextUnpaidInstallmentDueDate(final Loan loan) {
328-
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
328+
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments().stream()
329+
.filter(i -> !i.isReAgeSpecialInstallment()).toList();
329330
LocalDate currentBusinessDate = DateUtils.getBusinessLocalDate();
330331
LocalDate expectedMaturityDate = loan.determineExpectedMaturityDate();
331332
LocalDate nextUnpaidInstallmentDate = expectedMaturityDate;

fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ public List<Long> fetchDisbursementIds() {
744744

745745
public LocalDate determineExpectedMaturityDate() {
746746
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments().stream()
747-
.filter(i -> !i.isDownPayment() && !i.isAdditional()).toList();
747+
.filter(i -> !i.isDownPayment() && !i.isAdditional() && !i.isReAgeSpecialInstallment()).toList();
748748
final int numberOfInstallments = installments.size();
749749
LocalDate maturityDate = installments.get(numberOfInstallments - 1).getDueDate();
750750
ListIterator<LoanRepaymentScheduleInstallment> iterator = installments.listIterator(numberOfInstallments);
@@ -1558,7 +1558,7 @@ public int fetchNumberOfInstallmentsAfterExceptions() {
15581558
int numberOfInstallments = 0;
15591559
for (final LoanRepaymentScheduleInstallment installment : installments) {
15601560
if (!installment.isRecalculatedInterestComponent() && !installment.isAdditional() && !installment.isDownPayment()
1561-
&& !installment.isReAged()) {
1561+
&& !installment.isReAged() && !installment.isReAgeSpecialInstallment()) {
15621562
numberOfInstallments++;
15631563
}
15641564
}

0 commit comments

Comments
 (0)