mariiaKraievska commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1967338040
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3745,4 +3760,39 @@ public void closeAsMarkedForReschedule(final Loan loan,
final JsonCommand comman
loanTransactionValidator.validateLoanRescheduleDate(loan);
}
+
+ private void createMissingAccrualTransactionIfNeeded(final BigDecimal
newInterest, final Loan loan, final LocalDate chargeOffDate) {
+ final LoanRepaymentScheduleInstallment installment =
loan.getRepaymentScheduleInstallments().stream()
+ .filter(i -> !i.getFromDate().isAfter(chargeOffDate) &&
i.getDueDate().isAfter(chargeOffDate)).findFirst().orElse(null);
+
+ if (installment == null) {
+ return;
+ }
+
+ final BigDecimal sumOfAccrualsOnCurrentPeriod =
loan.getLoanTransactions().stream()
+ .filter(lt -> lt.isAccrual() &&
!lt.getTransactionDate().isBefore(installment.getFromDate())
+ &&
lt.getTransactionDate().isBefore(installment.getDueDate()))
+ .map(LoanTransaction::getAmount).reduce(BigDecimal.ZERO,
BigDecimal::add);
+
+ final BigDecimal missingAccrualAmount =
newInterest.subtract(sumOfAccrualsOnCurrentPeriod);
+
+ if (missingAccrualAmount.compareTo(BigDecimal.ZERO) > 0) {
+ final LoanTransaction newAccrualTransaction =
accrueTransaction(loan, loan.getOffice(), chargeOffDate, missingAccrualAmount,
+ missingAccrualAmount, ZERO, ZERO,
externalIdFactory.create());
+ loan.addLoanTransaction(newAccrualTransaction);
+ }
+ }
+
+ private BigDecimal getInterestTillChargeOffForPeriod(final Loan loan,
final LocalDate chargeOffDate) {
Review Comment:
Done
--
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]