galovics commented on code in PR #2542:
URL: https://github.com/apache/fineract/pull/2542#discussion_r955724749
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java:
##########
@@ -115,11 +114,11 @@ public void setup() {
this.systemTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE);
}
- @AfterEach
- public void tearDown() {
-
GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(requestSpec,
responseSpec);
-
GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(requestSpec,
responseSpec);
- }
+ // @AfterEach
Review Comment:
Accidental?
##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/ApplyChargeToOverdueLoansBusinessStep.java:
##########
@@ -32,26 +31,21 @@
@Component
@RequiredArgsConstructor
+@Slf4j
public class ApplyChargeToOverdueLoansBusinessStep implements
LoanCOBBusinessStep {
- private final ConfigurationDomainService configurationDomainService;
private final LoanReadPlatformService loanReadPlatformService;
private final LoanWritePlatformService loanWritePlatformService;
@Override
- public Loan execute(Loan input) {
- final Long penaltyWaitPeriodValue =
configurationDomainService.retrievePenaltyWaitPeriod();
- final Boolean backdatePenalties =
configurationDomainService.isBackdatePenaltiesEnabled();
- final Collection<OverdueLoanScheduleData>
overdueLoanScheduledInstallments = loanReadPlatformService
-
.retrieveAllLoansWithOverdueInstallments(penaltyWaitPeriodValue,
backdatePenalties);
- // TODO: this is very much not effective to get all overdue
installments for each loan, a new method needs to be
- // implemented for it
- Map<Long, List<OverdueLoanScheduleData>> groupedOverdueData =
overdueLoanScheduledInstallments.stream()
-
.collect(Collectors.groupingBy(OverdueLoanScheduleData::getLoanId));
- for (Long loanId : groupedOverdueData.keySet()) {
- loanWritePlatformService.applyOverdueChargesForLoan(input.getId(),
groupedOverdueData.get(loanId));
- }
- return input;
+ public Loan execute(Loan loan) {
+ log.info("-------STARTED--------{}",
LocalDateTime.now(ZoneId.systemDefault()));
Review Comment:
I guess these were left in accidentally.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java:
##########
@@ -1558,6 +1560,42 @@ public Collection<OverdueLoanScheduleData>
retrieveAllLoansWithOverdueInstallmen
return this.jdbcTemplate.query(sqlBuilder.toString(), rm,
penaltyWaitPeriod, penaltyWaitPeriod);
}
+ @Override
+ public Collection<OverdueLoanScheduleData>
retrieveAllOverdueInstallmentsForLoan(final Loan loan) {
+ Collection<OverdueLoanScheduleData> list = new ArrayList<>();
+
+ if (!loan.isOpen()) {
+ return list;
+ }
+ final Long penaltyWaitPeriod =
configurationDomainService.retrievePenaltyWaitPeriod();
+ final boolean backdatePenalties =
configurationDomainService.isBackdatePenaltiesEnabled();
+
+ for (LoanRepaymentScheduleInstallment installment :
loan.getRepaymentScheduleInstallments()) {
+ if (installment.isObligationsMet() ||
installment.isRecalculatedInterestComponent()) {
+ continue;
+ }
+
+ if
(installment.isOverdueOn(DateUtils.getBusinessLocalDate().plusDays(penaltyWaitPeriod)))
{
+ if (!backdatePenalties
+ &&
installment.getDueDate().compareTo(DateUtils.getBusinessLocalDate().plusDays(penaltyWaitPeriod
+ 1)) < 0) {
+ continue;
+ }
+ Optional<Charge> penaltyCharge =
loan.getLoanProduct().getLoanProductCharges().stream()
+ .filter((e) -> e.getChargeTimeType() == 9 &&
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(),
+ DateUtils.DEFAULT_DATE_FORMAT, "en_GB",
installment.getPrincipalOutstanding(loan.getCurrency()).getAmount(),
Review Comment:
en_GB, could we reuse this from the Locale class?
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java:
##########
@@ -1558,6 +1560,42 @@ public Collection<OverdueLoanScheduleData>
retrieveAllLoansWithOverdueInstallmen
return this.jdbcTemplate.query(sqlBuilder.toString(), rm,
penaltyWaitPeriod, penaltyWaitPeriod);
}
+ @Override
+ public Collection<OverdueLoanScheduleData>
retrieveAllOverdueInstallmentsForLoan(final Loan loan) {
+ Collection<OverdueLoanScheduleData> list = new ArrayList<>();
+
+ if (!loan.isOpen()) {
+ return list;
+ }
+ final Long penaltyWaitPeriod =
configurationDomainService.retrievePenaltyWaitPeriod();
+ final boolean backdatePenalties =
configurationDomainService.isBackdatePenaltiesEnabled();
+
+ for (LoanRepaymentScheduleInstallment installment :
loan.getRepaymentScheduleInstallments()) {
+ if (installment.isObligationsMet() ||
installment.isRecalculatedInterestComponent()) {
+ continue;
+ }
+
+ if
(installment.isOverdueOn(DateUtils.getBusinessLocalDate().plusDays(penaltyWaitPeriod)))
{
+ if (!backdatePenalties
+ &&
installment.getDueDate().compareTo(DateUtils.getBusinessLocalDate().plusDays(penaltyWaitPeriod
+ 1)) < 0) {
+ continue;
+ }
+ Optional<Charge> penaltyCharge =
loan.getLoanProduct().getLoanProductCharges().stream()
Review Comment:
Is there a way we could extract this magic number (the 9) into a constant or
reuse it from somewhere?
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java:
##########
@@ -1558,6 +1560,42 @@ public Collection<OverdueLoanScheduleData>
retrieveAllLoansWithOverdueInstallmen
return this.jdbcTemplate.query(sqlBuilder.toString(), rm,
penaltyWaitPeriod, penaltyWaitPeriod);
}
+ @Override
+ public Collection<OverdueLoanScheduleData>
retrieveAllOverdueInstallmentsForLoan(final Loan loan) {
+ Collection<OverdueLoanScheduleData> list = new ArrayList<>();
+
+ if (!loan.isOpen()) {
+ return list;
+ }
+ final Long penaltyWaitPeriod =
configurationDomainService.retrievePenaltyWaitPeriod();
+ final boolean backdatePenalties =
configurationDomainService.isBackdatePenaltiesEnabled();
+
+ for (LoanRepaymentScheduleInstallment installment :
loan.getRepaymentScheduleInstallments()) {
+ if (installment.isObligationsMet() ||
installment.isRecalculatedInterestComponent()) {
+ continue;
+ }
+
+ if
(installment.isOverdueOn(DateUtils.getBusinessLocalDate().plusDays(penaltyWaitPeriod)))
{
+ if (!backdatePenalties
+ &&
installment.getDueDate().compareTo(DateUtils.getBusinessLocalDate().plusDays(penaltyWaitPeriod
+ 1)) < 0) {
Review Comment:
Would be nice to extract this compareTo condition into a variable with a
proper name to better understand what it means.
--
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]