diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/WorkingCapitalLoanRequestFactory.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/WorkingCapitalLoanRequestFactory.java index aa98e28365e..fe3d997791f 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/WorkingCapitalLoanRequestFactory.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/WorkingCapitalLoanRequestFactory.java @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.time.format.DateTimeFormatter; import lombok.RequiredArgsConstructor; +import org.apache.fineract.client.models.PostWorkingCapitalLoansLoanIdRequest; import org.apache.fineract.client.models.PostWorkingCapitalLoansRequest; import org.apache.fineract.client.models.PutWorkingCapitalLoansLoanIdRequest; import org.apache.fineract.test.data.workingcapitalproduct.DefaultWorkingCapitalLoanProduct; @@ -64,4 +65,26 @@ public PutWorkingCapitalLoansLoanIdRequest defaultModifyWorkingCapitalLoansReque .locale(DEFAULT_LOCALE)// .dateFormat(DATE_FORMAT);// } + + public PostWorkingCapitalLoansLoanIdRequest defaultWorkingCapitalLoanApproveRequest() { + return new PostWorkingCapitalLoansLoanIdRequest()// + .approvedOnDate(DATE_SUBMIT_STRING)// + .expectedDisbursementDate(DATE_SUBMIT_STRING)// + .approvedLoanAmount(DEFAULT_PRINCIPAL)// + .dateFormat(DATE_FORMAT)// + .locale(DEFAULT_LOCALE);// + } + + public PostWorkingCapitalLoansLoanIdRequest defaultWorkingCapitalLoanRejectRequest() { + return new PostWorkingCapitalLoansLoanIdRequest()// + .rejectedOnDate(DATE_SUBMIT_STRING)// + .dateFormat(DATE_FORMAT)// + .locale(DEFAULT_LOCALE);// + } + + public PostWorkingCapitalLoansLoanIdRequest defaultWorkingCapitalLoanUndoApprovalRequest() { + return new PostWorkingCapitalLoansLoanIdRequest()// + .dateFormat(DATE_FORMAT)// + .locale(DEFAULT_LOCALE);// + } } diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalProductLoanAccountStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalProductLoanAccountStepDef.java index b2bfa2eb7b2..0ebcbc05913 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalProductLoanAccountStepDef.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalProductLoanAccountStepDef.java @@ -29,6 +29,7 @@ import io.cucumber.java.en.When; import java.math.BigDecimal; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; @@ -38,6 +39,8 @@ import org.apache.fineract.client.models.DeleteWorkingCapitalLoansLoanIdResponse; import org.apache.fineract.client.models.GetWorkingCapitalLoansLoanIdResponse; import org.apache.fineract.client.models.PostClientsResponse; +import org.apache.fineract.client.models.PostWorkingCapitalLoansLoanIdRequest; +import org.apache.fineract.client.models.PostWorkingCapitalLoansLoanIdResponse; import org.apache.fineract.client.models.PostWorkingCapitalLoansRequest; import org.apache.fineract.client.models.PostWorkingCapitalLoansResponse; import org.apache.fineract.client.models.PutWorkingCapitalLoansLoanIdRequest; @@ -45,6 +48,7 @@ import org.apache.fineract.test.data.workingcapitalproduct.DefaultWorkingCapitalLoanProduct; import org.apache.fineract.test.data.workingcapitalproduct.WorkingCapitalLoanProductResolver; import org.apache.fineract.test.factory.WorkingCapitalLoanRequestFactory; +import org.apache.fineract.test.helper.Utils; import org.apache.fineract.test.messaging.event.EventCheckHelper; import org.apache.fineract.test.stepdef.AbstractStepDef; import org.apache.fineract.test.support.TestContextKey; @@ -68,18 +72,6 @@ public void createWorkingCapitalLoan(final DataTable table) { createWorkingCapitalLoanAccount(data.get(1)); } - private void createWorkingCapitalLoanAccount(final List loanData) { - final String loanProduct = loanData.get(0); - final Long clientId = extractClientId(); - final Long loanProductId = resolveLoanProductId(loanProduct); - final PostWorkingCapitalLoansRequest loansRequest = buildCreateLoanRequest(clientId, loanProductId, loanData); - - final PostWorkingCapitalLoansResponse response = ok( - () -> fineractClient.workingCapitalLoans().submitWorkingCapitalLoanApplication(loansRequest)); - testContext().set(TestContextKey.LOAN_CREATE_RESPONSE, response); - log.info("Working Capital Loan created with ID: {}", response.getLoanId()); - } - @Then("Working capital loan creation was successful") public void verifyWorkingCapitalLoanCreationSuccess() { final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); @@ -94,48 +86,16 @@ public void verifyWorkingCapitalLoanCreationSuccess() { @Then("Working capital loan account has the correct data:") public void verifyWorkingCapitalLoanAccountData(final DataTable table) { - final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); - final Long loanId = loanResponse.getLoanId(); - - final GetWorkingCapitalLoansLoanIdResponse response = ok( - () -> fineractClient.workingCapitalLoans().retrieveWorkingCapitalLoanById(loanId)); + final Long loanId = getCreatedLoanId(); + final GetWorkingCapitalLoansLoanIdResponse response = retrieveLoanDetails(loanId); final List> data = table.asLists(); - final List expectedData = data.get(1); - - final String expectedProductName = expectedData.get(0); - final String expectedSubmittedOnDate = expectedData.get(1); - final String expectedDisbursementDate = expectedData.get(2); - final String expectedStatus = expectedData.get(3); - final String expectedPrincipal = expectedData.get(4); - final String expectedTotalPayment = expectedData.get(5); - final String expectedPeriodPaymentRate = expectedData.get(6); - final String expectedDiscount = expectedData.get(7); - - assertNotNull(response, "Loan response should not be null"); - assertNotNull(response.getProduct(), "Product should not be null"); - assertThat(response.getProduct().getName()).as("Product name should match").isEqualTo(expectedProductName); - assert response.getSubmittedOnDate() != null; - assertThat(response.getSubmittedOnDate().toString()).as("Submitted on date should match").isEqualTo(expectedSubmittedOnDate); - assertNotNull(response.getDisbursementDetails(), "Disbursement details should be present"); - assertThat(response.getDisbursementDetails()).as("Disbursement details should not be empty").isNotEmpty(); - assertThat(response.getDisbursementDetails().getFirst().getExpectedDisbursementDate().toString()) - .as("Expected disbursement date should match").isEqualTo(expectedDisbursementDate); - assert response.getStatus() != null; - assertThat(response.getStatus().getValue()).as("Status should match").isEqualTo(expectedStatus); - assertNotNull(response.getBalance(), "Balance should be present"); - assertThat(response.getBalance().getPrincipalOutstanding()).as("Principal should match") - .isEqualByComparingTo(new BigDecimal(expectedPrincipal)); - assertThat(response.getBalance().getTotalPayment()).as("Total payment should match") - .isEqualByComparingTo(new BigDecimal(expectedTotalPayment)); - assertThat(response.getPeriodPaymentRate()).as("Period payment rate should match") - .isEqualByComparingTo(new BigDecimal(expectedPeriodPaymentRate)); - - if ("null".equals(expectedDiscount)) { - assertThat(response.getDiscount()).as("Discount should be null").isNull(); - } else { - assertThat(response.getDiscount()).as("Discount should match").isEqualByComparingTo(new BigDecimal(expectedDiscount)); - } + final List header = table.row(0); + final List expectedValues = data.get(1); + + final List actualValues = fetchValuesOfWorkingCapitalLoan(header, response); + + assertThat(actualValues).as("Working capital loan data should match expected values").isEqualTo(expectedValues); log.info("Verified working capital loan account data for loan ID: {}", loanId); } @@ -290,58 +250,26 @@ public void modifyWorkingCapitalLoan(final DataTable table) { modifyWorkingCapitalLoanAccount(data.get(1)); } - private void modifyWorkingCapitalLoanAccount(final List loanData) { - final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); - final Long loanId = loanResponse.getLoanId(); - final PutWorkingCapitalLoansLoanIdRequest modifyRequest = buildModifyLoanRequest(loanData); - - final PutWorkingCapitalLoansLoanIdResponse response = ok( - () -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationById(loanId, modifyRequest, "")); - testContext().set(TestContextKey.LOAN_MODIFY_RESPONSE, response); - log.info("Working Capital Loan modified with ID: {}", response.getResourceId()); - } - @When("Admin modifies the working capital loan by externalId with the following data:") public void modifyWorkingCapitalLoanByExternalId(final DataTable table) { final List> data = table.asLists(); modifyWorkingCapitalLoanAccountByExternalId(data.get(1)); } - private void modifyWorkingCapitalLoanAccountByExternalId(final List loanData) { - final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); - final Long loanId = loanResponse.getLoanId(); - final String externalId = retrieveLoanExternalId(loanId); - final PutWorkingCapitalLoansLoanIdRequest modifyRequest = buildModifyLoanRequest(loanData); - - final PutWorkingCapitalLoansLoanIdResponse response = ok( - () -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationByExternalId(externalId, modifyRequest, "")); - testContext().set(TestContextKey.LOAN_MODIFY_RESPONSE, response); - log.info("Working Capital Loan modified by externalId: {} with resource ID: {}", externalId, response.getResourceId()); - } - @Then("Changing submittedOnDate after expectedDisbursementDate results an error:") public void changingSubmittedOnDateAfterExpectedDisbursementDateResultsAnError(final DataTable table) { final List> data = table.asLists(); final String submittedOnDate = data.get(1).get(0); - final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); - final Long loanId = loanResponse.getLoanId(); - final PutWorkingCapitalLoansLoanIdRequest modifyRequest = workingCapitalLoanRequestFactory.defaultModifyWorkingCapitalLoansRequest() .submittedOnDate(submittedOnDate); final CallFailedRuntimeException exception = fail( - () -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationById(loanId, modifyRequest, "")); + () -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationById(getCreatedLoanId(), modifyRequest, "")); testContext().set(TestContextKey.LOAN_MODIFY_RESPONSE, exception); - log.info("HTTP status code: {}", exception.getStatus()); - - assertThat(exception.getStatus()).as("HTTP status code should be 403").isEqualTo(403); - - log.info( - "Checking for submittedOnDate after expectedDisbursementDate error: submittedOnDate cannot be after expectedDisbursementDate."); - assertThat(exception.getMessage()).as("Should contain submittedOnDate after expectedDisbursementDate error") - .contains("The date on which a loan is submitted cannot be after its expected disbursement date"); + assertHttpStatus(exception, 403); + assertValidationError(exception, "The date on which a loan is submitted cannot be after its expected disbursement date"); log.info("Verified working capital loan modification failed with submittedOnDate after expectedDisbursementDate"); } @@ -352,9 +280,6 @@ public void changingSubmittedOnDateAfterBusinessDateResultsAnError(final DataTab final String submittedOnDate = data.get(1).get(0); final String expectedDisbursementDate = data.get(1).get(1); - final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); - final Long loanId = loanResponse.getLoanId(); - final PutWorkingCapitalLoansLoanIdRequest modifyRequest = workingCapitalLoanRequestFactory.defaultModifyWorkingCapitalLoansRequest() .submittedOnDate(submittedOnDate); if (expectedDisbursementDate != null && !expectedDisbursementDate.isBlank()) { @@ -362,35 +287,21 @@ public void changingSubmittedOnDateAfterBusinessDateResultsAnError(final DataTab } final CallFailedRuntimeException exception = fail( - () -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationById(loanId, modifyRequest, "")); + () -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationById(getCreatedLoanId(), modifyRequest, "")); testContext().set(TestContextKey.LOAN_MODIFY_RESPONSE, exception); - assertThat(exception.getStatus()).as("HTTP status code should be 403").isEqualTo(403); - assertThat(exception.getMessage()).as("Should contain submittedOnDate cannot be in the future error") - .contains("The date on which a loan is submitted cannot be in the future."); + assertHttpStatus(exception, 403); + assertValidationError(exception, "The date on which a loan is submitted cannot be in the future."); } @When("Admin deletes the working capital loan account") public void deleteWorkingCapitalLoanAccount() { - final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); - final Long loanId = loanResponse.getLoanId(); - - final DeleteWorkingCapitalLoansLoanIdResponse response = ok( - () -> fineractClient.workingCapitalLoans().deleteWorkingCapitalLoanApplication(loanId)); - testContext().set(TestContextKey.LOAN_DELETE_RESPONSE, response); - log.info("Working Capital Loan deleted with ID: {}", response.getResourceId()); + deleteLoan(false); } @When("Admin deletes the working capital loan account by externalId") public void deleteWorkingCapitalLoanAccountByExternalId() { - final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); - final Long loanId = loanResponse.getLoanId(); - final String externalId = retrieveLoanExternalId(loanId); - - final DeleteWorkingCapitalLoansLoanIdResponse response = ok( - () -> fineractClient.workingCapitalLoans().deleteWorkingCapitalLoanApplicationByExternalId(externalId)); - testContext().set(TestContextKey.LOAN_DELETE_RESPONSE, response); - log.info("Working Capital Loan deleted by externalId: {} with resource ID: {}", externalId, response.getResourceId()); + deleteLoan(true); } @Then("Working capital loan account deletion was successful") @@ -475,20 +386,160 @@ public void workingCapitalLoanModificationFailsWith404() { log.info("Verified modification failed: non-existent loan ID"); } - private Long getCreatedLoanId() { - final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); - return loanResponse.getLoanId(); + @Then("Working capital loan modification response contains changes for {string}") + public void verifyModificationResponseContainsChanges(final String expectedField) { + final PutWorkingCapitalLoansLoanIdResponse modifyResponse = testContext().get(TestContextKey.LOAN_MODIFY_RESPONSE); + assertThat(modifyResponse).as("Modification response").isNotNull(); + assertThat(modifyResponse.getResourceId()).as("Resource ID").isNotNull(); + + final Object changes = modifyResponse.getChanges(); + assertThat(changes).as("Changes map").isNotNull().isInstanceOf(Map.class); + + @SuppressWarnings("unchecked") + final Map changesMap = (Map) changes; + assertThat(changesMap).as("Changes map should contain key '%s'", expectedField).containsKey(expectedField); + log.info("Verified modification response contains changes for '{}': {}", expectedField, changesMap.get(expectedField)); } - private BigDecimal extractPrincipalFromModifyTable(final DataTable table) { - final Map data = table.asMaps().get(0); - return new BigDecimal(data.get("principalAmount")); + @When("Admin successfully approves the working capital loan on {string} with {string} amount and expected disbursement date on {string}") + public void approveWorkingCapitalLoan(final String approveDate, final String approvedAmount, final String expectedDisbursementDate) { + final PostWorkingCapitalLoansLoanIdRequest approveRequest = workingCapitalLoanRequestFactory + .defaultWorkingCapitalLoanApproveRequest().approvedOnDate(approveDate).approvedLoanAmount(new BigDecimal(approvedAmount)) + .expectedDisbursementDate(expectedDisbursementDate); + + executeStateTransition("approve", approveRequest, TestContextKey.LOAN_APPROVAL_RESPONSE, false); } - private CallFailedRuntimeException failModifyWithPrincipal(final Long loanId, final BigDecimal principal) { - final PutWorkingCapitalLoansLoanIdRequest modifyRequest = workingCapitalLoanRequestFactory.defaultModifyWorkingCapitalLoansRequest() - .principalAmount(principal); - return fail(() -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationById(loanId, modifyRequest, "")); + @When("Admin successfully approves the working capital loan by externalId on {string} with {string} amount and expected disbursement date on {string}") + public void approveWorkingCapitalLoanByExternalId(final String approveDate, final String approvedAmount, + final String expectedDisbursementDate) { + final PostWorkingCapitalLoansLoanIdRequest approveRequest = workingCapitalLoanRequestFactory + .defaultWorkingCapitalLoanApproveRequest().approvedOnDate(approveDate).approvedLoanAmount(new BigDecimal(approvedAmount)) + .expectedDisbursementDate(expectedDisbursementDate); + + executeStateTransition("approve", approveRequest, TestContextKey.LOAN_APPROVAL_RESPONSE, true); + } + + @Then("Working capital loan approval was successful") + public void verifyWorkingCapitalLoanApprovalSuccess() { + verifyStateTransitionSuccess(TestContextKey.LOAN_APPROVAL_RESPONSE, "approval"); + } + + @Then("Approval of working capital loan on {string} with {string} amount and expected disbursement date on {string} results an error with the following data:") + public void approvalOfWorkingCapitalLoanResultsAnError(final String approveDate, final String approvedAmount, + final String expectedDisbursementDate, final DataTable table) { + final PostWorkingCapitalLoansLoanIdRequest approveRequest = workingCapitalLoanRequestFactory + .defaultWorkingCapitalLoanApproveRequest().approvedOnDate(approveDate).approvedLoanAmount(new BigDecimal(approvedAmount)) + .expectedDisbursementDate(expectedDisbursementDate); + + final CallFailedRuntimeException exception = fail(() -> fineractClient.workingCapitalLoans() + .stateTransitionWorkingCapitalLoanById(getCreatedLoanId(), "approve", approveRequest)); + + verifyErrorResponse(exception, table); + log.info("Verified working capital loan approval failed with expected error"); + } + + @When("Admin rejects the working capital loan on {string}") + public void rejectWorkingCapitalLoan(final String rejectDate) { + final PostWorkingCapitalLoansLoanIdRequest rejectRequest = workingCapitalLoanRequestFactory.defaultWorkingCapitalLoanRejectRequest() + .rejectedOnDate(rejectDate); + + executeStateTransition("reject", rejectRequest, TestContextKey.LOAN_REJECT_RESPONSE, false); + } + + @Then("Working capital loan rejection was successful") + public void verifyWorkingCapitalLoanRejectionSuccess() { + verifyStateTransitionSuccess(TestContextKey.LOAN_REJECT_RESPONSE, "rejection"); + } + + @When("Admin makes undo approval on the working capital loan") + public void undoApprovalWorkingCapitalLoan() { + final PostWorkingCapitalLoansLoanIdRequest undoApprovalRequest = workingCapitalLoanRequestFactory + .defaultWorkingCapitalLoanUndoApprovalRequest(); + + executeStateTransition("undoApproval", undoApprovalRequest, TestContextKey.LOAN_UNDO_APPROVAL_RESPONSE, false); + } + + @Then("Working capital loan undo approval was successful") + public void verifyWorkingCapitalLoanUndoApprovalSuccess() { + verifyStateTransitionSuccess(TestContextKey.LOAN_UNDO_APPROVAL_RESPONSE, "undo approval"); + } + + // ==================================== + // Private Helper Methods + // ==================================== + + // Loan Lifecycle Helpers + private void createWorkingCapitalLoanAccount(final List loanData) { + final String loanProduct = loanData.get(0); + final Long clientId = extractClientId(); + final Long loanProductId = resolveLoanProductId(loanProduct); + final PostWorkingCapitalLoansRequest loansRequest = buildCreateLoanRequest(clientId, loanProductId, loanData); + + final PostWorkingCapitalLoansResponse response = ok( + () -> fineractClient.workingCapitalLoans().submitWorkingCapitalLoanApplication(loansRequest)); + testContext().set(TestContextKey.LOAN_CREATE_RESPONSE, response); + log.info("Working Capital Loan created with ID: {}", response.getLoanId()); + } + + private void modifyWorkingCapitalLoanAccount(final List loanData) { + final PutWorkingCapitalLoansLoanIdRequest modifyRequest = buildModifyLoanRequest(loanData); + + final PutWorkingCapitalLoansLoanIdResponse response = ok( + () -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationById(getCreatedLoanId(), modifyRequest, "")); + testContext().set(TestContextKey.LOAN_MODIFY_RESPONSE, response); + log.info("Working Capital Loan modified with ID: {}", response.getResourceId()); + } + + private void modifyWorkingCapitalLoanAccountByExternalId(final List loanData) { + final Long loanId = getCreatedLoanId(); + final String externalId = retrieveLoanExternalId(loanId); + final PutWorkingCapitalLoansLoanIdRequest modifyRequest = buildModifyLoanRequest(loanData); + + final PutWorkingCapitalLoansLoanIdResponse response = ok( + () -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationByExternalId(externalId, modifyRequest, "")); + testContext().set(TestContextKey.LOAN_MODIFY_RESPONSE, response); + log.info("Working Capital Loan modified by externalId: {} with resource ID: {}", externalId, response.getResourceId()); + } + + private void deleteLoan(final boolean useExternalId) { + final Long loanId = getCreatedLoanId(); + + final DeleteWorkingCapitalLoansLoanIdResponse response; + if (useExternalId) { + final String externalId = retrieveLoanExternalId(loanId); + response = ok(() -> fineractClient.workingCapitalLoans().deleteWorkingCapitalLoanApplicationByExternalId(externalId)); + log.info("Working Capital Loan deleted by externalId: {} with resource ID: {}", externalId, response.getResourceId()); + } else { + response = ok(() -> fineractClient.workingCapitalLoans().deleteWorkingCapitalLoanApplication(loanId)); + log.info("Working Capital Loan deleted with ID: {}", response.getResourceId()); + } + + testContext().set(TestContextKey.LOAN_DELETE_RESPONSE, response); + } + + private void executeStateTransition(final String command, final PostWorkingCapitalLoansLoanIdRequest request, final String responseKey, + final boolean useExternalId) { + final long loanId = getCreatedLoanId(); + + final PostWorkingCapitalLoansLoanIdResponse response; + if (useExternalId) { + final String loanExternalId = retrieveLoanExternalId(loanId); + response = ok(() -> fineractClient.workingCapitalLoans().stateTransitionWorkingCapitalLoanByExternalId(loanExternalId, command, + request)); + log.info("Working Capital Loan with externalId {} {} successful", loanExternalId, command); + } else { + response = ok(() -> fineractClient.workingCapitalLoans().stateTransitionWorkingCapitalLoanById(loanId, command, request)); + log.info("Working Capital Loan {} {} successful", loanId, command); + } + + testContext().set(responseKey, response); + } + + // Data Extraction Helpers + private Long getCreatedLoanId() { + final PostWorkingCapitalLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); + return loanResponse.getLoanId(); } private Long extractClientId() { @@ -501,6 +552,41 @@ private Long resolveLoanProductId(final String loanProductName) { return workingCapitalLoanProductResolver.resolve(product); } + private BigDecimal extractPrincipalFromModifyTable(final DataTable table) { + final Map data = table.asMaps().get(0); + return new BigDecimal(data.get("principalAmount")); + } + + private List fetchValuesOfWorkingCapitalLoan(final List header, final GetWorkingCapitalLoansLoanIdResponse response) { + final List actualValues = new ArrayList<>(); + for (final String headerName : header) { + switch (headerName) { + case "product.name" -> actualValues.add(response.getProduct() == null ? null : response.getProduct().getName()); + case "submittedOnDate" -> + actualValues.add(response.getSubmittedOnDate() == null ? null : response.getSubmittedOnDate().toString()); + case "expectedDisbursementDate" -> + actualValues.add(response.getDisbursementDetails() == null || response.getDisbursementDetails().isEmpty() ? null + : response.getDisbursementDetails().getFirst().getExpectedDisbursementDate().toString()); + case "status" -> actualValues.add(response.getStatus() == null ? null : response.getStatus().getValue()); + case "principal" -> + actualValues.add(response.getBalance() == null || response.getBalance().getPrincipalOutstanding() == null ? null + : new Utils.DoubleFormatter(response.getBalance().getPrincipalOutstanding().doubleValue()).format()); + case "approvedPrincipal" -> actualValues.add(response.getApprovedPrincipal() == null ? "0" + : new Utils.DoubleFormatter(response.getApprovedPrincipal().doubleValue()).format()); + case "totalPayment" -> + actualValues.add(response.getBalance() == null || response.getBalance().getTotalPayment() == null ? null + : new Utils.DoubleFormatter(response.getBalance().getTotalPayment().doubleValue()).format()); + case "periodPaymentRate" -> actualValues.add(response.getPeriodPaymentRate() == null ? null + : new Utils.DoubleFormatter(response.getPeriodPaymentRate().doubleValue()).format()); + case "discount" -> actualValues.add( + response.getDiscount() == null ? "null" : new Utils.DoubleFormatter(response.getDiscount().doubleValue()).format()); + default -> throw new IllegalStateException(String.format("Header name %s cannot be found", headerName)); + } + } + return actualValues; + } + + // Request Builders private PostWorkingCapitalLoansRequest buildCreateLoanRequest(final Long clientId, final Long productId, final List loanData) { final String submittedOnDate = loanData.get(1); final String expectedDisbursementDate = loanData.get(2); @@ -534,12 +620,24 @@ private PutWorkingCapitalLoansLoanIdRequest buildModifyLoanRequest(final List fineractClient.workingCapitalLoans().retrieveWorkingCapitalLoanById(loanId)); + } + private String retrieveLoanExternalId(final Long loanId) { final GetWorkingCapitalLoansLoanIdResponse loanDetails = ok( () -> fineractClient.workingCapitalLoans().retrieveWorkingCapitalLoanById(loanId)); return loanDetails.getExternalId(); } + private CallFailedRuntimeException failModifyWithPrincipal(final Long loanId, final BigDecimal principal) { + final PutWorkingCapitalLoansLoanIdRequest modifyRequest = workingCapitalLoanRequestFactory.defaultModifyWorkingCapitalLoansRequest() + .principalAmount(principal); + return fail(() -> fineractClient.workingCapitalLoans().modifyWorkingCapitalLoanApplicationById(loanId, modifyRequest, "")); + } + + // Assertion Helpers private void assertHttpStatus(final CallFailedRuntimeException exception, final int expectedStatus) { log.info("HTTP status code: {}", exception.getStatus()); assertThat(exception.getStatus()).as("HTTP status code should be " + expectedStatus).isEqualTo(expectedStatus); @@ -550,18 +648,24 @@ private void assertValidationError(final CallFailedRuntimeException exception, f assertThat(exception.getMessage()).as("Should contain validation error").contains(expectedMessage); } - @Then("Working capital loan modification response contains changes for {string}") - public void verifyModificationResponseContainsChanges(final String expectedField) { - final PutWorkingCapitalLoansLoanIdResponse modifyResponse = testContext().get(TestContextKey.LOAN_MODIFY_RESPONSE); - assertThat(modifyResponse).as("Modification response").isNotNull(); - assertThat(modifyResponse.getResourceId()).as("Resource ID").isNotNull(); + private void verifyStateTransitionSuccess(final String responseKey, final String operationName) { + final PostWorkingCapitalLoansLoanIdResponse response = testContext().get(responseKey); - final Object changes = modifyResponse.getChanges(); - assertThat(changes).as("Changes map").isNotNull().isInstanceOf(Map.class); + assertNotNull(response, "Loan " + operationName + " response should not be null"); + assertNotNull(response.getLoanId(), "Loan ID should not be null"); + assertNotNull(response.getResourceId(), "Resource ID should not be null"); + assertTrue(response.getLoanId() > 0, "Loan ID should be greater than 0"); - @SuppressWarnings("unchecked") - final Map changesMap = (Map) changes; - assertThat(changesMap).as("Changes map should contain key '%s'", expectedField).containsKey(expectedField); - log.info("Verified modification response contains changes for '{}': {}", expectedField, changesMap.get(expectedField)); + log.info("Verified working capital loan {} was successful. Loan ID: {}", operationName, response.getLoanId()); + } + + private void verifyErrorResponse(final CallFailedRuntimeException exception, final DataTable table) { + final List> data = table.asLists(); + final String expectedHttpCode = data.get(1).get(0); + final String expectedErrorMessage = data.get(1).get(1); + + assertThat(exception.getStatus()).as("HTTP status code should be " + expectedHttpCode) + .isEqualTo(Integer.parseInt(expectedHttpCode)); + assertThat(exception.getMessage()).as("Should contain error message").contains(expectedErrorMessage); } } diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalProductLoanAccount.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalProductLoanAccount.feature index adea3288f35..c5a0e6dfab4 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalProductLoanAccount.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalProductLoanAccount.feature @@ -7,11 +7,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70251 Scenario: Create Working Capital Loan account - UC2: Create loan with mandatory fields only @@ -19,11 +19,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | null | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | null | @TestRailId:C70252 Scenario: Create Working Capital Loan account - UC3: Create loan with non-default values @@ -31,19 +31,19 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 500 | 1000 | 2 | 5 | + | WCLP | 01 January 2026 | 01 January 2026 | 500.0 | 1000.0 | 2.0 | 5.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 500 | 1000 | 2 | 5 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | 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) 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 | 100 | 1 | 0 |1 |30 |DAYS | + | 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 | @TestRailId:C70254 Scenario: Create Working Capital Loan account - UC5: Create with principal amount greater than WCLP max (Negative) @@ -51,7 +51,7 @@ Feature: WorkingCapitalProduct And Admin creates a client with random data Then Creating a working capital loan with principal amount greater than Working Capital Loan Product max will result an error: | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | WCLP | 01 January 2026 | 01 January 2026 | 1000000 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 1000000.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70255 @@ -60,7 +60,7 @@ Feature: WorkingCapitalProduct And Admin creates a client with random data Then Creating a working capital loan with principal amount smaller than Working Capital Loan Product min will result an error: | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | WCLP | 01 January 2026 | 01 January 2026 | 1 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 1.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70256 Scenario: Create Working Capital Loan account - UC7: Create loan with mandatory field missing (Negative) @@ -68,7 +68,7 @@ Feature: WorkingCapitalProduct And Admin creates a client with random data Then Creating a working capital loan with missing mandatory fields will result an error: | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | WCLP | 01 January 2026 | 01 January 2026 | | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | | 100.0 | 1.0 | 0.0 | @TestRailId:C70257 Scenario: Create Working Capital Loan account - UC8: Create loan with multiple mandatory field missing (Negative) @@ -76,7 +76,7 @@ Feature: WorkingCapitalProduct And Admin creates a client with random data Then Creating a working capital loan with missing mandatory fields will result an error: | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | WCLP | | | | | | 0 | + | WCLP | | | | | | 0.0 | @TestRailId:C70258 Scenario: Modify Working Capital Loan account in Submitted and pending approval state - UC1: Change principal amount (lower) @@ -84,17 +84,17 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | | 80 | | | | + | | | 80.0 | | | | Then Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 80 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 80.0 | 0.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70259 Scenario: Modify Working Capital Loan account in Submitted and pending approval state - UC2: Change principal amount (higher) @@ -102,17 +102,17 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | | 500 | | | | + | | | 500.0 | | | | Then Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 500 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 500.0 | 0.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70260 Scenario: Modify Working Capital Loan account in Submitted and pending approval state - UC3: Change submittedOnDate @@ -120,17 +120,17 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 20 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 20 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | | 15 December 2025 | | | | | | Then Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2025-12-15 | 2026-01-20 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2025-12-15 | 2026-01-20 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70279 Scenario: Modify Working Capital Loan account in Submitted and pending approval state - UC3.1: Change submittedOnDate after business date results an error (Negative) @@ -138,11 +138,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 20 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 20 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | And Changing submittedOnDate after business date results an error: | submittedOnDate | expectedDisbursementDate | | 05 January 2026 | | @@ -153,11 +153,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 20 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 20 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | And Changing submittedOnDate after business date results an error: | submittedOnDate | expectedDisbursementDate | | 05 January 2026 | 25 January 2026 | @@ -168,11 +168,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | And Changing submittedOnDate after expectedDisbursementDate results an error: | submittedOnDate | | 05 January 2026 | @@ -183,11 +183,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 20 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 20 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | | | 25 January 2026 | | | | | @@ -195,8 +195,8 @@ Feature: WorkingCapitalProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | | 05 January 2026 | | | | | | Then Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-05 | 2026-01-25 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-05 | 2026-01-25 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70263 Scenario: Modify Working Capital Loan account in Submitted and pending approval state - UC6: Change submittedOnDate and expectedDisbursementDate in one call @@ -204,17 +204,17 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 20 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 20 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-20 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | | 05 January 2026 | 25 January 2026 | | | | | Then Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-05 | 2026-01-25 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-05 | 2026-01-25 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70264 Scenario: Modify Working Capital Loan account in Submitted and pending approval state - UC7: Change multiple parameters @@ -222,17 +222,17 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | 15 January 2026 | 500 | 500 | 2 | 5 | + | | 15 January 2026 | 500.0 | 500.0 | 2.0 | 5.0 | Then Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-15 | Submitted and pending approval | 500 | 500 | 2 | 5 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-15 | Submitted and pending approval | 500.0 | 0.0 | 500.0 | 2.0 | 5.0 | @TestRailId:C70265 Scenario: Modify Working Capital Loan account in Submitted and pending approval state - UC8: Modify by externalId @@ -240,17 +240,17 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin modifies the working capital loan by externalId with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | 15 January 2026 | 500 | 500 | 2 | 5 | + | | 15 January 2026 | 500.0 | 500.0 | 2.0 | 5.0 | Then Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-15 | Submitted and pending approval | 500 | 500 | 2 | 5 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-15 | Submitted and pending approval | 500.0 | 0.0 | 500.0 | 2.0 | 5.0 | @TestRailId:C70266 Scenario: Delete Working Capital Loan account in Submitted and pending approval state - UC1: Delete loan account by loanId @@ -258,11 +258,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin deletes the working capital loan account Then Working capital loan account deletion was successful @@ -272,11 +272,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | When Admin deletes the working capital loan account by externalId Then Working capital loan account deletion was successful @@ -286,14 +286,14 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 20 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 20 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | | | 25 January 2026 | | | | | Then Working capital loan account has the correct data: | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-25 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | WCLP | 2026-01-01 | 2026-01-25 | Submitted and pending approval | 100.0 | 100.0 | 1.0 | 0.0 | @TestRailId:C70269 Scenario: Modify Working Capital Loan account - UC10: Change totalPayment only @@ -301,14 +301,14 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | | | 500 | | | + | | | | 500.0 | | | Then Working capital loan account has the correct data: | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 500 | 1 | 0 | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 500.0 | 1.0 | 0.0 | @TestRailId:C70270 Scenario: Modify Working Capital Loan account - UC11: Change periodPaymentRate only @@ -316,14 +316,14 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | | | | 3 | | + | | | | | 3.0 | | Then Working capital loan account has the correct data: | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 3 | 0 | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 100.0 | 3.0 | 0.0 | @TestRailId:C70271 Scenario: Modify Working Capital Loan account - UC12: Change discount only @@ -331,14 +331,14 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | | | | | 10 | + | | | | | | 10.0 | Then Working capital loan account has the correct data: | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 10 | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 100.0 | 1.0 | 10.0 | @TestRailId:C70272 Scenario: Modify Working Capital Loan account - UC13: Principal exceeds product max results in an error @@ -346,11 +346,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful Then Modifying the working capital loan with principal exceeding product max results in an error: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | | 1000000 | | | | + | | | 1000000.0 | | | | @TestRailId:C70273 Scenario: Modify Working Capital Loan account - UC14: Principal below product min results in an error @@ -358,11 +358,11 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful Then Modifying the working capital loan with principal below product min results in an error: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | | 1 | | | | + | | | 1.0 | | | | @TestRailId:C70274 Scenario: Modify Working Capital Loan account - UC15: Empty modification request results in an error @@ -370,7 +370,7 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful Then Modifying the working capital loan with empty request results in an error @@ -380,7 +380,7 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful Then Modifying the working capital loan with future submittedOnDate results in an error: | submittedOnDate | expectedDisbursementDate | @@ -397,38 +397,249 @@ Feature: WorkingCapitalProduct 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful When Admin modifies the working capital loan with the following data: | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | | | 500 | | | | + | | | 500.0 | | | | Then Working capital loan modification response contains changes for "principalAmount" And Working capital loan account has the correct data: | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 500 | 100 | 1 | 0 | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 500.0 | 100.0 | 1.0 | 0.0 | -# TODO implement with approval testcases - @Skip @TestRailId:tempApprove - Scenario: Create Working Capital Loan account - UC12: Attempt to modify loan in APPROVED state (Negative) + @TestRailId:C72337 + Scenario: Approve Working Capital Loan account - UC1: Approve loan in SUBMITTED AND PENDING APPROVAL state with default values 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 | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin successfully approves the working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" + Then Working capital loan approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Approved | 100.0 | 100.0 | 100.0 | 1.0 | 0.0 | + + @TestRailId:C72338 + Scenario: Approve Working Capital Loan account - UC2: Approve with modified principal lower than created + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin successfully approves the working capital loan on "01 January 2026" with "80" amount and expected disbursement date on "01 January 2026" + Then Working capital loan approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Approved | 100.0 | 80.0 | 100.0 | 1.0 | 0.0 | + + @TestRailId:C72339 + Scenario: Approve Working Capital Loan account - UC3: Approve with principal greater than created amount results an error (negative) + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + And Approval of working capital loan on "01 January 2026" with "150" amount and expected disbursement date on "01 January 2026" results an error with the following data: + | httpErrorCode | errorMessage | + | 400 | amount.cannot.exceed.proposed.principal | + + @TestRailId:C72340 + Scenario: Approve Working Capital Loan account - UC4: Approve with modified expected disbursement date + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin successfully approves the working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "15 January 2026" + Then Working capital loan approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-15 | Approved | 100.0 | 100.0 | 100.0 | 1.0 | 0.0 | + + @TestRailId:C72341 + Scenario: Approve Working Capital Loan account - UC5: Approve with past approval date results an error (negative) + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + And Approval of working capital loan on "31 December 2025" with "100" amount and expected disbursement date on "01 January 2026" results an error with the following data: + | httpErrorCode | errorMessage | + | 400 | cannot.be.before.submittal.date | + + @TestRailId:C72342 + Scenario: Approve Working Capital Loan account - UC6: Reject loan in SUBMITTED AND PENDING APPROVAL state + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin rejects the working capital loan on "01 January 2026" + Then Working capital loan rejection was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Rejected | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + + @TestRailId:C72343 + Scenario: Approve Working Capital Loan account - UC7: Undo approval returns loan from APPROVED to SUBMITTED AND PENDING APPROVAL + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin successfully approves the working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" + Then Working capital loan approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Approved | 100.0 | 100.0 | 100.0 | 1.0 | 0.0 | + When Admin makes undo approval on the working capital loan + Then Working capital loan undo approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | null | + + @TestRailId:C72344 + Scenario: Approve Working Capital Loan account - UC8: Re-approve after undo approval + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin successfully approves the working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" + Then Working capital loan approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Approved | 100.0 | 100.0 | 100.0 | 1.0 | 0.0 | + When Admin makes undo approval on the working capital loan + Then Working capital loan undo approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | null | + When Admin successfully approves the working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" + Then Working capital loan approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Approved | 100.0 | 100.0 | 100.0 | 1.0 | null | + + @TestRailId:C72345 + Scenario: Approve Working Capital Loan account - UC9: Approve on working capital loan in APPROVED state results an error (negative) + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin successfully approves the working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" + Then Working capital loan approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Approved | 100.0 | 100.0 | 100.0 | 1.0 | 0.0 | + And Approval of working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" results an error with the following data: + | httpErrorCode | errorMessage | + | 400 | Transition LOAN_APPROVED is not allowed from status APPROVED | + + @TestRailId:C72346 + Scenario: Approve Working Capital Loan account - UC10: Approve on working capital loan in REJECTED state results an error (negative) + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin rejects the working capital loan on "01 January 2026" + Then Working capital loan rejection was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Rejected | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + And Approval of working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" results an error with the following data: + | httpErrorCode | errorMessage | + | 400 | Transition LOAN_APPROVED is not allowed from status REJECTED | + + @TestRailId:C72347 + Scenario: Approve Working Capital Loan account - UC11: Approve loan in SUBMITTED AND PENDING APPROVAL state with default values by externalId + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin successfully approves the working capital loan by externalId on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" + Then Working capital loan approval was successful + And Working capital loan account has the correct data: + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Approved | 100.0 | 100.0 | 100.0 | 1.0 | 0.0 | + +# TODO implement with disbursal testcases + @TestRailId:tempDisburse1 + Scenario: Approve Working Capital Loan account - UC8: Undo approval on already-disbursed loan + 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 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | + 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 | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 | + When Admin successfully approves the working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" + Then Working capital loan approval was successful +# When Admin disburses the working capital loan on "01 January 2026" +# Then Working capital loan disbursement was successful +# And Undo approval on the working capital loan results an error with the following data: +# | httpErrorCode | errorMessage | +# | 400 | msg | # TODO implement with disbursal testcases - @Skip @TestRailId:tempDisburse + @Skip @TestRailId:tempDisburse2 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 And Admin creates a working capital loan with the following data: | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | - | WCLP | 01 January 2026 | 01 January 2026 | 100 | 100 | 1 | 0 | + | WCLP | 01 January 2026 | 01 January 2026 | 100.0 | 100.0 | 1.0 | 0.0 | Then Working capital loan creation was successful And Working capital loan account has the correct data: - | product.name | submittedOnDate | expectedDisbursementDate | status | principal | totalPayment | periodPaymentRate | discount | - | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100 | 100 | 1 | 0 | + | product.name | submittedOnDate | expectedDisbursementDate | status | principal | approvedPrincipal | totalPayment | periodPaymentRate | discount | + | WCLP | 2026-01-01 | 2026-01-01 | Submitted and pending approval | 100.0 | 0.0 | 100.0 | 1.0 | 0.0 |