Abhishek6122008 commented on code in PR #6782:
URL: https://github.com/apache/fineract/pull/6782#discussion_r4418249017
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/interest/PostingPeriod.java:
##########
@@ -291,32 +291,72 @@ public BigDecimal calculateInterest(final
CompoundInterestValues compoundInteres
// for each compounding period accumulate the amount of interest
// to be applied to the balanced for interest calculation
for (final CompoundingPeriod compoundingPeriod :
this.compoundingPeriods) {
+ final BigDecimal interestUnrounded = interestOn(compoundingPeriod,
compoundInterestValues.getcompoundedInterest());
+ compound(compoundingPeriod, interestUnrounded,
compoundInterestValues);
+ interestEarned = interestEarned.add(interestUnrounded);
+ }
- final BigDecimal interestUnrounded =
compoundingPeriod.calculateInterest(this.interestCompoundingType,
- this.interestCalculationType,
compoundInterestValues.getcompoundedInterest(), this.interestRateAsFraction,
- this.daysInYear,
this.minBalanceForInterestCalculation.getAmount(),
this.overdraftInterestRateAsFraction,
- this.minOverdraftForInterestCalculation.getAmount());
- BigDecimal unCompoundedInterest =
compoundInterestValues.getuncompoundedInterest().add(interestUnrounded);
-
compoundInterestValues.setuncompoundedInterest(unCompoundedInterest);
- LocalDate compoundingPeriodEndDate =
compoundingPeriod.getPeriodInterval().endDate();
- if
(!SavingsCompoundingInterestPeriodType.DAILY.equals(this.interestCompoundingType))
{
- compoundingPeriodEndDate =
determineInterestPeriodEndDateFrom(compoundingPeriod.getPeriodInterval().startDate(),
- this.interestCompoundingType,
compoundingPeriod.getPeriodInterval().endDate(),
- this.getFinancialYearBeginningMonth());
- }
+ updateInterestEarned(interestEarned);
+ return interestEarned;
+ }
- if
(compoundingPeriodEndDate.equals(compoundingPeriod.getPeriodInterval().endDate()))
{
- BigDecimal interestCompounded =
compoundInterestValues.getcompoundedInterest().add(unCompoundedInterest);
-
compoundInterestValues.setCompoundedInterest(interestCompounded);
- compoundInterestValues.setZeroForInterestToBeUncompounded();
- }
- interestEarned = interestEarned.add(interestUnrounded);
+ /**
+ * Calculates the interest of the two periods that the overdraft split
builds for one posting interval, one for the
+ * days in credit and one for the overdrawn days. They cover different
days of the same compounding periods, so they
+ * are calculated one compounding period at a time and the interest of
both is compounded at its end, as it is when
+ * the interval is not split. Calculated one after the other, the second
period would get the interest of the first
+ * compounded into all its days, before the end of the compounding period
it was earned in.
+ */
+ public static BigDecimal calculateInterest(final PostingPeriod first,
final PostingPeriod second,
+ final CompoundInterestValues compoundInterestValues) {
Review Comment:
Renamed it to calculateInterestForSplitInterval.
--
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]