Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FINERACT-2081: Skip loan processing if no overdue #4066

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ Feature: COBFeature
When Admin successfully disburse the loan on "01 July 2023" with "1000" EUR transaction amount
Then Loan status will be "ACTIVE"
Then Admin checks that last closed business date of loan is "null"
When Admin sets the business date to "10 August 2023"
When Admin sets the business date to "09 August 2023"
When Admin runs inline COB job for Loan
Then Admin checks that last closed business date of loan is "09 August 2023"
Then Admin checks that last closed business date of loan is "08 August 2023"
Then Admin checks that delinquency range is: "RANGE_3" and has delinquentDate "2023-08-03"
Then Loan delinquency history has the following details:
| Range (Classification) | Added on date | Lifted on date |
| RANGE_3 | 09 August 2023 | |
| RANGE_1 | 04 August 2023 | 09 August 2023 |
When Admin sets the business date to "12 August 2023"
When Admin runs COB job
Then Admin checks that last closed business date of loan is "09 August 2023"
Then Admin checks that last closed business date of loan is "08 August 2023"
Then Loan delinquency history has the following details:
| Range (Classification) | Added on date | Lifted on date |
| RANGE_3 | 09 August 2023 | |
Expand All @@ -89,21 +89,21 @@ Feature: COBFeature
Then Admin checks that delinquency range is: "RANGE_3" and has delinquentDate "2023-08-03"
Then Loan delinquency history has the following details:
| Range (Classification) | Added on date | Lifted on date |
| RANGE_3 | 09 August 2023 | |
| RANGE_3 | 10 August 2023 | |
| RANGE_1 | 04 August 2023 | 09 August 2023 |
And Customer makes "AUTOPAY" repayment on "10 August 2023" with 1000 EUR transaction amount
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
Then Admin checks that delinquency range is: "NO_DELINQUENCY" and has delinquentDate ""
Then Loan delinquency history has the following details:
| Range (Classification) | Added on date | Lifted on date |
| RANGE_3 | 09 August 2023 | 10 August 2023 |
| RANGE_3 | 10 August 2023 | 10 August 2023 |
| RANGE_1 | 04 August 2023 | 09 August 2023 |
When Admin sets the business date to "11 August 2023"
When Admin runs COB job
Then Admin checks that last closed business date of loan is "09 August 2023"
Then Loan delinquency history has the following details:
| Range (Classification) | Added on date | Lifted on date |
| RANGE_3 | 09 August 2023 | 10 August 2023 |
| RANGE_3 | 10 August 2023 | 10 August 2023 |
| RANGE_1 | 04 August 2023 | 09 August 2023 |


Expand All @@ -121,21 +121,21 @@ Feature: COBFeature
Then Admin checks that delinquency range is: "RANGE_3" and has delinquentDate "2023-08-03"
Then Loan delinquency history has the following details:
| Range (Classification) | Added on date | Lifted on date |
| RANGE_3 | 09 August 2023 | |
| RANGE_3 | 10 August 2023 | |
| RANGE_1 | 04 August 2023 | 09 August 2023 |
And Customer makes "AUTOPAY" repayment on "10 August 2023" with 1200 EUR transaction amount
Then Loan status will be "OVERPAID"
Then Admin checks that delinquency range is: "NO_DELINQUENCY" and has delinquentDate ""
Then Loan delinquency history has the following details:
| Range (Classification) | Added on date | Lifted on date |
| RANGE_3 | 09 August 2023 | 10 August 2023 |
| RANGE_3 | 10 August 2023 | 10 August 2023 |
| RANGE_1 | 04 August 2023 | 09 August 2023 |
When Admin sets the business date to "11 August 2023"
When Admin runs COB job
Then Admin checks that last closed business date of loan is "09 August 2023"
Then Loan delinquency history has the following details:
| Range (Classification) | Added on date | Lifted on date |
| RANGE_3 | 09 August 2023 | 10 August 2023 |
| RANGE_3 | 10 August 2023 | 10 August 2023 |
| RANGE_1 | 04 August 2023 | 09 August 2023 |

@Skip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Feature: LoanDelinquency
When Admin sets the business date to "01 October 2023"
When Admin creates a client with random data
When Admin creates a fully customized loan with the following data:
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LP2_DOWNPAYMENT_AUTO_ADVANCED_PAYMENT_ALLOCATION | 01 October 2023 | 1000 | 0 | FLAT | SAME_AS_REPAYMENT_PERIOD | EQUAL_INSTALLMENTS | 45 | DAYS | 15 | DAYS | 3 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
And Admin successfully approves the loan on "01 October 2023" with "1000" amount and expected disbursement date on "01 October 2023"
When Admin successfully disburse the loan on "01 October 2023" with "1000" EUR transaction amount
Expand Down Expand Up @@ -625,11 +625,7 @@ Feature: LoanDelinquency
| PAUSE | 15 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_3 | 250.0 | 04 October 2023 | 11 | 14 |
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
Then Installment level delinquency event has correct data
| NO_DELINQUENCY | 250.0 | 04 October 2023 | 11 | 14 |
# --- Delinquency resume ---
When Admin sets the business date to "25 October 2023"
When Admin initiate a DELINQUENCY RESUME with startDate: "25 October 2023"
Expand All @@ -647,11 +643,7 @@ Feature: LoanDelinquency
| RESUME | 25 October 2023 | |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_3 | 500.0 | 04 October 2023 | 12 | 25 |
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
Then Installment level delinquency event has correct data
| NO_DELINQUENCY | 500.0 | 04 October 2023 | 12 | 25 |


Scenario: Verify Loan delinquency pause E2E - PAUSE period with RESUME and second PAUSE
Expand All @@ -674,11 +666,7 @@ Feature: LoanDelinquency
| PAUSE | 15 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_3 | 250.0 | 04 October 2023 | 11 | 14 |
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
Then Installment level delinquency event has correct data
| NO_DELINQUENCY | 250.0 | 04 October 2023 | 11 | 14 |
# --- Delinquency resume ---
When Admin sets the business date to "25 October 2023"
When Admin initiate a DELINQUENCY RESUME with startDate: "25 October 2023"
Expand All @@ -696,11 +684,7 @@ Feature: LoanDelinquency
| RESUME | 25 October 2023 | |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_3 | 500.0 | 04 October 2023 | 12 | 25 |
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
Then Installment level delinquency event has correct data
| NO_DELINQUENCY | 500.0 | 04 October 2023 | 12 | 25 |
# --- Delinquency runs ---
When Admin sets the business date to "13 November 2023"
When Admin runs inline COB job for Loan
Expand Down Expand Up @@ -755,10 +739,11 @@ Feature: LoanDelinquency
| PAUSE | 14 November 2023 | 30 November 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_30 | 1000.0 | 04 October 2023 | 31 | 60 |
| RANGE_3 | 1000.0 | 04 October 2023 | 31 | 60 |
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 500.00 |
| 1 | RANGE_1 | 250.00 |
| 2 | RANGE_3 | 250.00 |
| 3 | RANGE_30 | 250.00 |
# --- Delinquency runs again ---
When Admin sets the business date to "01 December 2023"
Expand Down Expand Up @@ -802,12 +787,7 @@ Feature: LoanDelinquency
| PAUSE | 06 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_1 | 250.0 | 04 October 2023 | 2 | 5 |
# --- Grace period applied only on Loan level, not on installment level ---
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
Then Installment level delinquency event has correct data
| NO_DELINQUENCY | 250.0 | 04 October 2023 | 2 | 5 |
# --- Full repayment for late/due date installments ---
When Admin sets the business date to "16 October 2023"
Then Loan Delinquency pause periods has the following data:
Expand All @@ -818,11 +798,7 @@ Feature: LoanDelinquency
| PAUSE | 06 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_1 | 250.0 | 04 October 2023 | 2 | 15 |
# --- Grace period applied only on Loan level, not on installment level ---
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
| NO_DELINQUENCY | 250.0 | 04 October 2023 | 2 | 15 |
And Customer makes "AUTOPAY" repayment on "16 October 2023" with 500 EUR transaction amount
When Admin runs inline COB job for Loan
Then Loan Delinquency pause periods has the following data:
Expand Down Expand Up @@ -857,12 +833,7 @@ Feature: LoanDelinquency
| PAUSE | 06 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_1 | 250.0 | 04 October 2023 | 2 | 5 |
# --- Grace period applied only on Loan level, not on installment level ---
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
Then Installment level delinquency event has correct data
| NO_DELINQUENCY | 250.0 | 04 October 2023 | 2 | 5 |
# --- Full repayment for late/due date installments ---
When Admin sets the business date to "16 October 2023"
Then Loan Delinquency pause periods has the following data:
Expand All @@ -873,11 +844,7 @@ Feature: LoanDelinquency
| PAUSE | 06 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_1 | 250.0 | 04 October 2023 | 2 | 15 |
# --- Grace period applied only on Loan level, not on installment level ---
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
| NO_DELINQUENCY | 250.0 | 04 October 2023 | 2 | 15 |
And Customer makes "AUTOPAY" repayment on "16 October 2023" with 150 EUR transaction amount
When Admin runs inline COB job for Loan
Then Loan Delinquency pause periods has the following data:
Expand Down Expand Up @@ -915,12 +882,7 @@ Feature: LoanDelinquency
| PAUSE | 06 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_1 | 250.0 | 04 October 2023 | 2 | 5 |
# --- Grace period applied only on Loan level, not on installment level ---
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
Then Installment level delinquency event has correct data
| NO_DELINQUENCY | 250.0 | 04 October 2023 | 2 | 5 |
# --- Full repayment for late/due date installments ---
When Admin sets the business date to "16 October 2023"
Then Loan Delinquency pause periods has the following data:
Expand All @@ -931,11 +893,7 @@ Feature: LoanDelinquency
| PAUSE | 06 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_1 | 250.0 | 04 October 2023 | 2 | 15 |
# --- Grace period applied only on Loan level, not on installment level ---
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 250.00 |
| NO_DELINQUENCY | 250.0 | 04 October 2023 | 2 | 15 |
And Customer makes "AUTOPAY" repayment on "16 October 2023" with 250 EUR transaction amount
When Admin runs inline COB job for Loan
Then Loan Delinquency pause periods has the following data:
Expand Down Expand Up @@ -991,7 +949,7 @@ Feature: LoanDelinquency
When Admin sets the business date to "01 October 2023"
When Admin creates a client with random data
When Admin creates a fully customized loan with the following data:
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LP2_DOWNPAYMENT_ADV_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL_INSTALLMENT_LEVEL_DELINQUENCY | 01 October 2023 | 1000 | 0 | FLAT | SAME_AS_REPAYMENT_PERIOD | EQUAL_INSTALLMENTS | 45 | DAYS | 15 | DAYS | 3 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
And Admin successfully approves the loan on "01 October 2023" with "1000" amount and expected disbursement date on "01 October 2023"
When Admin successfully disburse the loan on "01 October 2023" with "1000" EUR transaction amount
Expand Down Expand Up @@ -1034,21 +992,15 @@ Feature: LoanDelinquency
| true | 30 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_3 | 500.0 | 04 October 2023 | 21 | 29 |
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 500.00 |
| NO_DELINQUENCY | 500.0 | 04 October 2023 | 21 | 29 |
When Admin sets the business date to "31 October 2023"
Then Loan Delinquency pause periods has the following data:
| active | pausePeriodStart | pausePeriodEnd |
| false | 25 October 2023 | 30 October 2023 |
| false | 30 October 2023 | 30 October 2023 |
Then Loan has the following LOAN level delinquency data:
| classification | delinquentAmount | delinquentDate | delinquentDays | pastDueDays |
| RANGE_3 | 500.0 | 04 October 2023 | 22 | 30 |
Then Loan has the following INSTALLMENT level delinquency data:
| rangeId | Range | Amount |
| 2 | RANGE_3 | 500.00 |
| NO_DELINQUENCY | 500.0 | 04 October 2023 | 22 | 30 |


Scenario: Verify that creating a loan with Advanced payment allocation with product no Advanced payment allocation set results an error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon
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();
Expand Down
Loading
Loading