Skip to content
Open
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 @@ -21,6 +21,9 @@
public enum DefaultWorkingCapitalLoanProduct implements WorkingCapitalLoanProduct {

WCLP, //
WCLP_DISCOUNT, //
WCLP_DISALLOW_ATTRIBUTES_OVERRIDE, //
WCLP_DISCOUNT_DISALLOW_ATTRIBUTES_OVERRIDE, ///
WCLP_FOR_UPDATE; //

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ public PostWorkingCapitalLoanProductsRequest defaultWorkingCapitalLoanProductReq
List.of(PENALTY, FEE, PRINCIPAL))));//
}

public PostWorkingCapitalLoanProductsRequest defaultWorkingCapitalLoanProductAllowAttributesOverrideRequest() {
String name = Utils.randomStringGenerator(WCLP_NAME_PREFIX, 10);
String shortName = loanProductsRequestFactory.generateShortNameSafely();

PostAllowAttributeOverrides allowAttributeOverrides = new PostAllowAttributeOverrides().delinquencyBucketClassification(true)
.discountDefault(true).periodPaymentFrequencyType(true).periodPaymentFrequency(true);

return defaultWorkingCapitalLoanProductRequest().name(name)//
.shortName(shortName)//
.allowAttributeOverrides(allowAttributeOverrides);
}

public PutWorkingCapitalLoanProductsProductIdRequest defaultWorkingCapitalLoanProductRequestUpdate() {
String name = Utils.randomStringGenerator(WCLP_NAME_PREFIX, 10);
String shortName = loanProductsRequestFactory.generateShortNameSafely();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public void creatingWorkingCapitalLoanWithLpOverridablesDisabledWillResultAnErro
assertValidationError(exception, "validation.msg.WORKINGCAPITALLOAN.delinquencyBucketId.override.not.allowed.by.product");
assertValidationError(exception, "validation.msg.WORKINGCAPITALLOAN.repaymentEvery.override.not.allowed.by.product");
assertValidationError(exception, "validation.msg.WORKINGCAPITALLOAN.repaymentFrequencyType.override.not.allowed.by.product");
assertValidationError(exception, "validation.msg.WORKINGCAPITALLOAN.discount.override.not.allowed.by.product");

log.info("Verified working capital loan creation failed with expected validation errors for LP overridables disabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ public abstract class TestContextKey {
public static final String OFFICE_CREATE_RESPONSE = "officeCreateResponse";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_ADVANCED_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_VERTICAL_INTEREST_RECALC = "loanProductCreateResponseLP2DownPaymentAdvancedPaymentAllocationProgressiveLoanScheduleVerticalInterestRecalc";
public static final String DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_WCLP = "workingCapitalLoanProductCreateResponseWCLP";
public static final String DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_WCLP_DISCOUNT = "workingCapitalLoanProductCreateResponseWCLPDiscount";
public static final String DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_WCLP_DISALLOW_OVERRIDES = "workingCapitalLoanProductCreateResponseWCLPDisallowOverrides";
public static final String DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_WCLP_DISCOUNT_DISALLOW_OVERRIDES = "workingCapitalLoanProductCreateResponseWCLPDiscountDisallowOverrides";
public static final String WC_LOAN_IDS = "wcLoanIds";
public static final String DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_REQUEST_FOR_UPDATE_WCLP = "workingCapitalLoanProductCreateRequestForUpdateWCLP";
public static final String DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_FOR_UPDATE_WCLP = "workingCapitalLoanProductCreateResponseForUpdateWCLP";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

import static org.apache.fineract.client.feign.util.FeignCalls.ok;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetWorkingCapitalLoanProductsResponse;
import org.apache.fineract.client.models.PostAllowAttributeOverrides;
import org.apache.fineract.client.models.PostWorkingCapitalLoanProductsRequest;
import org.apache.fineract.client.models.PostWorkingCapitalLoanProductsResponse;
import org.apache.fineract.test.data.workingcapitalproduct.DefaultWorkingCapitalLoanProduct;
Expand All @@ -47,11 +49,46 @@ public void initialize() throws Exception {

final String workingCapitalProductDefaultName = DefaultWorkingCapitalLoanProduct.WCLP.getName();
final PostWorkingCapitalLoanProductsRequest defaultWCPLRequest = workingCapitalRequestFactory
.defaultWorkingCapitalLoanProductRequest() //
.defaultWorkingCapitalLoanProductAllowAttributesOverrideRequest() //
.name(workingCapitalProductDefaultName); //
final PostWorkingCapitalLoanProductsResponse responseDefaultWCPL = createWorkingCapitalLoanProductIdempotent(defaultWCPLRequest);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_WCLP, responseDefaultWCPL);

final String workingCapitalProductDiscountDefaultName = DefaultWorkingCapitalLoanProduct.WCLP_DISCOUNT.getName();
final PostWorkingCapitalLoanProductsRequest defaultWCPLPDiscountRequest = workingCapitalRequestFactory
.defaultWorkingCapitalLoanProductAllowAttributesOverrideRequest() //
.name(workingCapitalProductDiscountDefaultName) //
.discount(new BigDecimal(50)); //
final PostWorkingCapitalLoanProductsResponse responseDefaultWCPLDiscount = createWorkingCapitalLoanProductIdempotent(
defaultWCPLPDiscountRequest);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_WCLP_DISCOUNT,
responseDefaultWCPLDiscount);

final String workingCapitalProductDisallowOverridesDefaultName = DefaultWorkingCapitalLoanProduct.WCLP_DISALLOW_ATTRIBUTES_OVERRIDE
.getName();
final PostWorkingCapitalLoanProductsRequest defaultWCPLDisallowOverridesRequest = workingCapitalRequestFactory
.defaultWorkingCapitalLoanProductRequest() //
.name(workingCapitalProductDisallowOverridesDefaultName); //
final PostWorkingCapitalLoanProductsResponse responseDefaultWCPLDisallowOverrides = createWorkingCapitalLoanProductIdempotent(
defaultWCPLDisallowOverridesRequest);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_WCLP_DISALLOW_OVERRIDES,
responseDefaultWCPLDisallowOverrides);

final String workingCapitalProductDiscountDisallowOverridesDefaultName = DefaultWorkingCapitalLoanProduct.WCLP_DISCOUNT_DISALLOW_ATTRIBUTES_OVERRIDE
.getName();
PostAllowAttributeOverrides allowAttributeOverridesDisabled = new PostAllowAttributeOverrides()
.delinquencyBucketClassification(false).discountDefault(false).periodPaymentFrequencyType(false)
.periodPaymentFrequency(false);
final PostWorkingCapitalLoanProductsRequest defaultWCPLDiscountDisallowOverridesRequest = workingCapitalRequestFactory
.defaultWorkingCapitalLoanProductRequest() //
.name(workingCapitalProductDiscountDisallowOverridesDefaultName) //
.discount(new BigDecimal(50)) //
.allowAttributeOverrides(allowAttributeOverridesDisabled); //
final PostWorkingCapitalLoanProductsResponse responseDefaultWCPLDiscountDisallowOverrides = createWorkingCapitalLoanProductIdempotent(
defaultWCPLDiscountDisallowOverridesRequest);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT_CREATE_RESPONSE_WCLP_DISCOUNT_DISALLOW_OVERRIDES,
responseDefaultWCPLDiscountDisallowOverrides);

final String workingCapitalProductForUpdateName = DefaultWorkingCapitalLoanProduct.WCLP_FOR_UPDATE.getName();
final PostWorkingCapitalLoanProductsRequest defaultForUpdateWCPLRequest = workingCapitalRequestFactory
.defaultWorkingCapitalLoanProductRequest() //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@WorkingCapitalProductFeature
Feature: WorkingCapitalProduct
@WorkingCapitalLoanAccountFeature
Feature: WorkingCapitalLoanAccount

@TestRailId:C70250
Scenario: Create Working Capital Loan account - UC1: Create loan with all fields (LP overridables disabled)
Expand Down Expand Up @@ -38,12 +38,36 @@ Feature: WorkingCapitalProduct
| WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 500.0 | 0.0 | 1000.0 | 2.0 | 5.0 |

@TestRailId:C70253
Scenario: Create Working Capital Loan account - UC4: With LP overridables disabled, loan creation will result an error when trying override values (Negative)
Scenario: Create Working Capital Loan account - UC4: With LP overridables disabled/disallowed, loan creation will result an error when trying override values (Negative)
When Admin sets the business date to "01 January 2026"
And Admin creates a client with random data
Then Creating a working capital loan with LP overridables disabled and with the following data will result an error:
| LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | delinquencyBucketId | repaymentEvery | repaymentFrequencyType |
| WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | 1 | 30 | DAYS |
| LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | delinquencyBucketId | repaymentEvery | repaymentFrequencyType |
| WCLP_DISALLOW_ATTRIBUTES_OVERRIDE | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | 1 | 30 | DAYS |

@TestRailId:C74453
Scenario: Create Working Capital Loan account - UC4.1: With LP overridables enabled/allowed, loan creation will override discount value
When Admin sets the business date to "01 January 2026"
And Admin creates a client with random data
And Admin creates a working capital loan with the following data:
| LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | delinquencyBucketId | repaymentEvery | repaymentFrequencyType |
| WCLP_DISCOUNT | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 2.0 | 60.0 | 1 | 1 | MONTHS |
Then Working capital loan creation was successful
And Working capital loan account has the correct data:
| product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount |
| WCLP_DISCOUNT | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 2.0 | 60.0 |

@TestRailId:C74479
Scenario: Create Working Capital Loan account - UC4.2: With LP overridables disabled/disallowed, loan created with discount amount from loan product level
When Admin sets the business date to "01 January 2026"
And Admin creates a client with random data
And Admin creates a working capital loan with the following data:
| LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | delinquencyBucketId | repaymentEvery | repaymentFrequencyType |
| WCLP_DISCOUNT_DISALLOW_ATTRIBUTES_OVERRIDE | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | | 1 | 30 | DAYS |
Then Working capital loan creation was successful
And Working capital loan account has the correct data:
| product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount |
| WCLP_DISCOUNT_DISALLOW_ATTRIBUTES_OVERRIDE | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 50.0 |

@TestRailId:C70254
Scenario: Create Working Capital Loan account - UC5: Create with principal amount greater than WCLP max (Negative)
Expand All @@ -53,7 +77,6 @@ Feature: WorkingCapitalProduct
| LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount |
| WCLP | 01 January 2026 | 01 January 2026 | 1000000.0 | 100.0 | 1.0 | 0.0 |


@TestRailId:C70255
Scenario: Create Working Capital Loan account - UC6: Create with principal amount smaller than WCLP min (Negative)
When Admin sets the business date to "01 January 2026"
Expand Down Expand Up @@ -638,7 +661,7 @@ Feature: WorkingCapitalProduct
And Admin creates a Working Capital Loan Product with delinquencyGraceDays 3 and delinquencyStartType "LOAN_CREATION" for loan test
And Admin creates a working capital loan with the grace days product and the following data:
| submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | 0 |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | |
Then Working capital loan creation was successful
And Working capital loan account has delinquencyGraceDays 3 and delinquencyStartType "LOAN_CREATION"

Expand All @@ -649,7 +672,7 @@ Feature: WorkingCapitalProduct
And Admin creates a Working Capital Loan Product with delinquencyGraceDays 3 and delinquencyStartType "LOAN_CREATION" for loan test
And Admin creates a working capital loan with grace days override and the following data:
| submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | delinquencyGraceDays | delinquencyStartType |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | 0 | 7 | DISBURSEMENT |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | | 7 | DISBURSEMENT |
Then Working capital loan creation was successful
And Working capital loan account has delinquencyGraceDays 7 and delinquencyStartType "DISBURSEMENT"

Expand All @@ -660,7 +683,7 @@ Feature: WorkingCapitalProduct
And Admin creates a Working Capital Loan Product with delinquencyGraceDays 3 and delinquencyStartType "DISBURSEMENT" for loan test
And Admin creates a working capital loan with grace days override and the following data:
| submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | delinquencyGraceDays | delinquencyStartType |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | 0 | 0 | LOAN_CREATION |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | | 0 | LOAN_CREATION |
Then Working capital loan creation was successful
And Working capital loan account has delinquencyGraceDays 0 and delinquencyStartType "LOAN_CREATION"

Expand All @@ -671,7 +694,7 @@ Feature: WorkingCapitalProduct
And Admin creates a Working Capital Loan Product with delinquencyGraceDays 3 and delinquencyStartType "LOAN_CREATION" for loan test
And Admin creates a working capital loan with the grace days product and the following data:
| submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | 0 |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | |
Then Working capital loan creation was successful
When Admin modifies the working capital loan with grace days:
| delinquencyGraceDays | delinquencyStartType |
Expand All @@ -685,7 +708,7 @@ Feature: WorkingCapitalProduct
And Admin creates a Working Capital Loan Product with delinquencyGraceDays 5 and delinquencyStartType "DISBURSEMENT" for loan test
And Admin creates a working capital loan with the grace days product and the following data:
| submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | 0 |
| 01 January 2027 | 01 January 2027 | 100 | 100 | 1 | |
Then Working capital loan creation was successful
When Admin approves the working capital loan on "01 January 2027"
Then Working capital loan account has delinquencyGraceDays 5 and delinquencyStartType "DISBURSEMENT"
Expand All @@ -704,8 +727,7 @@ Feature: WorkingCapitalProduct
And Admin creates a Working Capital Loan Product with delinquencyGraceDays 3 and delinquencyStartType "LOAN_CREATION" for loan test
Then Creating a working capital loan with invalid delinquencyStartType "INVALID" will result with status code 400

# TODO implement with disbursal testcases
@Skip @TestRailId:C72368
@TestRailId:C72368
Scenario: Create Working Capital Loan account - UC13: Attempt to modify loan in DISBURSED state (Negative)
When Admin sets the business date to "01 January 2026"
And Admin creates a client with random data
Expand Down
Loading
Loading