FINERACT-2081: Skip loan processing if no overdue
This commit is contained in:
committed by
Adam Saghy
parent
a655707e0a
commit
b68149c6cd
+3
-1
@@ -37,7 +37,9 @@ public class ApplyChargeToOverdueLoansBusinessStep implements LoanCOBBusinessSte
|
||||
public Loan execute(Loan loan) {
|
||||
final Collection<OverdueLoanScheduleData> overdueLoanScheduleDataList = loanReadPlatformService
|
||||
.retrieveAllOverdueInstallmentsForLoan(loan);
|
||||
loanChargeWritePlatformService.applyOverdueChargesForLoan(loan.getId(), overdueLoanScheduleDataList);
|
||||
if (!overdueLoanScheduleDataList.isEmpty()) {
|
||||
loanChargeWritePlatformService.applyOverdueChargesForLoan(loan.getId(), overdueLoanScheduleDataList);
|
||||
}
|
||||
return loan;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -68,7 +68,9 @@ public class ApplyChargeToOverdueLoanInstallmentTasklet implements Tasklet {
|
||||
List<Throwable> exceptions = new ArrayList<>();
|
||||
for (Map.Entry<Long, Collection<OverdueLoanScheduleData>> entry : overdueScheduleData.entrySet()) {
|
||||
try {
|
||||
loanChargeWritePlatformService.applyOverdueChargesForLoan(entry.getKey(), entry.getValue());
|
||||
if (!entry.getValue().isEmpty()) {
|
||||
loanChargeWritePlatformService.applyOverdueChargesForLoan(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
} catch (final PlatformApiDataValidationException e) {
|
||||
final List<ApiParameterError> errors = e.getErrors();
|
||||
|
||||
+9
@@ -31,6 +31,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -764,11 +765,19 @@ public class LoanChargeWritePlatformServiceImpl implements LoanChargeWritePlatfo
|
||||
@Transactional
|
||||
@Override
|
||||
public void applyOverdueChargesForLoan(final Long loanId, Collection<OverdueLoanScheduleData> overdueLoanScheduleDataList) {
|
||||
if (overdueLoanScheduleDataList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Loan loan = this.loanAssembler.assembleFrom(loanId);
|
||||
if (loan.isChargedOff()) {
|
||||
log.warn("Adding charge to Loan: {} is not allowed. Loan Account is Charged-off", loanId);
|
||||
return;
|
||||
}
|
||||
Optional<Charge> optPenaltyCharge = loan.getLoanProduct().getCharges().stream()
|
||||
.filter((e) -> ChargeTimeType.OVERDUE_INSTALLMENT.getValue().equals(e.getChargeTimeType()) && e.isLoanCharge()).findFirst();
|
||||
if (optPenaltyCharge.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final List<Long> existingTransactionIds = loan.findExistingTransactionIds();
|
||||
final List<Long> existingReversedTransactionIds = loan.findExistingReversedTransactionIds();
|
||||
boolean runInterestRecalculation = false;
|
||||
|
||||
+11
-9
@@ -1642,6 +1642,15 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
|
||||
if (!loan.isOpen()) {
|
||||
return list;
|
||||
}
|
||||
|
||||
Optional<Charge> optPenaltyCharge = loan.getLoanProduct().getCharges().stream()
|
||||
.filter((e) -> ChargeTimeType.OVERDUE_INSTALLMENT.getValue().equals(e.getChargeTimeType()) && e.isLoanCharge()).findFirst();
|
||||
|
||||
if (optPenaltyCharge.isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
final Charge penaltyCharge = optPenaltyCharge.get();
|
||||
|
||||
final Long penaltyWaitPeriod = configurationDomainService.retrievePenaltyWaitPeriod();
|
||||
final boolean backdatePenalties = configurationDomainService.isBackdatePenaltiesEnabled();
|
||||
|
||||
@@ -1657,16 +1666,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
|
||||
if (!backdatePenalties && !isDueToday) {
|
||||
continue;
|
||||
}
|
||||
Optional<Charge> penaltyCharge = loan.getLoanProduct().getCharges().stream()
|
||||
.filter((e) -> ChargeTimeType.OVERDUE_INSTALLMENT.getValue().equals(e.getChargeTimeType()) && e.isLoanCharge())
|
||||
.findFirst();
|
||||
|
||||
if (penaltyCharge.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(new OverdueLoanScheduleData(loan.getId(), penaltyCharge.get().getId(),
|
||||
DateUtils.DEFAULT_DATE_FORMATTER.format(installment.getDueDate()), penaltyCharge.get().getAmount(),
|
||||
list.add(new OverdueLoanScheduleData(loan.getId(), penaltyCharge.getId(),
|
||||
DateUtils.DEFAULT_DATE_FORMATTER.format(installment.getDueDate()), penaltyCharge.getAmount(),
|
||||
DateUtils.DEFAULT_DATE_FORMAT, Locale.ENGLISH.toLanguageTag(),
|
||||
installment.getPrincipalOutstanding(loan.getCurrency()).getAmount(),
|
||||
installment.getInterestOutstanding(loan.getCurrency()).getAmount(), installment.getInstallmentNumber()));
|
||||
|
||||
Reference in New Issue
Block a user