This is an automated email from the ASF dual-hosted git repository.

arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new a85845ba5 Revert "FINERACT-1840: Fee income is not realised if the 
loan got fully repaid (#2902)"
a85845ba5 is described below

commit a85845ba52f7650393845b742de0b771c228c540
Author: Arnold Gálovics <[email protected]>
AuthorDate: Wed Jan 25 12:09:03 2023 +0100

    Revert "FINERACT-1840: Fee income is not realised if the loan got fully 
repaid (#2902)"
    
    This reverts commit f3d7c042a453d2532e65685661dea1b699341bde.
---
 .../domain/LoanAccountDomainServiceJpa.java        | 89 ++++++++++------------
 1 file changed, 40 insertions(+), 49 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
index 6b397732f..a66cdfc83 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
@@ -544,59 +544,50 @@ public class LoanAccountDomainServiceJpa implements 
LoanAccountDomainService {
     @Override
     public void recalculateAccruals(Loan loan, boolean 
isInterestCalculationHappened) {
         LocalDate accruedTill = loan.getAccruedTill();
-        final LocalDate businessDate = DateUtils.getBusinessLocalDate();
-        if (loan.isPeriodicAccrualAccountingEnabledOnLoanProduct() // Loan 
Product with Accrual Accounting
-                && isInterestCalculationHappened // Loan Product with Interest 
Recalculation enabled
-                // Loan Account accrued till is not equal to the Business Date
-                && (accruedTill == null || !accruedTill.equals(businessDate)) 
&& !loan.isNpa() // Loan Account is not
-                                                                               
                // NPA
-        ) {
-            // Loan Account is Active OR is Recently Closed with Obligations 
Met
-            if (loan.getStatus().isActive() || 
(loan.getStatus().isClosedObligationsMet() && 
loan.getClosedOnDate().equals(businessDate))) {
-                if (accruedTill == null) {
-                    accruedTill = businessDate;
-                }
+        if (!loan.isPeriodicAccrualAccountingEnabledOnLoanProduct() || 
!isInterestCalculationHappened || accruedTill == null || loan.isNpa()
+                || !loan.getStatus().isActive()) {
+            return;
+        }
+
+        boolean isOrganisationDateEnabled = 
this.configurationDomainService.isOrganisationstartDateEnabled();
+        LocalDate organisationStartDate = DateUtils.getBusinessLocalDate();
+        if (isOrganisationDateEnabled) {
+            organisationStartDate = 
this.configurationDomainService.retrieveOrganisationStartDate();
+        }
+        Collection<LoanScheduleAccrualData> loanScheduleAccrualList = new 
ArrayList<>();
+        List<LoanRepaymentScheduleInstallment> installments = 
loan.getRepaymentScheduleInstallments();
+        Long loanId = loan.getId();
+        Long officeId = loan.getOfficeId();
+        LocalDate accrualStartDate = null;
+        PeriodFrequencyType repaymentFrequency = 
loan.repaymentScheduleDetail().getRepaymentPeriodFrequencyType();
+        Integer repayEvery = loan.repaymentScheduleDetail().getRepayEvery();
+        LocalDate interestCalculatedFrom = loan.getInterestChargedFromDate();
+        Long loanProductId = loan.productId();
+        MonetaryCurrency currency = loan.getCurrency();
+        ApplicationCurrency applicationCurrency = 
this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
+        CurrencyData currencyData = applicationCurrency.toData();
+        Set<LoanCharge> loanCharges = loan.getActiveCharges();
 
-                boolean isOrganisationDateEnabled = 
this.configurationDomainService.isOrganisationstartDateEnabled();
-                LocalDate organisationStartDate = businessDate;
-                if (isOrganisationDateEnabled) {
-                    organisationStartDate = 
this.configurationDomainService.retrieveOrganisationStartDate();
-                }
-                Collection<LoanScheduleAccrualData> loanScheduleAccrualList = 
new ArrayList<>();
-                List<LoanRepaymentScheduleInstallment> installments = 
loan.getRepaymentScheduleInstallments();
-                Long loanId = loan.getId();
-                Long officeId = loan.getOfficeId();
-                LocalDate accrualStartDate = null;
-                PeriodFrequencyType repaymentFrequency = 
loan.repaymentScheduleDetail().getRepaymentPeriodFrequencyType();
-                Integer repayEvery = 
loan.repaymentScheduleDetail().getRepayEvery();
-                LocalDate interestCalculatedFrom = 
loan.getInterestChargedFromDate();
-                Long loanProductId = loan.productId();
-                MonetaryCurrency currency = loan.getCurrency();
-                ApplicationCurrency applicationCurrency = 
this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
-                CurrencyData currencyData = applicationCurrency.toData();
-                Set<LoanCharge> loanCharges = loan.getActiveCharges();
-
-                for (LoanRepaymentScheduleInstallment installment : 
installments) {
-                    if 
(installment.getDueDate().isAfter(loan.getMaturityDate())) {
-                        accruedTill = businessDate;
-                    }
-                    if (!isOrganisationDateEnabled || 
organisationStartDate.isBefore(installment.getDueDate())) {
-                        generateLoanScheduleAccrualData(accruedTill, 
loanScheduleAccrualList, loanId, officeId, accrualStartDate,
-                                repaymentFrequency, repayEvery, 
interestCalculatedFrom, loanProductId, currency, currencyData, loanCharges,
-                                installment);
-                    }
-                }
+        for (LoanRepaymentScheduleInstallment installment : installments) {
+            if (installment.getDueDate().isAfter(loan.getMaturityDate())) {
+                accruedTill = DateUtils.getBusinessLocalDate();
+            }
+            if (!isOrganisationDateEnabled || 
organisationStartDate.isBefore(installment.getDueDate())) {
+                generateLoanScheduleAccrualData(accruedTill, 
loanScheduleAccrualList, loanId, officeId, accrualStartDate,
+                        repaymentFrequency, repayEvery, 
interestCalculatedFrom, loanProductId, currency, currencyData, loanCharges,
+                        installment);
+            }
+        }
 
-                if (!loanScheduleAccrualList.isEmpty()) {
-                    try {
-                        
this.loanAccrualPlatformService.addPeriodicAccruals(accruedTill, 
loanScheduleAccrualList);
-                    } catch (MultiException e) {
-                        String globalisationMessageCode = 
"error.msg.accrual.exception";
-                        throw new 
GeneralPlatformDomainRuleException(globalisationMessageCode, e.getMessage(), e);
-                    }
-                }
+        if (!loanScheduleAccrualList.isEmpty()) {
+            try {
+                
this.loanAccrualPlatformService.addPeriodicAccruals(accruedTill, 
loanScheduleAccrualList);
+            } catch (MultiException e) {
+                String globalisationMessageCode = 
"error.msg.accrual.exception";
+                throw new 
GeneralPlatformDomainRuleException(globalisationMessageCode, e.getMessage(), e);
             }
         }
+
     }
 
     private void generateLoanScheduleAccrualData(final LocalDate accruedTill,

Reply via email to