You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2022/08/25 21:39:07 UTC
[GitHub] [fineract] adamsaghy opened a new pull request, #2542: FINERACT-1678: Performance improvement of Apply Charge to Overdue Loans COB Business Step
adamsaghy opened a new pull request, #2542:
URL: https://github.com/apache/fineract/pull/2542
## Description
Describe the changes made and why they were made.
Ignore if these details are present on the associated [Apache Fineract JIRA ticket](https://github.com/apache/fineract/pull/1284).
## Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
- [ ] Write the commit message as per https://github.com/apache/fineract/#pull-requests
- [ ] Acknowledge that we will not review PRs that are not passing the build _("green")_ - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
- [ ] Create/update unit or integration tests for verifying the changes made.
- [ ] Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
- [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
- [ ] Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)
FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] adamsaghy commented on pull request #2542: FINERACT-1678: Performance improvement of Apply Charge to Overdue Loans COB Business Step
Posted by GitBox <gi...@apache.org>.
adamsaghy commented on PR #2542:
URL: https://github.com/apache/fineract/pull/2542#issuecomment-1228169948
@galovics Yeah... i wanted this only my repo... its half done...just wanted to see how the tests go... :D
I guess i should not work around midnight :D
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] galovics commented on a diff in pull request #2542: FINERACT-1678: Performance improvement of Apply Charge to Overdue Loans COB Business Step
Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] galovics merged pull request #2542: FINERACT-1678: Performance improvement of Apply Charge to Overdue Loans COB Business Step
Posted by GitBox <gi...@apache.org>.
galovics merged PR #2542:
URL: https://github.com/apache/fineract/pull/2542
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org