somasorosdpc commented on code in PR #4577:
URL: https://github.com/apache/fineract/pull/4577#discussion_r2044059049


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/InterestScheduleModelRepositoryWrapperImpl.java:
##########
@@ -57,6 +64,39 @@ public String writeInterestScheduleModel(Loan loan, 
ProgressiveLoanInterestSched
         return jsonModel;
     }
 
+    @Override
+    public Optional<ProgressiveLoanModel> findOneByLoanId(Long loanId) {
+        return loanModelRepository.findOneByLoanId(loanId);
+    }
+
+    @Override
+    public Optional<ProgressiveLoanInterestScheduleModel> 
extractModel(Optional<ProgressiveLoanModel> progressiveLoanModel) {
+        return progressiveLoanModel.map(ProgressiveLoanModel::getJsonModel) //
+                .map(jsonModel -> 
progressiveLoanInterestScheduleModelParserService.fromJson(jsonModel,
+                        
progressiveLoanModel.get().getLoan().getLoanProductRelatedDetail(), 
MoneyHelper.getMathContext(),
+                        
progressiveLoanModel.get().getLoan().getLoanProduct().getInstallmentAmountInMultiplesOf()));
+    }
+
+    @Override
+    @Transactional
+    public Optional<ProgressiveLoanInterestScheduleModel> 
getAndUpdateModel(Loan loan, LocalDate businessDate) {
+        Optional<ProgressiveLoanModel> progressiveLoanModel = 
findOneByLoanId(loan.getId());
+        Optional<ProgressiveLoanInterestScheduleModel> savedModel;
+        if (progressiveLoanModel.isPresent() && 
!progressiveLoanModel.get().getBusinessDate().isAfter(businessDate)) {

Review Comment:
   Actually it is to make sure not to use saved model if saved model 
calculation is "later" than the current business date. It can happen during 
integration testing when integration tests travels in time also can hapen, if 
there is newer transaction than the actual close of business day ( it could 
cause other anomalies, but at least stored model shouldn't be used ).



##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java:
##########
@@ -67,6 +68,9 @@ public class ProgressiveLoanInterestScheduleModel {
     private final Money zero;
     private final Map<LoanInterestScheduleModelModifiers, Boolean> modifiers;
 
+    @Setter
+    private LocalDate lastOverdueBalanceChange;

Review Comment:
   It is not a contextual variable, rather a model variable which we use to 
calculate the overdue interest. It is not managed by EMI calculator but 
strictly related to the model. I did some review and process single Transaction 
will need this date, and because it is not related to loan but the progressive 
loan and more specifically to the progressive loan model. We can discuss about 
moving `adjustOverduePrincipalForInstallment` from 
`AdvancedPaymentScheduleTransactionProcessor` to `EMICalculator` because it is 
depends on loan config and model only.



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