Skip to content

Commit b334dde

Browse files
Tedyyy-Alburxhris
authored andcommitted
FINERACT-2393:Currently in Deposit, FD and RD products/Account configuration, we could set the “Interest Compounding Period” to Daily/Weekly/Monthly/Yearly.
1 parent cd0ecfc commit b334dde

File tree

11 files changed

+575
-37
lines changed

11 files changed

+575
-37
lines changed

fineract-core/src/main/java/org/apache/fineract/portfolio/savings/SavingsCompoundingInterestPeriodType.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ public enum SavingsCompoundingInterestPeriodType {
3434
MONTHLY(4, "savingsCompoundingInterestPeriodType.monthly"), //
3535
QUATERLY(5, "savingsCompoundingInterestPeriodType.quarterly"), //
3636
BI_ANNUAL(6, "savingsCompoundingInterestPeriodType.biannual"), //
37-
ANNUAL(7, "savingsCompoundingInterestPeriodType.annual"); //
38-
39-
// NO_COMPOUNDING_SIMPLE_INTEREST(8, "savingsCompoundingInterestPeriodType.nocompounding");
37+
ANNUAL(7, "savingsCompoundingInterestPeriodType.annual"), //
38+
NONE(8, "savingsCompoundingInterestPeriodType.none");//
4039

4140
private final Integer value;
4241
private final String code;
@@ -79,8 +78,8 @@ public static SavingsCompoundingInterestPeriodType fromInt(final Integer v) {
7978
return BI_ANNUAL;
8079
case 7:
8180
return ANNUAL;
82-
// case 8:
83-
// return NO_COMPOUNDING_SIMPLE_INTEREST;
81+
case 8:
82+
return NONE;
8483
default:
8584
return INVALID;
8685
}

fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/interest/MonthlyCompoundingPeriod.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ private BigDecimal calculateUsingDailyBalanceMethod(final SavingsCompoundingInte
140140
// break;
141141
// case ANNUAL:
142142
// break;
143-
// case NO_COMPOUNDING_SIMPLE_INTEREST:
144-
// break;
143+
case NONE:
144+
interestOnBalanceUnrounded = balance.calculateInterestOnBalance(interestToCompound, interestRateAsFraction, daysInYear,
145+
minBalanceForInterestCalculation, overdraftInterestRateAsFraction, minOverdraftForInterestCalculation);
146+
break;
145147
case INVALID:
146148
break;
147149
default:

fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/interest/PostingPeriod.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ public BigDecimal calculateInterest(final CompoundInterestValues compoundInteres
292292
// to be applied to the balanced for interest calculation
293293
for (final CompoundingPeriod compoundingPeriod : this.compoundingPeriods) {
294294

295+
if (SavingsCompoundingInterestPeriodType.NONE.equals(this.interestCompoundingType)) {
296+
compoundInterestValues.setCompoundedInterest(BigDecimal.ZERO);
297+
}
298+
295299
final BigDecimal interestUnrounded = compoundingPeriod.calculateInterest(this.interestCompoundingType,
296300
this.interestCalculationType, compoundInterestValues.getcompoundedInterest(), this.interestRateAsFraction,
297301
this.daysInYear, this.minBalanceForInterestCalculation.getAmount(), this.overdraftInterestRateAsFraction,
@@ -444,8 +448,31 @@ private static List<CompoundingPeriod> compoundingPeriodsInPostingPeriod(final L
444448
periodStartDate = periodEndDate.plusDays(1);
445449
}
446450
break;
447-
// case NO_COMPOUNDING_SIMPLE_INTEREST:
448-
// break;
451+
case NONE:
452+
final LocalDate postingPeriodEndDateNONE = postingPeriodInterval.endDate();
453+
454+
periodStartDate = postingPeriodInterval.startDate();
455+
periodEndDate = periodStartDate;
456+
457+
while (!DateUtils.isAfter(periodStartDate, postingPeriodEndDateNONE)
458+
&& !DateUtils.isAfter(periodEndDate, postingPeriodEndDateNONE)) {
459+
periodEndDate = determineInterestPeriodEndDateFrom(periodStartDate, interestPeriodType, upToInterestCalculationDate,
460+
financialYearBeginningMonth);
461+
if (DateUtils.isAfter(periodEndDate, postingPeriodEndDateNONE)) {
462+
periodEndDate = postingPeriodEndDateNONE;
463+
}
464+
465+
final LocalDateInterval compoundingPeriodInterval = LocalDateInterval.create(periodStartDate, periodEndDate);
466+
if (postingPeriodInterval.contains(compoundingPeriodInterval)) {
467+
compoundingPeriod = MonthlyCompoundingPeriod.create(compoundingPeriodInterval, allEndOfDayBalances,
468+
upToInterestCalculationDate);
469+
compoundingPeriods.add(compoundingPeriod);
470+
}
471+
472+
// move periodStartDate forward to day after this period
473+
periodStartDate = periodEndDate.plusDays(1);
474+
}
475+
break;
449476
}
450477

451478
return compoundingPeriods;
@@ -496,10 +523,9 @@ private static LocalDate determineInterestPeriodEndDateFrom(final LocalDate peri
496523
}
497524
break;
498525

499-
// case NO_COMPOUNDING_SIMPLE_INTEREST:
500-
// periodEndDate = periodStartDate.monthOfYear().withMaximumValue();
501-
// periodEndDate = periodEndDate.with(TemporalAdjusters.lastDayOfMonth());
502-
// break;
526+
case NONE:
527+
periodEndDate = periodEndDate.with(TemporalAdjusters.lastDayOfMonth());
528+
break;
503529
}
504530

505531
return periodEndDate;

fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,10 @@ public static EnumOptionData compoundingInterestPeriodType(final SavingsCompound
440440
optionData = new EnumOptionData(SavingsCompoundingInterestPeriodType.ANNUAL.getValue().longValue(),
441441
codePrefix + SavingsCompoundingInterestPeriodType.ANNUAL.getCode(), "Annually");
442442
break;
443-
// case NO_COMPOUNDING_SIMPLE_INTEREST:
444-
// optionData = new
445-
// EnumOptionData(SavingsCompoundingInterestPeriodType.NO_COMPOUNDING_SIMPLE_INTEREST.getValue().longValue(),
446-
// codePrefix +
447-
// SavingsCompoundingInterestPeriodType.NO_COMPOUNDING_SIMPLE_INTEREST.getCode(),
448-
// "No Compounding - Simple Interest");
449-
// break;
443+
case NONE:
444+
optionData = new EnumOptionData(SavingsCompoundingInterestPeriodType.NONE.getValue().longValue(),
445+
codePrefix + SavingsCompoundingInterestPeriodType.NONE.getCode(), "None");
446+
break;
450447
}
451448

452449
return optionData;

fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccrualWritePlatformServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private void addAccrualTransactions(SavingsAccount savingsAccount, final LocalDa
114114
.fromInt(savingsAccount.getInterestCalculationType());
115115

116116
final SavingsCompoundingInterestPeriodType compoundingPeriodType = SavingsCompoundingInterestPeriodType
117-
.fromInt(savingsAccount.getInterestPostingPeriodType());
117+
.fromInt(savingsAccount.getInterestCompoundingPeriodType());
118118

119119
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
120120
.fromInt(savingsAccount.getInterestCalculationDaysInYearType());

fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsDropdownReadPlatformServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public Collection<EnumOptionData> retrieveCompoundingInterestPeriodTypeOptions()
5959
SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.MONTHLY),
6060
SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.QUATERLY),
6161
SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.BI_ANNUAL),
62+
SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.NONE),
6263
SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.ANNUAL));
6364

6465
return allowedOptions;

fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositProduct.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ public DepositProductTermAndPreClosure depositProductTermAndPreClosure() {
285285

286286
public void validateInterestPostingAndCompoundingPeriodTypes(final DataValidatorBuilder baseDataValidator) {
287287
Map<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>> postingtoCompoundMap = new HashMap<>();
288-
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.MONTHLY, Arrays.asList(new SavingsCompoundingInterestPeriodType[] {
289-
SavingsCompoundingInterestPeriodType.DAILY, SavingsCompoundingInterestPeriodType.MONTHLY }));
288+
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.MONTHLY,
289+
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
290+
SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.NONE }));
290291

291292
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.QUATERLY,
292293
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,

0 commit comments

Comments
 (0)