FINERACT-1971: Fix next payment due date loan delinquent detail

This commit is contained in:
Ruchi Dhamankar
2024-01-12 15:57:06 +01:00
committed by Adam Saghy
parent e3a771aa71
commit 0672996678
9 changed files with 425 additions and 6 deletions
@@ -53,6 +53,8 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
private static final String REPORT_EXPORT_S3_FOLDER_NAME = "report-export-s3-folder-name";
public static final String CHARGE_ACCRUAL_DATE_CRITERIA = "charge-accrual-date";
public static final String NEXT_PAYMENT_DUE_DATE = "next-payment-due-date";
private final PermissionRepository permissionRepository;
private final GlobalConfigurationRepositoryWrapper globalConfigurationRepository;
private final PlatformCacheRepository cacheTypeRepository;
@@ -516,4 +518,15 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
return value;
}
@Override
public String getNextPaymentDateConfigForLoan() {
String defaultValue = "earliest-unpaid-date";
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(NEXT_PAYMENT_DUE_DATE);
String value = property.getStringValue();
if (StringUtils.isBlank(value)) {
return defaultValue;
}
return value;
}
}
@@ -26,6 +26,7 @@ import java.util.Optional;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.core.service.MathUtil;
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
import org.apache.fineract.portfolio.delinquency.data.DelinquencyBucketData;
@@ -70,6 +71,7 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
private final LoanInstallmentDelinquencyTagRepository repositoryLoanInstallmentDelinquencyTag;
private final LoanDelinquencyActionRepository loanDelinquencyActionRepository;
private final DelinquencyEffectivePauseHelper delinquencyEffectivePauseHelper;
private final ConfigurationDomainService configurationDomainService;
@Override
public Collection<DelinquencyRangeData> retrieveAllDelinquencyRanges() {
@@ -128,9 +130,11 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
List<LoanDelinquencyActionData> effectiveDelinquencyList = delinquencyEffectivePauseHelper
.calculateEffectiveDelinquencyList(savedDelinquencyList);
final String nextPaymentDueDateConfig = configurationDomainService.getNextPaymentDateConfigForLoan();
collectionData = loanDelinquencyDomainService.getOverdueCollectionData(loan, effectiveDelinquencyList);
collectionData.setAvailableDisbursementAmount(loan.getApprovedPrincipal().subtract(loan.getDisbursedAmount()));
collectionData.setNextPaymentDueDate(loan.possibleNextRepaymentDate());
collectionData.setNextPaymentDueDate(loan.possibleNextRepaymentDate(nextPaymentDueDateConfig));
final LoanTransaction lastPayment = loan.getLastPaymentTransaction();
if (lastPayment != null) {
@@ -18,6 +18,7 @@
*/
package org.apache.fineract.portfolio.delinquency.starter;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucketMappingsRepository;
import org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucketRepository;
@@ -57,10 +58,11 @@ public class DelinquencyConfiguration {
LoanDelinquencyDomainService loanDelinquencyDomainService,
LoanInstallmentDelinquencyTagRepository repositoryLoanInstallmentDelinquencyTag,
LoanDelinquencyActionRepository loanDelinquencyActionRepository,
DelinquencyEffectivePauseHelper delinquencyEffectivePauseHelper) {
DelinquencyEffectivePauseHelper delinquencyEffectivePauseHelper, ConfigurationDomainService configurationDomainService) {
return new DelinquencyReadPlatformServiceImpl(repositoryRange, repositoryBucket, repositoryLoanDelinquencyTagHistory, mapperRange,
mapperBucket, mapperLoanDelinquencyTagHistory, loanRepository, loanDelinquencyDomainService,
repositoryLoanInstallmentDelinquencyTag, loanDelinquencyActionRepository, delinquencyEffectivePauseHelper);
repositoryLoanInstallmentDelinquencyTag, loanDelinquencyActionRepository, delinquencyEffectivePauseHelper,
configurationDomainService);
}
@Bean
@@ -151,4 +151,5 @@
<include file="parts/0129_transaction_summary_with_asset_owner_report_overpaid_amount.xml" relativeToChangelogFile="true" />
<include file="parts/0130_add_create_delinquency_action_permission.xml" relativeToChangelogFile="true" />
<include file="parts/0131_add_configuration_maker_checker.xml" relativeToChangelogFile="true" />
<include file="parts/0132_add_configuration_loan_next_repayment_date_calculation.xml" relativeToChangelogFile="true" />
</databaseChangeLog>
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">
<changeSet author="fineract" id="1" context="postgresql">
<sql>
SELECT SETVAL('c_configuration_id_seq', COALESCE(MAX(id), 0)+1, false ) FROM c_configuration;
</sql>
</changeSet>
<changeSet author="fineract" id="2">
<insert tableName="c_configuration">
<column name="name" value="next-payment-due-date"/>
<column name="value"/>
<column name="date_value"/>
<column name="string_value" value="earliest-unpaid-date"/>
<column name="enabled" valueBoolean="true"/>
<column name="is_trap_door" valueBoolean="false"/>
<column name="description" value="earliest-unpaid-date: default for next-payment-due-date, Use earliest-unpaid-date or next-unpaid-due-date"/>
</insert>
</changeSet>
</databaseChangeLog>