JohnAlva commented on code in PR #4886:
URL: https://github.com/apache/fineract/pull/4886#discussion_r2249414940
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountInterestPostingServiceImpl.java:
##########
@@ -268,16 +280,107 @@ 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.getGlAccountIdForInterestReceivableNegative()))
{
+
+ List<SavingsAccountTransactionData>
listOfTransactionsIsOverdraft = new ArrayList<>();
+ List<SavingsAccountTransactionData>
listOfTransactionsIsNotOverdraft = new ArrayList<>();
+ List<SavingsAccountTransactionData> firstList = null;
+ List<SavingsAccountTransactionData> secondList = null;
+ boolean firstIsNegative = false;
+ boolean firstIsSet = false;
+ Boolean flagIntroduce = false;
+
+ List<SavingsAccountTransactionData> listOfTransactions =
retreiveOrderedNonInterestPostingTransactions(savingsAccountData);
+
+ for (SavingsAccountTransactionData lists : listOfTransactions)
{
+
+ if (MathUtil.isLessThanZero(lists.getRunningBalance())
+ && periodInterval.startDate().getMonth() ==
lists.getDate().getMonth()) {
+ listOfTransactionsIsOverdraft.add(lists);
+ if (!firstIsSet) {
+ firstIsNegative = true;
+ firstIsSet = true;
+ }
+ } else if (periodInterval.startDate().getMonth() ==
lists.getDate().getMonth()) {
+ BigDecimal bd = new
BigDecimal(String.valueOf(lists.getRunningBalance())).setScale(2,
RoundingMode.DOWN);
+ if (!MathUtil.isZero(bd)) {
+ listOfTransactionsIsNotOverdraft.add(lists);
+ if (!firstIsSet) {
+ firstIsNegative = false;
+ firstIsSet = true;
+ }
+ }
+ }
+
+ }
+
+ if (firstIsNegative) {
Review Comment:
I've already refactored the method into smaller helper methods to clarify
the logic and improve readability.
--
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]