adamsaghy commented on code in PR #4634:
URL: https://github.com/apache/fineract/pull/4634#discussion_r2085003138
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanTransactionProcessingServiceImpl.java:
##########
@@ -59,11 +61,52 @@ public class LoanTransactionProcessingServiceImpl
implements LoanTransactionProc
private final LoanTermVariationsMapper loanMapper;
private final InterestScheduleModelRepositoryWrapper modelRepository;
+ @Override
+ public boolean canProcessLatestTransactionOnly(Loan loan, LoanTransaction
loanTransaction,
+ LoanRepaymentScheduleInstallment currentInstallment) {
+ if (!loan.isInterestBearingAndInterestRecalculationEnabled()) {
+ return true;
+ }
+ if
(!DateUtils.isEqualBusinessDate(loanTransaction.getTransactionDate())) {
+ return false;
+ }
+ if (loan.isProgressiveSchedule()) {
+ return modelRepository.hasValidModelForDate(loan.getId(),
loanTransaction.getTransactionDate());
+ }
+ return currentInstallment != null
+ &&
currentInstallment.getTotalOutstanding(loan.getCurrency()).isEqualTo(loanTransaction.getAmount(loan.getCurrency()));
+ }
+
+ private ChangedTransactionDetail
processLatestTransactionProgressiveInterestRecalculation(
+ AdvancedPaymentScheduleTransactionProcessor advancedProcessor,
Loan loan, LoanTransaction loanTransaction) {
+ Optional<ProgressiveLoanInterestScheduleModel> savedModel =
modelRepository.getSavedModel(loan,
+ loanTransaction.getTransactionDate());
+
+ if (savedModel.isEmpty()) {
+ throw new IllegalStateException("No saved interest schedule model
found for loan #" + loan.getId() + " with transaction date "
+ + loanTransaction.getTransactionDate());
+ }
+
+ ProgressiveTransactionCtx progressiveContext = new
ProgressiveTransactionCtx(loan.getCurrency(),
+ loan.getRepaymentScheduleInstallments(),
loan.getActiveCharges(), new MoneyHolder(loan.getTotalOverpaidAsMoney()),
+ new ChangedTransactionDetail(), savedModel.orElse(null));
+ progressiveContext.setChargedOff(loan.isChargedOff());
+ ChangedTransactionDetail result =
advancedProcessor.processLatestTransaction(loanTransaction, progressiveContext);
+ if (!TransactionSynchronizationManager.isCurrentTransactionReadOnly())
{
+ modelRepository.writeInterestScheduleModel(loan, savedModel.get());
Review Comment:
yeah... throwing exception looks weird...
--
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]