adamsaghy commented on code in PR #5937:
URL: https://github.com/apache/fineract/pull/5937#discussion_r3389775753
##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanBreachScheduleServiceImpl.java:
##########
@@ -146,6 +147,28 @@ private void applyRepayment(final
WorkingCapitalLoanBreachSchedule period, BigDe
log.debug("Applied repayment of {} to Breach Schedule period {} for WC
loan {}", payAmount, period.getPeriodNumber(), loanId);
}
+ @Override
+ public void applyRepaymentUndo(Long loanId, LocalDate transactionDate,
BigDecimal amount) {
+ Optional<WorkingCapitalLoanBreachSchedule> currentPeriod = repository
+
.findByLoanIdAndFromDateLessThanEqualAndToDateGreaterThanEqual(loanId,
transactionDate, transactionDate);
+ currentPeriod.ifPresent(period -> applyRepaymentUndo(period, amount,
loanId));
+ }
+
+ private void applyRepaymentUndo(final WorkingCapitalLoanBreachSchedule
period, BigDecimal payAmount, Long loanId) {
+ BigDecimal newPaidAmount = period.getPaidAmount().subtract(payAmount);
+ period.setPaidAmount(newPaidAmount);
+
period.setOutstandingAmount(period.getMinPaymentAmount().subtract(period.getPaidAmount()).max(BigDecimal.ZERO));
+ if (period.getOutstandingAmount().compareTo(BigDecimal.ZERO) > 0) {
+ if
(period.getToDate().isBefore(ThreadLocalContextUtil.getBusinessDate())) {
+ period.setBreach(true);
+ } else {
+ period.setBreach(null);
+ }
+ }
+ repository.saveAndFlush(period);
Review Comment:
Not needed
--
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]