From f195b0d06e5aad48e8440a1b6f27dc2de42c5fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Soma=20S=C3=B6r=C3=B6s?= Date: Wed, 8 Jul 2026 10:35:26 +0200 Subject: [PATCH 1/2] FINERACT-2455: Working Capital - Delinquency Reset - Start New Period --- ...ngCapitalDelinquencyRescheduleStepDef.java | 10 ++++++ .../WorkingCapitalDelinquencyReset.feature | 23 ++++++++++++ ...anDelinquencyActionApiResourceSwagger.java | 2 ++ .../WorkingCapitalLoanDelinquencyAction.java | 3 ++ ...alLoanDelinquencyRangeScheduleService.java | 3 +- ...anDelinquencyRangeScheduleServiceImpl.java | 21 ++++++++--- ...oanDelinquencyActionParseAndValidator.java | 2 ++ .../module-changelog-master.xml | 1 + ...oan_delinquency_reset_start_new_period.xml | 36 +++++++++++++++++++ 9 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/parts/0057_wc_loan_delinquency_reset_start_new_period.xml diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalDelinquencyRescheduleStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalDelinquencyRescheduleStepDef.java index 7cf55b5b11e..6ed430a1dac 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalDelinquencyRescheduleStepDef.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalDelinquencyRescheduleStepDef.java @@ -144,6 +144,16 @@ public void createUndoResetAction() { executeRescheduleAction(request); } + @When("Admin creates WC delinquency reset action with start new period") + public void createResetActionWithStartNewPeriod() { + final PostWorkingCapitalLoansDelinquencyActionRequest request = new PostWorkingCapitalLoansDelinquencyActionRequest(); + request.setAction("reset"); + request.setLocale("en"); + request.setStartNewPeriod(true); + + executeRescheduleAction(request); + } + @When("Admin creates WC delinquency reschedule action with the following parameters:") public void createRescheduleAction(final DataTable table) { final Map params = table.asMaps().get(0); diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDelinquencyReset.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDelinquencyReset.feature index 557a9980092..e9148df65f0 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDelinquencyReset.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDelinquencyReset.feature @@ -485,3 +485,26 @@ Feature: Working Capital Delinquency Reset Action # --- Close loan --- Then Admin closes the Working Capital loan with a full repayment on "11 April 2026" And Working Capital loan status will be "CLOSED_OBLIGATIONS_MET" + + @TestRailId:TODO_ADD_4 + Scenario: Verify multiple Reset Delinquency Action with start new period + When Admin sets the business date to "01 January 2026" + When Admin creates a client with random data + When Admin creates a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | + | WCLP | 01 January 2026 | 01 January 2026 | 10000 | 10000 | 1 | 0.0 | + When Admin successfully approves the working capital loan on "01 January 2026" with "10000" amount and expected disbursement date on "01 January 2026" + And Admin successfully disburse the Working Capital loan on "01 January 2026" with "10000" EUR transaction amount + + When Admin sets the business date to "15 February 2026" + When Admin runs inline COB job for Working Capital Loan + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | 300 | 0 | 300 | false | + | 2 | 31 January 2026 | 01 March 2026 | 300 | 0 | 300 | | + When Admin creates WC delinquency reset action with start new period + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 14 February 2026 | | | | | + | 3 | 15 February 2026 | 16 March 2026 | 300 | 0 | 300 | | diff --git a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanDelinquencyActionApiResourceSwagger.java b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanDelinquencyActionApiResourceSwagger.java index 1adefce0323..f92b31edecd 100644 --- a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanDelinquencyActionApiResourceSwagger.java +++ b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanDelinquencyActionApiResourceSwagger.java @@ -48,6 +48,8 @@ private PostWorkingCapitalLoansDelinquencyActionRequest() {} public String dateFormat; @Schema(example = "en") public String locale; + @Schema(example = "false") + public Boolean startNewPeriod; } @Schema(description = "PostWorkingCapitalLoansDelinquencyActionResponse") diff --git a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/domain/WorkingCapitalLoanDelinquencyAction.java b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/domain/WorkingCapitalLoanDelinquencyAction.java index c9eea2cdbbd..d1fe8051dd3 100644 --- a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/domain/WorkingCapitalLoanDelinquencyAction.java +++ b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/domain/WorkingCapitalLoanDelinquencyAction.java @@ -71,4 +71,7 @@ public class WorkingCapitalLoanDelinquencyAction extends AbstractAuditableWithUT @Column(name = "frequency_type") private DelinquencyFrequencyType frequencyType; + @Column(name = "start_new_period") + private Boolean startNewPeriod = false; + } diff --git a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanDelinquencyRangeScheduleService.java b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanDelinquencyRangeScheduleService.java index 8bf8796db1e..252f1596ea3 100644 --- a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanDelinquencyRangeScheduleService.java +++ b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanDelinquencyRangeScheduleService.java @@ -24,12 +24,13 @@ import org.apache.fineract.portfolio.workingcapitalloan.data.WorkingCapitalLoanDelinquencyRangeScheduleData; import org.apache.fineract.portfolio.workingcapitalloan.domain.WorkingCapitalLoan; import org.apache.fineract.portfolio.workingcapitalloan.domain.WorkingCapitalLoanDelinquencyAction; +import org.apache.fineract.portfolio.workingcapitalloan.domain.WorkingCapitalLoanDelinquencyRangeSchedule; public interface WorkingCapitalLoanDelinquencyRangeScheduleService { void generateInitialPeriod(WorkingCapitalLoan loan); - void generateNextPeriodIfNeeded(WorkingCapitalLoan loan, LocalDate businessDate); + List generateNextPeriodIfNeeded(WorkingCapitalLoan loan, LocalDate businessDate); boolean hasSchedule(Long loanId); diff --git a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanDelinquencyRangeScheduleServiceImpl.java b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanDelinquencyRangeScheduleServiceImpl.java index b5fad3a3bf4..747e48ec69c 100644 --- a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanDelinquencyRangeScheduleServiceImpl.java +++ b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanDelinquencyRangeScheduleServiceImpl.java @@ -94,16 +94,17 @@ public boolean hasSchedule(Long loanId) { } @Override - public void generateNextPeriodIfNeeded(WorkingCapitalLoan loan, LocalDate businessDate) { + public List generateNextPeriodIfNeeded(WorkingCapitalLoan loan, LocalDate businessDate) { + List result = new ArrayList<>(); final DelinquencyMinimumPaymentPeriodAndRule rule = getMinimumPaymentRule(loan); if (rule == null) { - return; + return result; } final Optional latestPeriodOpt = loanDelinquencyRangeScheduleRepository .findTopByLoanIdOrderByPeriodNumberDesc(loan.getId()); if (latestPeriodOpt.isEmpty() || latestPeriodOpt.get().getToDate().isAfter(businessDate)) { - return; + return result; } final EffectiveDelinquencyRescheduleParams params = resolveEffectiveRescheduleParams(loan.getId(), rule); @@ -118,8 +119,10 @@ public void generateNextPeriodIfNeeded(WorkingCapitalLoan loan, LocalDate busine applyRecordedPauses(nextPeriod, loan); latestPeriod = loanDelinquencyRangeScheduleRepository.saveAndFlush(nextPeriod); + result.add(latestPeriod); log.debug("Generated next delinquency range schedule period {} for WC loan {}", nextPeriod.getPeriodNumber(), loan.getId()); } + return result; } @Override @@ -365,8 +368,16 @@ public void resetPeriods(WorkingCapitalLoan loan, WorkingCapitalLoanDelinquencyA LocalDate resetDate = action.getStartDate(); final List periods = loanDelinquencyRangeScheduleRepository - .findByLoanIdAndResetIsNotAndToDateBeforeOrderByPeriodNumberAsc(loan.getId(), true, action.getStartDate()); - periods.forEach(p1 -> resetPeriod(p1, resetDate)); + .findByLoanIdOrderByPeriodNumberAsc(loan.getId()); + if (action.getStartNewPeriod() != null && action.getStartNewPeriod() + && !periods.getLast().getFromDate().isEqual(action.getStartDate())) { + periods.getLast().setToDate(action.getStartDate().minusDays(1)); + List newPeriods = generateNextPeriodIfNeeded(loan, action.getStartDate()); + periods.addAll(newPeriods); + } + + periods.stream().filter(p -> !Objects.equals(p.getReset(), true) && p.getToDate().isBefore(action.getStartDate())) + .forEach(p1 -> resetPeriod(p1, resetDate)); } private void resetPeriod(WorkingCapitalLoanDelinquencyRangeSchedule period, LocalDate resetDate) { diff --git a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/validator/WorkingCapitalLoanDelinquencyActionParseAndValidator.java b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/validator/WorkingCapitalLoanDelinquencyActionParseAndValidator.java index e98d3ca4381..a489e1a2ca9 100644 --- a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/validator/WorkingCapitalLoanDelinquencyActionParseAndValidator.java +++ b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/validator/WorkingCapitalLoanDelinquencyActionParseAndValidator.java @@ -61,6 +61,7 @@ public class WorkingCapitalLoanDelinquencyActionParseAndValidator extends ParseA private static final String MINIMUM_PAYMENT_TYPE = "minimumPaymentType"; private static final String FREQUENCY = "frequency"; private static final String FREQUENCY_TYPE = "frequencyType"; + private static final String START_NEW_PERIOD = "startNewPeriod"; private final FromJsonHelper jsonHelper; private final WorkingCapitalLoanDelinquencyRangeScheduleRepository rangeScheduleRepository; @@ -271,6 +272,7 @@ private WorkingCapitalLoanDelinquencyAction parseCommand(final JsonCommand comma action.setStartDate(extractDate(json, START_DATE)); } else if (DelinquencyAction.RESET.equals(action.getAction())) { action.setStartDate(extractDate(json, START_DATE)); + action.setStartNewPeriod(jsonHelper.extractBooleanNamed(START_NEW_PERIOD, json)); } else if (DelinquencyAction.UNDO_RESET.equals(action.getAction())) { action.setStartDate(extractDate(json, START_DATE)); } diff --git a/fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/module-changelog-master.xml b/fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/module-changelog-master.xml index 2b814c7b43c..eef83d8525e 100644 --- a/fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/module-changelog-master.xml +++ b/fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/module-changelog-master.xml @@ -78,4 +78,5 @@ + diff --git a/fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/parts/0057_wc_loan_delinquency_reset_start_new_period.xml b/fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/parts/0057_wc_loan_delinquency_reset_start_new_period.xml new file mode 100644 index 00000000000..9f25d19eb4b --- /dev/null +++ b/fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/parts/0057_wc_loan_delinquency_reset_start_new_period.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + From 6cff522dc022f664667b2fccafc014273c0bfaa3 Mon Sep 17 00:00:00 2001 From: Peter Kovacs Date: Mon, 20 Jul 2026 14:00:13 +0200 Subject: [PATCH 2/2] FINERACT-2455: Working Capital Loan - Delinquency Reset - Start New Period - E2E tests --- .../WorkingCapitalDelinquencyReset.feature | 195 +++++++++++++++++- 1 file changed, 187 insertions(+), 8 deletions(-) diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDelinquencyReset.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDelinquencyReset.feature index e9148df65f0..70cac6f9cdf 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDelinquencyReset.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDelinquencyReset.feature @@ -486,25 +486,204 @@ Feature: Working Capital Delinquency Reset Action Then Admin closes the Working Capital loan with a full repayment on "11 April 2026" And Working Capital loan status will be "CLOSED_OBLIGATIONS_MET" - @TestRailId:TODO_ADD_4 - Scenario: Verify multiple Reset Delinquency Action with start new period + @TestRailId:C89749 + Scenario: Verify Working Capital delinquency reset / delinquency reset undo - UC9: delinquency reset with start new period When Admin sets the business date to "01 January 2026" - When Admin creates a client with random data - When Admin creates a working capital loan with the following data: + And Admin creates a client with random data + And Admin creates a working capital loan with the following data: | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | | WCLP | 01 January 2026 | 01 January 2026 | 10000 | 10000 | 1 | 0.0 | - When Admin successfully approves the working capital loan on "01 January 2026" with "10000" amount and expected disbursement date on "01 January 2026" + And Admin successfully approves the working capital loan on "01 January 2026" with "10000" amount and expected disbursement date on "01 January 2026" And Admin successfully disburse the Working Capital loan on "01 January 2026" with "10000" EUR transaction amount - - When Admin sets the business date to "15 February 2026" - When Admin runs inline COB job for Working Capital Loan +# --- Initial state --- + And Admin sets the business date to "15 February 2026" + And Admin runs inline COB job for Working Capital Loan Then WC loan delinquency range schedule has the following periods: | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | | 1 | 01 January 2026 | 30 January 2026 | 300 | 0 | 300 | false | | 2 | 31 January 2026 | 01 March 2026 | 300 | 0 | 300 | | +# --- Delinquency reset with start new period --- When Admin creates WC delinquency reset action with start new period Then WC loan delinquency range schedule has the following periods: | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | | 1 | 01 January 2026 | 30 January 2026 | | | | | | 2 | 31 January 2026 | 14 February 2026 | | | | | | 3 | 15 February 2026 | 16 March 2026 | 300 | 0 | 300 | | + + @TestRailId:C89750 + Scenario: Verify Working Capital delinquency reset / delinquency reset undo - UC10: 2 installments overdue and backdated payments with start new period + When Admin sets the business date to "01 January 2026" + And Admin creates a client with random data + And Admin creates WC Delinquency Bucket with frequency 30 DAYS and minimumPayment 25 PERCENTAGE + And Admin creates a new Working Capital Loan Product with delinquency bucket + And Admin creates a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | + | WCLP_DELINQUENCY | 01 January 2026 | 01 January 2026 | 800 | 800 | 1 | 0.0 | + And Admin successfully approves the working capital loan on "01 January 2026" with "800" amount and expected disbursement date on "01 January 2026" + And Admin successfully disburse the Working Capital loan on "01 January 2026" with "800" EUR transaction amount +# --- Backdated payments covering period 1 fully and period 2 partially --- + When Admin sets the business date to "25 January 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Customer makes repayment on "25 January 2026" with 200.0 transaction amount on Working Capital loan + When Admin sets the business date to "20 February 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Customer makes repayment on "20 February 2026" with 100.0 transaction amount on Working Capital loan + When Admin sets the business date to "15 April 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | 200 | 200 | 0 | true | + | 2 | 31 January 2026 | 01 March 2026 | 200 | 100 | 100 | false | + | 3 | 02 March 2026 | 31 March 2026 | 200 | 0 | 200 | false | + | 4 | 01 April 2026 | 30 April 2026 | 200 | 0 | 200 | | +# --- Delinquency reset with start new period at 15 April 2026 --- + When Admin creates WC delinquency reset action with start new period + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 01 March 2026 | | | | | + | 3 | 02 March 2026 | 31 March 2026 | | | | | + | 4 | 01 April 2026 | 14 April 2026 | | | | | + | 5 | 15 April 2026 | 14 May 2026 | 200 | 0 | 200 | | + When Admin sets the business date to "16 May 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 01 March 2026 | | | | | + | 3 | 02 March 2026 | 31 March 2026 | | | | | + | 4 | 01 April 2026 | 14 April 2026 | | | | | + | 5 | 15 April 2026 | 14 May 2026 | 200 | 0 | 200 | false | + | 6 | 15 May 2026 | 13 June 2026 | 200 | 0 | 200 | | +# --- Backdated repayment applied against the still-open period (5) created after reset --- + When Admin sets the business date to "20 May 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Customer makes repayment on "20 May 2026" with 150.0 transaction amount on Working Capital loan + When Admin sets the business date to "14 June 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 01 March 2026 | | | | | + | 3 | 02 March 2026 | 31 March 2026 | | | | | + | 4 | 01 April 2026 | 14 April 2026 | | | | | + | 5 | 15 April 2026 | 14 May 2026 | 200 | 150 | 50 | false | + | 6 | 15 May 2026 | 13 June 2026 | 200 | 0 | 200 | false | + | 7 | 14 June 2026 | 13 July 2026 | 200 | 0 | 200 | | +# --- Backdated payment into an already reset period has no effect on the delinquency schedule --- + And Customer makes repayment on "01 March 2026" with 100.0 transaction amount on Working Capital loan + When Admin sets the business date to "17 June 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 01 March 2026 | | | | | + | 3 | 02 March 2026 | 31 March 2026 | | | | | + | 4 | 01 April 2026 | 14 April 2026 | | | | | + | 5 | 15 April 2026 | 14 May 2026 | 200 | 150 | 50 | false | + | 6 | 15 May 2026 | 13 June 2026 | 200 | 0 | 200 | false | + | 7 | 14 June 2026 | 13 July 2026 | 200 | 0 | 200 | | + + @TestRailId:C89751 + Scenario: Verify Working Capital delinquency reset / delinquency reset undo - UC11: overpaid and overdue installments with start new period + When Admin sets the business date to "01 January 2026" + And Admin creates a client with random data + And Admin creates WC Delinquency Bucket with frequency 30 DAYS and minimumPayment 25 PERCENTAGE + And Admin creates a new Working Capital Loan Product with delinquency bucket + And Admin creates a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | + | WCLP_DELINQUENCY | 01 January 2026 | 01 January 2026 | 800 | 800 | 1 | 0.0 | + And Admin successfully approves the working capital loan on "01 January 2026" with "800" amount and expected disbursement date on "01 January 2026" + And Admin successfully disburse the Working Capital loan on "01 January 2026" with "800" EUR transaction amount +# --- Period 1 overpaid, period 2 partially paid --- + When Admin sets the business date to "25 January 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Customer makes repayment on "25 January 2026" with 300.0 transaction amount on Working Capital loan + When Admin sets the business date to "20 February 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Customer makes repayment on "20 February 2026" with 50.0 transaction amount on Working Capital loan + When Admin sets the business date to "15 April 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | 200 | 300 | 0 | true | + | 2 | 31 January 2026 | 01 March 2026 | 200 | 50 | 150 | false | + | 3 | 02 March 2026 | 31 March 2026 | 200 | 0 | 200 | false | + | 4 | 01 April 2026 | 30 April 2026 | 200 | 0 | 200 | | +# --- Delinquency reset with start new period at 15 April 2026 --- + When Admin creates WC delinquency reset action with start new period + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 01 March 2026 | | | | | + | 3 | 02 March 2026 | 31 March 2026 | | | | | + | 4 | 01 April 2026 | 14 April 2026 | | | | | + | 5 | 15 April 2026 | 14 May 2026 | 200 | 0 | 200 | | + When Admin sets the business date to "16 May 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 01 March 2026 | | | | | + | 3 | 02 March 2026 | 31 March 2026 | | | | | + | 4 | 01 April 2026 | 14 April 2026 | | | | | + | 5 | 15 April 2026 | 14 May 2026 | 200 | 0 | 200 | false | + | 6 | 15 May 2026 | 13 June 2026 | 200 | 0 | 200 | | + When Admin sets the business date to "15 June 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 01 March 2026 | | | | | + | 3 | 02 March 2026 | 31 March 2026 | | | | | + | 4 | 01 April 2026 | 14 April 2026 | | | | | + | 5 | 15 April 2026 | 14 May 2026 | 200 | 0 | 200 | false | + | 6 | 15 May 2026 | 13 June 2026 | 200 | 0 | 200 | false | + | 7 | 14 June 2026 | 13 July 2026 | 200 | 0 | 200 | | + + @TestRailId:C89752 + Scenario: Verify Working Capital delinquency reset / delinquency reset undo - UC12: delinquency pause followed by reset with start new period + When Admin sets the business date to "01 January 2026" + And Admin creates a client with random data + And Admin creates WC Delinquency Bucket with frequency 30 DAYS and minimumPayment 25 PERCENTAGE + And Admin creates a new Working Capital Loan Product with delinquency bucket + And Admin creates a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | + | WCLP_DELINQUENCY | 01 January 2026 | 01 January 2026 | 800 | 800 | 1 | 0.0 | + And Admin successfully approves the working capital loan on "01 January 2026" with "800" amount and expected disbursement date on "01 January 2026" + And Admin successfully disburse the Working Capital loan on "01 January 2026" with "800" EUR transaction amount +# --- Period 1 fully paid, period 2 partially paid --- + When Admin sets the business date to "25 January 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Customer makes repayment on "25 January 2026" with 200.0 transaction amount on Working Capital loan + When Admin sets the business date to "20 February 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Customer makes repayment on "20 February 2026" with 100.0 transaction amount on Working Capital loan + When Admin sets the business date to "20 March 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | 200 | 200 | 0 | true | + | 2 | 31 January 2026 | 01 March 2026 | 200 | 100 | 100 | false | + | 3 | 02 March 2026 | 31 March 2026 | 200 | 0 | 200 | | +# --- 10-day delinquency pause starting on the current business date --- + And Admin initiate a Working Capital loan delinquency pause with startDate "20 March 2026" and endDate "29 March 2026" + When Admin sets the business date to "11 April 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | 200 | 200 | 0 | true | + | 2 | 31 January 2026 | 01 March 2026 | 200 | 100 | 100 | false | + | 3 | 02 March 2026 | 10 April 2026 | 200 | 0 | 200 | false | + | 4 | 11 April 2026 | 10 May 2026 | 200 | 0 | 200 | | +# --- Delinquency reset with start new period at 15 April 2026 --- + When Admin sets the business date to "15 April 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Admin creates WC delinquency reset action with start new period + Then WC loan delinquency range schedule has the following periods: + | periodNumber | fromDate | toDate | expectedAmount | paidAmount | outstandingAmount | minPaymentCriteriaMet | + | 1 | 01 January 2026 | 30 January 2026 | | | | | + | 2 | 31 January 2026 | 01 March 2026 | | | | | + | 3 | 02 March 2026 | 10 April 2026 | | | | | + | 4 | 11 April 2026 | 14 April 2026 | | | | | + | 5 | 15 April 2026 | 14 May 2026 | 200 | 0 | 200 | | \ No newline at end of file