Cocoa-Puffs commented on code in PR #6067:
URL: https://github.com/apache/fineract/pull/6067#discussion_r3506306215


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanBuyDownFeeAmortizationProcessingServiceImpl.java:
##########
@@ -80,14 +80,17 @@ public void processBuyDownFeeAmortizationTillDate(@NonNull 
Loan loan, @NonNull L
             AmortizationType amortizationType;
             if (!balance.isDeleted()) {
                 final List<LoanTransaction> adjustments = 
loanTransactionRepository.findAdjustments(balance.getLoanTransaction());
-                final Money amortizationTillDate = 
BuyDownFeeAmortizationUtil.calculateTotalAmortizationTillDate(balance, 
adjustments,
-                        maturityDate, 
loan.getLoanProductRelatedDetail().getBuyDownFeeStrategy(), tillDatePlusOne, 
loan.getCurrency());
                 final BigDecimal alreadyAmortizedAmount = 
loanAmortizationAllocationService
                         
.calculateAlreadyAmortizedAmount(balance.getLoanTransaction().getId(), 
loan.getId());
                 if (MathUtil.isZero(balance.getUnrecognizedAmount()) && 
adjustments.isEmpty()) {
                     totalAmortization = 
totalAmortization.add(Money.of(loan.getCurrency(), alreadyAmortizedAmount));
                     continue;
                 }
+                final boolean fullyAmortizedOnSaleOrClosure = 
MathUtil.isZero(balance.getUnrecognizedAmount())
+                        && 
alreadyAmortizedAmount.compareTo(balance.getAmount()) >= 0;
+                final LocalDate effectiveTillDate = 
fullyAmortizedOnSaleOrClosure ? maturityDate : tillDatePlusOne;
+                final Money amortizationTillDate = 
BuyDownFeeAmortizationUtil.calculateTotalAmortizationTillDate(balance, 
adjustments,
+                        maturityDate, 
loan.getLoanProductRelatedDetail().getBuyDownFeeStrategy(), effectiveTillDate, 
loan.getCurrency());

Review Comment:
   yes. the same bug was present in capitalized income scenarios as well. i 
have added the fix to there as well



-- 
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]

Reply via email to