adamsaghy commented on code in PR #4886:
URL: https://github.com/apache/fineract/pull/4886#discussion_r2306683609
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountInterestPostingServiceImpl.java:
##########
@@ -268,16 +305,39 @@ public List<PostingPeriod> calculateInterestUsing(final
MathContext mc, final Lo
if
(postedAsOnDates.contains(periodInterval.endDate().plusDays(1))) {
isUserPosting = true;
}
- final PostingPeriod postingPeriod =
PostingPeriod.createFromDTO(periodInterval, periodStartingBalance,
-
retreiveOrderedNonInterestPostingTransactions(savingsAccountData),
monetaryCurrency, compoundingPeriodType,
- interestCalculationType, interestRateAsFraction,
daysInYearType.getValue(), upToInterestCalculationDate,
- interestPostTransactions, isInterestTransfer,
minBalanceForInterestCalculation,
- isSavingsInterestPostingAtCurrentPeriodEnd,
overdraftInterestRateAsFraction, minOverdraftForInterestCalculation,
- isUserPosting, financialYearBeginningMonth,
savingsAccountData.isAllowOverdraft());
+ if (savingsAccountData.isAllowOverdraft() &&
!MathUtil.isZero(savingsAccountData.getGlAccountIdForInterestReceivable())) {
- periodStartingBalance = postingPeriod.closingBalance();
+ List<SavingsAccountTransactionData> overdraftTxs =
listForOverdraft(savingsAccountData, periodInterval);
+ List<SavingsAccountTransactionData> interestPostingTxs =
listForInterestPosting(savingsAccountData, periodInterval,
+ monetaryCurrency);
- allPostingPeriods.add(postingPeriod);
+ boolean isOverdraftAccountType =
isOverdraftAccount(savingsAccountData, periodInterval, monetaryCurrency);
+
+ List<SavingsAccountTransactionData> first =
isOverdraftAccountType ? overdraftTxs : interestPostingTxs;
+ List<SavingsAccountTransactionData> second =
isOverdraftAccountType ? interestPostingTxs : overdraftTxs;
+
+ periodStartingBalance =
appendPostingPeriodIfAny(periodInterval, periodStartingBalance, first,
monetaryCurrency,
+ compoundingPeriodType, interestCalculationType,
interestRateAsFraction, daysInYearType.getValue(),
+ upToInterestCalculationDate, interestPostTransactions,
isInterestTransfer, minBalanceForInterestCalculation,
+ isSavingsInterestPostingAtCurrentPeriodEnd,
overdraftInterestRateAsFraction, minOverdraftForInterestCalculation,
+ isUserPosting, financialYearBeginningMonth,
savingsAccountData.isAllowOverdraft(), allPostingPeriods,
+ isOverdraftAccountType ? true : false);
+
+ periodStartingBalance =
appendPostingPeriodIfAny(periodInterval, periodStartingBalance, second,
monetaryCurrency,
Review Comment:
Why do we have 2 of these?
Are you sure you want to override the `periodStartingBalance` variable
values?
Are you sure the first `appendPostingPeriodIfAny` result to be used in the
second `appendPostingPeriodIfAny`?
Would you mind to add some short description what exactly happens here?
--
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]