This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 7d0474cc1 FINERACT-2162: Support chargeback for progressive loans with
disabled interest recalculation and payment allocation
7d0474cc1 is described below
commit 7d0474cc170621bc66a64cd173da8f4b29168397
Author: Oleksii Novikov <[email protected]>
AuthorDate: Tue Feb 4 18:09:30 2025 +0200
FINERACT-2162: Support chargeback for progressive loans with disabled
interest recalculation and payment allocation
---
.../test/data/loanproduct/DefaultLoanProduct.java | 2 +
.../global/LoanProductGlobalInitializerStep.java | 41 ++++
.../fineract/test/support/TestContextKey.java | 2 +
.../test/resources/features/LoanChargeback.feature | 260 +++++++++++++++++++++
.../domain/LoanRepaymentScheduleInstallment.java | 22 +-
...dvancedPaymentScheduleTransactionProcessor.java | 29 ++-
.../db/changelog/tenant/changelog-tenant.xml | 1 +
.../0165_add_credited_interest_to_instalment.xml | 32 +++
8 files changed, 374 insertions(+), 15 deletions(-)
diff --git
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java
index 3b302b38d..16861dfed 100644
---
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java
+++
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java
@@ -78,6 +78,8 @@ public enum DefaultLoanProduct implements LoanProduct {
LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR,
//
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_ACCRUAL_ACTIVITY, //
LP2_ADV_PYMNT_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR, //
+ LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST, //
+ LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST, //
;
@Override
diff --git
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
index d2ff0db38..ddda52307 100644
---
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
+++
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
@@ -1242,6 +1242,47 @@ public class LoanProductGlobalInitializerStep implements
FineractGlobalInitializ
.createLoanProduct(loanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule).execute();
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR,
responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule);
+
+ // LP2 with disabled interest recalculation + chargeback
allocation(INTEREST, PENALTY, FEE, PRINCIPAL)
+ // (LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST)
+ String name56 =
DefaultLoanProduct.LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST.getName();
+ PostLoanProductsRequest loanProductsRequestChargebackAllocation =
loanProductsRequestFactory.defaultLoanProductsRequestLP2Emi()//
+ .name(name56)//
+ .daysInYearType(DaysInYearType.DAYS360.value)//
+ .daysInMonthType(DaysInMonthType.DAYS30.value)//
+ .creditAllocation(List.of(//
+ createCreditAllocation("CHARGEBACK",
List.of("INTEREST", "PENALTY", "FEE", "PRINCIPAL"))//
+ ))//
+ .paymentAllocation(List.of(//
+ createPaymentAllocation("DEFAULT",
"NEXT_INSTALLMENT"), //
+ createPaymentAllocation("GOODWILL_CREDIT",
"LAST_INSTALLMENT"), //
+ createPaymentAllocation("MERCHANT_ISSUED_REFUND",
"REAMORTIZATION"), //
+ createPaymentAllocation("PAYOUT_REFUND",
"NEXT_INSTALLMENT")));//
+ Response<PostLoanProductsResponse>
loanProductsResponseChargebackAllocation = loanProductsApi
+
.createLoanProduct(loanProductsRequestChargebackAllocation).execute();
+
TestContext.INSTANCE.set(TestContextKey.LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST_RESPONSE,
+ loanProductsResponseChargebackAllocation);
+
+ // LP2 with disabled interest recalculation + chargeback
allocation(PRINCIPAL, INTEREST, PENALTY, FEE)
+ //
(LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST)
+ String name57 =
DefaultLoanProduct.LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST.getName();
+ PostLoanProductsRequest
loanProductsRequestChargebackAllocationPrincipalFirst =
loanProductsRequestFactory
+ .defaultLoanProductsRequestLP2Emi()//
+ .name(name57)//
+ .daysInYearType(DaysInYearType.DAYS360.value)//
+ .daysInMonthType(DaysInMonthType.DAYS30.value)//
+ .creditAllocation(List.of(//
+ createCreditAllocation("CHARGEBACK",
List.of("PRINCIPAL", "INTEREST", "PENALTY", "FEE"))//
+ ))//
+ .paymentAllocation(List.of(//
+ createPaymentAllocation("DEFAULT",
"NEXT_INSTALLMENT"), //
+ createPaymentAllocation("GOODWILL_CREDIT",
"LAST_INSTALLMENT"), //
+ createPaymentAllocation("MERCHANT_ISSUED_REFUND",
"REAMORTIZATION"), //
+ createPaymentAllocation("PAYOUT_REFUND",
"NEXT_INSTALLMENT")));//
+ Response<PostLoanProductsResponse>
loanProductsResponseChargebackAllocationPrincipalFirst = loanProductsApi
+
.createLoanProduct(loanProductsRequestChargebackAllocationPrincipalFirst).execute();
+
TestContext.INSTANCE.set(TestContextKey.LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST_RESPONSE,
+ loanProductsResponseChargebackAllocationPrincipalFirst);
}
public static AdvancedPaymentData createPaymentAllocation(String
transactionType, String futureInstallmentAllocationRule,
diff --git
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java
index dd6830551..824556eef 100644
---
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java
+++
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java
@@ -159,4 +159,6 @@ public abstract class TestContextKey {
public static final String TRANSACTION_EVENT = "transactionEvent";
public static final String LOAN_WRITE_OFF_RESPONSE =
"loanWriteOffResponse";
public static final String LOAN_DELINQUENCY_ACTION_RESPONSE =
"loanDelinquencyActionResponse";
+ public static final String
LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST_RESPONSE =
"loanProductCreateResponseLP2NoInterestRecalculationChargebackAllocationInterestFirst";
+ public static final String
LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST_RESPONSE =
"loanProductCreateResponseLP2NoInterestRecalculationChargebackAllocationPrincipalFirst";
}
diff --git
a/fineract-e2e-tests-runner/src/test/resources/features/LoanChargeback.feature
b/fineract-e2e-tests-runner/src/test/resources/features/LoanChargeback.feature
index 86fd70430..4b7805a27 100644
---
a/fineract-e2e-tests-runner/src/test/resources/features/LoanChargeback.feature
+++
b/fineract-e2e-tests-runner/src/test/resources/features/LoanChargeback.feature
@@ -3755,3 +3755,263 @@ Feature: LoanChargeback
| 01 July 2024 | Accrual | 2.05 | 0.0 | 2.05 |
0.0 | 0.0 | 0.0 | false | false |
| 15 July 2024 | Chargeback | 17.01 | 17.01 | 0.0 |
0.0 | 0.0 | 17.01 | false | false |
| 15 July 2024 | Chargeback | 17.0 | 17.0 | 0.0 |
0.0 | 0.0 | 34.01 | false | false |
+
+ Scenario: Full chargeback with no interest recalculation, interest
allocation first, before maturity date
+ When Admin sets the business date to "1 January 2024"
+ And Admin creates a client with random data
+ 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_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST |
01 January 2024 | 100 | 7 | DECLINING_BALANCE
| DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS
| 1 | MONTHS | 6 |
0 | 0 | 0 |
ADVANCED_PAYMENT_ALLOCATION |
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan | Principal
due | Interest | Fees | Penalties | Due | Paid | In advance | Late |
Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | | | | 0.0
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 100 | 2.05 | 0 | 0 | 102.05 | 0 | 0
| 0 | 102.05 |
+ And Admin successfully approves the loan on "1 January 2024" with "100"
amount and expected disbursement date on "1 January 2024"
+ And Admin successfully disburse the loan on "1 January 2024" with "100"
EUR transaction amount
+ When Admin sets the business date to "1 March 2024"
+ And Customer makes "AUTOPAY" repayment on "01 February 2024" with 17.01
EUR transaction amount
+ And Customer makes "AUTOPAY" repayment on "01 March 2024" with 17.01 EUR
transaction amount
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 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 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 100 | 2.05 | 0 | 0 | 102.05 | 34.02 | 0
| 0 | 68.03 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ When Admin makes "REPAYMENT_ADJUSTMENT_CHARGEBACK" chargeback with 17.01
EUR transaction amount for Payment nr. 2
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 3 | 31 | 01 April 2024 | | 50.43 |
33.14 | 0.88 | 0.0 | 0.0 | 34.02 | 0.0 | 0.0 | 0.0
| 34.02 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 116.52 | 2.54 | 0 | 0 | 119.06 | 34.02 | 0
| 0 | 85.04 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ | 01 March 2024 | Chargeback | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 83.57 | false | false |
+
+ Scenario: Partial chargeback with no interest recalculation, interest
allocation first, before maturity date
+ When Admin sets the business date to "1 January 2024"
+ And Admin creates a client with random data
+ 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_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST |
01 January 2024 | 100 | 7 | DECLINING_BALANCE
| DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS
| 1 | MONTHS | 6 |
0 | 0 | 0 |
ADVANCED_PAYMENT_ALLOCATION |
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan | Principal
due | Interest | Fees | Penalties | Due | Paid | In advance | Late |
Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | | | | 0.0
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 100 | 2.05 | 0 | 0 | 102.05 | 0 | 0
| 0 | 102.05 |
+ And Admin successfully approves the loan on "1 January 2024" with "100"
amount and expected disbursement date on "1 January 2024"
+ And Admin successfully disburse the loan on "1 January 2024" with "100"
EUR transaction amount
+ When Admin sets the business date to "1 March 2024"
+ And Customer makes "AUTOPAY" repayment on "01 February 2024" with 17.01
EUR transaction amount
+ And Customer makes "AUTOPAY" repayment on "01 March 2024" with 17.01 EUR
transaction amount
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 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 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 100 | 2.05 | 0 | 0 | 102.05 | 34.02 | 0
| 0 | 68.03 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ When Admin makes "REPAYMENT_ADJUSTMENT_CHARGEBACK" chargeback with 15 EUR
transaction amount for Payment nr. 2
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 3 | 31 | 01 April 2024 | | 50.43 |
31.13 | 0.88 | 0.0 | 0.0 | 32.01 | 0.0 | 0.0 | 0.0
| 32.01 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 114.51 | 2.54 | 0 | 0 | 117.05 | 34.02 | 0
| 0 | 83.03 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ | 01 March 2024 | Chargeback | 15.0 | 14.51 | 0.49 |
0.0 | 0.0 | 81.56 | false | false |
+
+ Scenario: Partial chargeback with disabled interest recalculation,
allocation principal first, before maturity date
+ When Admin sets the business date to "1 January 2024"
+ And Admin creates a client with random data
+ 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_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST |
01 January 2024 | 100 | 7 | DECLINING_BALANCE
| DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS
| 1 | MONTHS | 6 |
0 | 0 | 0 |
ADVANCED_PAYMENT_ALLOCATION |
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan | Principal
due | Interest | Fees | Penalties | Due | Paid | In advance | Late |
Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | | | | 0.0
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 100 | 2.05 | 0 | 0 | 102.05 | 0 | 0
| 0 | 102.05 |
+ And Admin successfully approves the loan on "1 January 2024" with "100"
amount and expected disbursement date on "1 January 2024"
+ And Admin successfully disburse the loan on "1 January 2024" with "100"
EUR transaction amount
+ When Admin sets the business date to "1 March 2024"
+ And Customer makes "AUTOPAY" repayment on "01 February 2024" with 17.01
EUR transaction amount
+ And Customer makes "AUTOPAY" repayment on "01 March 2024" with 17.01 EUR
transaction amount
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 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 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 100 | 2.05 | 0 | 0 | 102.05 | 34.02 | 0
| 0 | 68.03 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ When Admin makes "REPAYMENT_ADJUSTMENT_CHARGEBACK" chargeback with 15 EUR
transaction amount for Payment nr. 2
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 3 | 31 | 01 April 2024 | | 50.43 |
31.62 | 0.39 | 0.0 | 0.0 | 32.01 | 0.0 | 0.0 | 0.0
| 32.01 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 115.0 | 2.05 | 0 | 0 | 117.05 | 34.02 | 0
| 0 | 83.03 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ | 01 March 2024 | Chargeback | 15.0 | 15.0 | 0.0 |
0.0 | 0.0 | 82.05 | false | false |
+
+ Scenario: Two chargebacks with disabled interest recalculation, allocation
principal first
+ When Admin sets the business date to "1 January 2024"
+ And Admin creates a client with random data
+ 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_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST |
01 January 2024 | 100 | 7 | DECLINING_BALANCE
| DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS
| 1 | MONTHS | 6 |
0 | 0 | 0 |
ADVANCED_PAYMENT_ALLOCATION |
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan | Principal
due | Interest | Fees | Penalties | Due | Paid | In advance | Late |
Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | | | | 0.0
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ | 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
|
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 100 | 2.05 | 0 | 0 | 102.05 | 0 | 0
| 0 | 102.05 |
+ And Admin successfully approves the loan on "1 January 2024" with "100"
amount and expected disbursement date on "1 January 2024"
+ And Admin successfully disburse the loan on "1 January 2024" with "100"
EUR transaction amount
+ When Admin sets the business date to "1 March 2024"
+ And Customer makes "AUTOPAY" repayment on "01 February 2024" with 17.01
EUR transaction amount
+ And Customer makes "AUTOPAY" repayment on "01 March 2024" with 17.01 EUR
transaction amount
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 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 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 100 | 2.05 | 0 | 0 | 102.05 | 34.02 | 0
| 0 | 68.03 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ When Admin makes "REPAYMENT_ADJUSTMENT_CHARGEBACK" chargeback with 15 EUR
transaction amount for Payment nr. 1
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 3 | 31 | 01 April 2024 | | 50.43 |
31.62 | 0.39 | 0.0 | 0.0 | 32.01 | 0.0 | 0.0 | 0.0
| 32.01 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 115.0 | 2.05 | 0 | 0 | 117.05 | 34.02 | 0
| 0 | 83.03 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ | 01 March 2024 | Chargeback | 15.0 | 15.0 | 0.0 |
0.0 | 0.0 | 82.05 | false | false |
+ When Admin makes "REPAYMENT_ADJUSTMENT_CHARGEBACK" chargeback with 17.01
EUR transaction amount for Payment nr. 2
+ Then Loan Repayment schedule has 6 periods, with the following data for
periods:
+ | Nr | Days | Date | Paid date | Balance of loan |
Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late
| Outstanding |
+ | | | 01 January 2024 | | 100.0 |
| | 0.0 | | 0.0 | 0.0 | | |
|
+ | 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 |
+ | 2 | 29 | 01 March 2024 | 01 March 2024 | 67.05 |
16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0
| 0.0 |
+ | 3 | 31 | 01 April 2024 | | 50.43 |
48.14 | 0.88 | 0.0 | 0.0 | 49.02 | 0.0 | 0.0 | 0.0
| 49.02 |
+ | 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 |
+ | 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 |
+ | 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 |
+ Then Loan Repayment schedule has the following data in Total row:
+ | Principal due | Interest | Fees | Penalties | Due | Paid | In
advance | Late | Outstanding |
+ | 131.52 | 2.54 | 0 | 0 | 134.06 | 34.02 | 0
| 0 | 100.04 |
+ Then Loan Transactions tab has the following data:
+ | Transaction date | Transaction Type | Amount | Principal | Interest |
Fees | Penalties | Loan Balance | Reverted | Replayed |
+ | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 |
0.0 | 0.0 | 100.0 | false | false |
+ | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 |
0.0 | 0.0 | 83.57 | false | false |
+ | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 67.05 | false | false |
+ | 01 March 2024 | Chargeback | 15.0 | 15.0 | 0.0 |
0.0 | 0.0 | 82.05 | false | false |
+ | 01 March 2024 | Chargeback | 17.01 | 16.52 | 0.49 |
0.0 | 0.0 | 98.57 | false | false |
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
index 76d223337..a477465eb 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
@@ -140,6 +140,9 @@ public class LoanRepaymentScheduleInstallment extends
AbstractAuditableWithUTCDa
@Column(name = "credits_amount", scale = 6, precision = 19, nullable =
true)
private BigDecimal creditedPrincipal;
+ @Column(name = "credited_interest", scale = 6, precision = 19, nullable =
true)
+ private BigDecimal creditedInterest;
+
@Column(name = "credited_fee", scale = 6, precision = 19, nullable = true)
private BigDecimal creditedFee;
@@ -232,8 +235,8 @@ public class LoanRepaymentScheduleInstallment extends
AbstractAuditableWithUTCDa
public LoanRepaymentScheduleInstallment(Loan loan, Integer
installmentNumber, LocalDate fromDate, LocalDate dueDate,
BigDecimal principal, BigDecimal interestCharged, BigDecimal
feeChargesCharged, BigDecimal penaltyCharges,
- BigDecimal creditedPrincipal, BigDecimal creditedFee, BigDecimal
creditedPenalty, boolean additional, boolean isDownPayment,
- boolean isReAged) {
+ BigDecimal creditedPrincipal, BigDecimal creditedInterest,
BigDecimal creditedFee, BigDecimal creditedPenalty,
+ boolean additional, boolean isDownPayment, boolean isReAged) {
this.loan = loan;
this.installmentNumber = installmentNumber;
this.fromDate = fromDate;
@@ -243,6 +246,7 @@ public class LoanRepaymentScheduleInstallment extends
AbstractAuditableWithUTCDa
this.feeChargesCharged = feeChargesCharged;
this.penaltyCharges = penaltyCharges;
this.creditedPrincipal = creditedPrincipal;
+ this.creditedInterest = creditedInterest;
this.creditedFee = creditedFee;
this.creditedPenalty = creditedPenalty;
this.additional = additional;
@@ -253,7 +257,7 @@ public class LoanRepaymentScheduleInstallment extends
AbstractAuditableWithUTCDa
public static LoanRepaymentScheduleInstallment newReAgedInstallment(final
Loan loan, final Integer installmentNumber,
final LocalDate fromDate, final LocalDate dueDate, final
BigDecimal principal) {
return new LoanRepaymentScheduleInstallment(loan, installmentNumber,
fromDate, dueDate, principal, null, null, null, null, null,
- null, false, false, true);
+ null, null, false, false, true);
}
public static LoanRepaymentScheduleInstallment
getLastNonDownPaymentInstallment(List<LoanRepaymentScheduleInstallment>
installments) {
@@ -442,6 +446,10 @@ public class LoanRepaymentScheduleInstallment extends
AbstractAuditableWithUTCDa
this.principal = this.principal.subtract(this.creditedPrincipal);
this.creditedPrincipal = null;
}
+ if (this.creditedInterest != null) {
+ this.interestCharged =
this.interestCharged.subtract(this.creditedInterest);
+ this.creditedInterest = null;
+ }
if (this.creditedFee != null) {
this.feeChargesCharged =
this.feeChargesCharged.subtract(this.creditedFee);
this.creditedFee = null;
@@ -853,6 +861,14 @@ public class LoanRepaymentScheduleInstallment extends
AbstractAuditableWithUTCDa
}
}
+ public void addToCreditedInterest(final BigDecimal amount) {
+ if (this.creditedInterest == null) {
+ this.creditedInterest = amount;
+ } else {
+ this.creditedInterest = this.creditedInterest.add(amount);
+ }
+ }
+
public void addToCreditedFee(final BigDecimal amount) {
if (this.creditedFee == null) {
this.creditedFee = amount;
diff --git
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java
index 49b86a365..e51758985 100644
---
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java
+++
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java
@@ -540,24 +540,30 @@ public class AdvancedPaymentScheduleTransactionProcessor
extends AbstractLoanRep
return allocation;
}
- private void recognizeAmountsAfterChargeback(TransactionCtx ctx, LocalDate
transactionDate,
- LoanRepaymentScheduleInstallment installment, Map<AllocationType,
Money> chargebackAllocation) {
- Money principal = chargebackAllocation.get(PRINCIPAL);
- if (principal.isGreaterThanZero()) {
+ private void recognizeAmountsAfterChargeback(final TransactionCtx ctx,
final LocalDate transactionDate,
+ final LoanRepaymentScheduleInstallment installment, final
Map<AllocationType, Money> chargebackAllocation) {
+ final Money principal = chargebackAllocation.get(PRINCIPAL);
+ if (principal != null && principal.isGreaterThanZero()) {
installment.addToCreditedPrincipal(principal.getAmount());
installment.addToPrincipal(transactionDate, principal);
}
- MonetaryCurrency currency = ctx.getCurrency();
- Money fee = chargebackAllocation.get(FEE);
- if (fee.isGreaterThanZero()) {
+ final Money interest = chargebackAllocation.get(INTEREST);
+ if (interest != null && interest.isGreaterThanZero()) {
+ installment.addToCreditedInterest(interest.getAmount());
+ installment.addToInterest(transactionDate, interest);
+ }
+
+ final MonetaryCurrency currency = ctx.getCurrency();
+ final Money fee = chargebackAllocation.get(FEE);
+ if (fee != null && fee.isGreaterThanZero()) {
installment.addToCreditedFee(fee.getAmount());
installment.addToChargePortion(fee, Money.zero(currency),
Money.zero(currency), Money.zero(currency), Money.zero(currency),
Money.zero(currency));
}
- Money penalty = chargebackAllocation.get(PENALTY);
- if (penalty.isGreaterThanZero()) {
+ final Money penalty = chargebackAllocation.get(PENALTY);
+ if (penalty != null && penalty.isGreaterThanZero()) {
installment.addToCreditedPenalty(penalty.getAmount());
installment.addToChargePortion(Money.zero(currency),
Money.zero(currency), Money.zero(currency), penalty, Money.zero(currency),
Money.zero(currency));
@@ -566,9 +572,8 @@ public class AdvancedPaymentScheduleTransactionProcessor
extends AbstractLoanRep
@NotNull
private LoanCreditAllocationRule
getChargebackAllocationRules(LoanTransaction loanTransaction) {
- LoanCreditAllocationRule chargeBackAllocationRule =
loanTransaction.getLoan().getCreditAllocationRules().stream()
+ return loanTransaction.getLoan().getCreditAllocationRules().stream()
.filter(tr ->
tr.getTransactionType().equals(CreditAllocationTransactionType.CHARGEBACK)).findFirst().orElseThrow();
- return chargeBackAllocationRule;
}
@NotNull
@@ -1270,7 +1275,7 @@ public class AdvancedPaymentScheduleTransactionProcessor
extends AbstractLoanRep
final LoanRepaymentScheduleInstallment
installmentForCharges = new LoanRepaymentScheduleInstallment(loan,
lastInstallment.getInstallmentNumber() + 1,
currentInstallment.getDueDate(), latestDueDate.get(),
- BigDecimal.ZERO, BigDecimal.ZERO, futureFee,
futurePenalty, null, null, null, true, false, false);
+ BigDecimal.ZERO, BigDecimal.ZERO, futureFee,
futurePenalty, null, null, null, null, true, false, false);
installmentsUpToTransactionDate.add(installmentForCharges);
}
}
diff --git
a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml
b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml
index 7964f8135..5bf431d45 100644
---
a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml
+++
b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml
@@ -183,4 +183,5 @@
<include
file="parts/0162_add_additional_audit_fields_to_term_variations.xml"
relativeToChangelogFile="true" />
<include
file="parts/0163_transaction_summary_with_asset_owner_report_accrual_adj_merged_with_accrual.xml"
relativeToChangelogFile="true" />
<include
file="parts/0164_transaction_summary_with_asset_owner_report_accrual_adj_report_separately_and_exclude_accrual_activity.xml"
relativeToChangelogFile="true" />
+ <include file="parts/0165_add_credited_interest_to_instalment.xml"
relativeToChangelogFile="true" />
</databaseChangeLog>
diff --git
a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0165_add_credited_interest_to_instalment.xml
b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0165_add_credited_interest_to_instalment.xml
new file mode 100644
index 000000000..cfcc13147
--- /dev/null
+++
b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0165_add_credited_interest_to_instalment.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">
+ <changeSet author="fineract" id="1">
+ <addColumn tableName="m_loan_repayment_schedule">
+ <column name="credited_interest" type="DECIMAL(19, 6)">
+ <constraints nullable="true"/>
+ </column>
+ </addColumn>
+ </changeSet>
+</databaseChangeLog>