Eyad-Sharkawy commented on code in PR #6405:
URL: https://github.com/apache/fineract/pull/6405#discussion_r4384023793
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/FixedDepositTest.java:
##########
@@ -1620,4 +1620,61 @@ private LoanTestData.Journal debit(final Account
account, final BigDecimal amoun
private LoanTestData.Journal credit(final Account account, final
BigDecimal amount) {
return LoanTestData.Journal.credit(account.getAccountID().longValue(),
amount.doubleValue());
}
+
+ @Test
+ public void testFixedDepositAccountWithRateChartOverriddenLifecycle() {
+ DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy",
Locale.US);
+ Calendar todaysDate = Calendar.getInstance();
+ todaysDate.add(Calendar.MONTH, -3);
+ final String VALID_FROM = dateFormat.format(todaysDate.getTime());
+ todaysDate.add(Calendar.YEAR, 10);
+ final String VALID_TO = dateFormat.format(todaysDate.getTime());
+
+ todaysDate = Calendar.getInstance();
+ todaysDate.add(Calendar.MONTH, -1);
+ final String SUBMITTED_ON_DATE =
dateFormat.format(todaysDate.getTime());
+ final String APPROVED_ON_DATE =
dateFormat.format(todaysDate.getTime());
+ final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
+
+ Long clientId = clientHelper.createClient();
+ Assertions.assertNotNull(clientId);
+
+ Long fixedDepositProductId = createFixedDepositProduct(VALID_FROM,
VALID_TO, NONE);
+ Assertions.assertNotNull(fixedDepositProductId);
+
+ // 1. Submit application with isRateChartOverridden = true and custom
nominalAnnualInterestRate = 10.0
+ final BigDecimal customInterestRate = new BigDecimal("10.0");
+ PostFixedDepositAccountsRequest request = DepositRequestBuilders
+ .fixedDepositAccount(clientId, fixedDepositProductId,
SUBMITTED_ON_DATE, WHOLE_TERM).isRateChartOverridden(true)
+ .nominalAnnualInterestRate(customInterestRate);
+
+ Long fixedDepositAccountId =
fixedDepositHelper.submitApplication(request).getSavingsId();
+ Assertions.assertNotNull(fixedDepositAccountId);
+
+ // 2. GET and verify rate chart is overridden with custom rate
+ GetFixedDepositAccountsAccountIdResponse account =
fixedDepositHelper.getAccount(fixedDepositAccountId);
+
Assertions.assertTrue(Boolean.TRUE.equals(account.getIsRateChartOverridden()),
"isRateChartOverridden should be true");
+ Assertions.assertEquals(0,
customInterestRate.compareTo(account.getNominalAnnualInterestRate()));
+
+ // 3. Update application to toggle isRateChartOverridden back to false
Review Comment:
Addressed in the latest commit: added
`testFixedDepositAccountWithRateChartOverriddenEndToEnd()` in
`FixedDepositTest` and
`testRecurringDepositAccountWithRateChartOverriddenEndToEnd()` in
`RecurringDepositTest`, which keep the override enabled through approval,
activation, and interest calculation, asserting that interest is calculated at
the custom 10% rate.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java:
##########
@@ -161,7 +161,7 @@ protected BigDecimal
getEffectiveInterestRateAsFraction(final MathContext mc, fi
// default it to nominalAnnualInterst rate. interest chart overrrides
// this value.
BigDecimal applicableInterestRate = this.nominalAnnualInterestRate;
- if (this.chart != null) {
+ if (this.chart != null &&
!this.accountTermAndPreClosure.isRateChartOverridden()) {
Review Comment:
Addressed in the latest commit: the premature closure penalty is now applied
to custom rates in a local variable without writing it back to
`this.nominalAnnualInterestRate`, ensuring full idempotency and zero rate drift
during previews (`calculatePrematureAmount`) or premature closure. Updated unit
tests for both FD and RD to assert the penalized rate and verify idempotency.
##########
fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountTermAndPreClosure.java:
##########
@@ -301,12 +315,13 @@ public DepositAccountTermAndPreClosure copy(BigDecimal
depositAmount) {
final DepositTermDetail depositTermDetail =
this.depositTermDetail.copy();
final LocalDate expectedFirstDepositOnDate = null;
final Boolean transferInterestToLinkedAccount = false;
+ final boolean isRateChartOverridden = this.isRateChartOverridden;
Review Comment:
Addressed in the latest commit: `reInvest()` in both `FixedDepositAccount`
and `RecurringDepositAccount` now carries over the custom interest rate when
`isRateChartOverridden` is true (`interestRate =
this.accountTermAndPreClosure.isRateChartOverridden() ?
this.nominalAnnualInterestRate : BigDecimal.ZERO`), preventing the 0%
reinvestment. Added unit tests in `DepositAccountRateChartOverriddenTest`
covering reinvestment for both FD and RD accounts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]