adamsaghy commented on code in PR #6081:
URL: https://github.com/apache/fineract/pull/6081#discussion_r3579290246


##########
fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanCreditBalanceRefund.feature:
##########
@@ -486,3 +486,358 @@ Feature: Working Capital Loan Credit Balance Refund
       | principalOutstanding | 0.00    |
       | overpaymentAmount    | 100.00  |
       | totalPaidPrincipal   | 9000.00 |
+
+  @TestRailId:C85504
+  Scenario: Verify working capital loan credit balance refund match with 
overpaid amount to male loan closed - UC1
+    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 | totalPaymentVolume | periodPaymentRate | discount |
+      | WCLP        | 01 January 2026 | 01 January 2026          | 9000        
    | 100000             | 18                | 0        |
+    And Admin successfully approves the working capital loan on "01 January 
2026" with "9000" amount and expected disbursement date on "01 January 2026"
+    And Admin successfully disburse the Working Capital loan on "01 January 
2026" with "9000" EUR transaction amount
+    When Admin sets the business date to "02 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    And Customer makes repayment on "02 January 2026" with 9050.0 transaction 
amount on Working Capital loan
+    Then Working Capital loan status will be "OVERPAID"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
50.0              |
+    And Working Capital Loan has transactions:
+      | transactionDate | type            | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement    | 9000.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment       | 9050.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+    When Admin sets the business date to "10 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    When Customer makes credit balance refund on "10 January 2026" with 50.0 
transaction amount on Working Capital loan
+    Then Working Capital loan status will be "CLOSED_OBLIGATIONS_MET"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
0.0               |
+    And Working Capital Loan has transactions:
+      | transactionDate | type                  | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement          | 9000.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment             | 9050.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 10 January 2026 | Credit Balance Refund | 50.0              | 50.0     
        | 0.0               | 0.0                   | false    |
+
+  @TestRailId:C85505
+  Scenario: Verify working capital loan credit balance refund backdated less 
then overpaid amount to make loan overpaid - UC2
+    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 | totalPaymentVolume | periodPaymentRate | discount |
+      | WCLP        | 01 January 2026 | 01 January 2026          | 9000        
    | 100000             | 18                | 0        |
+    And Admin successfully approves the working capital loan on "01 January 
2026" with "9000" amount and expected disbursement date on "01 January 2026"
+    And Admin successfully disburse the Working Capital loan on "01 January 
2026" with "9000" EUR transaction amount
+    When Admin sets the business date to "02 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    And Customer makes repayment on "02 January 2026" with 9050.0 transaction 
amount on Working Capital loan
+    Then Working Capital loan status will be "OVERPAID"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
50.0              |
+    And Working Capital Loan has transactions:
+      | transactionDate | type            | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement    | 9000.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment       | 9050.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+    When Admin sets the business date to "10 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    When Customer makes credit balance refund on "10 January 2026" with 30.0 
transaction amount on Working Capital loan
+    Then Working Capital loan status will be "OVERPAID"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
20.0              |
+    And Working Capital Loan has transactions:
+      | transactionDate | type                  | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement          | 9000.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment             | 9050.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 10 January 2026 | Credit Balance Refund | 30.0              | 30.0     
        | 0.0               | 0.0                   | false    |
+
+  @TestRailId:C85506
+  Scenario: Verify working capital loan credit balance refund with backdated 
repayment undo to make loan active - UC3
+    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 | totalPaymentVolume | periodPaymentRate | discount |
+      | WCLP_ACC_DEF_REV_AM | 01 January 2026 | 01 January 2026          | 
9000            | 100000             | 18                | 0        |
+    And Admin successfully approves the working capital loan on "01 January 
2026" with "9000" amount and expected disbursement date on "01 January 2026"
+    And Admin successfully disburse the Working Capital loan on "01 January 
2026" with "9000" EUR transaction amount
+    When Admin sets the business date to "02 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    And Customer makes repayment on "02 January 2026" with 200.0 transaction 
amount on Working Capital loan
+    Then Working Capital loan status will be "ACTIVE"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 200.0              | 0.0            | 0.0              | 
0.0               |
+    And Working Capital Loan has transactions:
+      | transactionDate | type            | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement    | 9000.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment       | 200.0             | 200.0          
  | 0.0               | 0.0                   | false    |
+    When Admin sets the business date to "05 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    And Customer makes repayment on "05 January 2026" with 9100.0 transaction 
amount on Working Capital loan
+    Then Working Capital loan status will be "OVERPAID"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
300.0             |
+    And Working Capital Loan has transactions:
+      | transactionDate | type            | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement    | 9000.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment       | 200.0             | 200.0          
  | 0.0               | 0.0                   | false    |
+      | 05 January 2026 | Repayment       | 9100.0            | 8800.0         
  | 0.0               | 0.0                   | false    |
+    When Admin sets the business date to "10 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    When Customer makes credit balance refund on "10 January 2026" with 300.0 
transaction amount on Working Capital loan
+    Then Working Capital loan status will be "CLOSED_OBLIGATIONS_MET"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
0.0               |
+    And Working Capital Loan has transactions:
+      | transactionDate | type                  | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement          | 9000.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment             | 200.0             | 200.0    
        | 0.0               | 0.0                   | false    |
+      | 05 January 2026 | Repayment             | 9100.0            | 8800.0   
        | 0.0               | 0.0                   | false    |
+      | 10 January 2026 | Credit Balance Refund | 300.0             | 300.0    
        | 0.0               | 0.0                   | false    |
+    And Customer undo "1"th "REPAYMENT" transaction made on "02 January 2026" 
on Working Capital loan
+    Then Working Capital loan status will be "ACTIVE"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9100.0             | 0.0            | 0.0              | 
0.0               |

Review Comment:
   Expectation:
   principal: $9200 ($9000 original + $200 principal adjustment)
   total paid principal: $9000 (it cannot be more than principal due)
   



##########
fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanCreditBalanceRefund.feature:
##########
@@ -486,3 +486,358 @@ Feature: Working Capital Loan Credit Balance Refund
       | principalOutstanding | 0.00    |
       | overpaymentAmount    | 100.00  |
       | totalPaidPrincipal   | 9000.00 |
+
+  @TestRailId:C85504
+  Scenario: Verify working capital loan credit balance refund match with 
overpaid amount to male loan closed - UC1
+    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 | totalPaymentVolume | periodPaymentRate | discount |
+      | WCLP        | 01 January 2026 | 01 January 2026          | 9000        
    | 100000             | 18                | 0        |
+    And Admin successfully approves the working capital loan on "01 January 
2026" with "9000" amount and expected disbursement date on "01 January 2026"
+    And Admin successfully disburse the Working Capital loan on "01 January 
2026" with "9000" EUR transaction amount
+    When Admin sets the business date to "02 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    And Customer makes repayment on "02 January 2026" with 9050.0 transaction 
amount on Working Capital loan
+    Then Working Capital loan status will be "OVERPAID"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
50.0              |
+    And Working Capital Loan has transactions:
+      | transactionDate | type            | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement    | 9000.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment       | 9050.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+    When Admin sets the business date to "10 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    When Customer makes credit balance refund on "10 January 2026" with 50.0 
transaction amount on Working Capital loan
+    Then Working Capital loan status will be "CLOSED_OBLIGATIONS_MET"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
0.0               |
+    And Working Capital Loan has transactions:
+      | transactionDate | type                  | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement          | 9000.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment             | 9050.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 10 January 2026 | Credit Balance Refund | 50.0              | 50.0     
        | 0.0               | 0.0                   | false    |
+
+  @TestRailId:C85505
+  Scenario: Verify working capital loan credit balance refund backdated less 
then overpaid amount to make loan overpaid - UC2
+    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 | totalPaymentVolume | periodPaymentRate | discount |
+      | WCLP        | 01 January 2026 | 01 January 2026          | 9000        
    | 100000             | 18                | 0        |
+    And Admin successfully approves the working capital loan on "01 January 
2026" with "9000" amount and expected disbursement date on "01 January 2026"
+    And Admin successfully disburse the Working Capital loan on "01 January 
2026" with "9000" EUR transaction amount
+    When Admin sets the business date to "02 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    And Customer makes repayment on "02 January 2026" with 9050.0 transaction 
amount on Working Capital loan
+    Then Working Capital loan status will be "OVERPAID"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
50.0              |
+    And Working Capital Loan has transactions:
+      | transactionDate | type            | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement    | 9000.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment       | 9050.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+    When Admin sets the business date to "10 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    When Customer makes credit balance refund on "10 January 2026" with 30.0 
transaction amount on Working Capital loan
+    Then Working Capital loan status will be "OVERPAID"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
20.0              |
+    And Working Capital Loan has transactions:
+      | transactionDate | type                  | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement          | 9000.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment             | 9050.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 10 January 2026 | Credit Balance Refund | 30.0              | 30.0     
        | 0.0               | 0.0                   | false    |
+
+  @TestRailId:C85506
+  Scenario: Verify working capital loan credit balance refund with backdated 
repayment undo to make loan active - UC3
+    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 | totalPaymentVolume | periodPaymentRate | discount |
+      | WCLP_ACC_DEF_REV_AM | 01 January 2026 | 01 January 2026          | 
9000            | 100000             | 18                | 0        |
+    And Admin successfully approves the working capital loan on "01 January 
2026" with "9000" amount and expected disbursement date on "01 January 2026"
+    And Admin successfully disburse the Working Capital loan on "01 January 
2026" with "9000" EUR transaction amount
+    When Admin sets the business date to "02 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    And Customer makes repayment on "02 January 2026" with 200.0 transaction 
amount on Working Capital loan
+    Then Working Capital loan status will be "ACTIVE"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 200.0              | 0.0            | 0.0              | 
0.0               |
+    And Working Capital Loan has transactions:
+      | transactionDate | type            | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement    | 9000.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment       | 200.0             | 200.0          
  | 0.0               | 0.0                   | false    |
+    When Admin sets the business date to "05 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    And Customer makes repayment on "05 January 2026" with 9100.0 transaction 
amount on Working Capital loan
+    Then Working Capital loan status will be "OVERPAID"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
300.0             |
+    And Working Capital Loan has transactions:
+      | transactionDate | type            | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement    | 9000.0            | 9000.0         
  | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment       | 200.0             | 200.0          
  | 0.0               | 0.0                   | false    |
+      | 05 January 2026 | Repayment       | 9100.0            | 8800.0         
  | 0.0               | 0.0                   | false    |
+    When Admin sets the business date to "10 January 2026"
+    When Admin runs inline COB job for Working Capital Loan
+    When Customer makes credit balance refund on "10 January 2026" with 300.0 
transaction amount on Working Capital loan
+    Then Working Capital loan status will be "CLOSED_OBLIGATIONS_MET"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9000.0             | 0.0            | 0.0              | 
0.0               |
+    And Working Capital Loan has transactions:
+      | transactionDate | type                  | transactionAmount | 
principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
+      | 01 January 2026 | Disbursement          | 9000.0            | 9000.0   
        | 0.0               | 0.0                   | false    |
+      | 02 January 2026 | Repayment             | 200.0             | 200.0    
        | 0.0               | 0.0                   | false    |
+      | 05 January 2026 | Repayment             | 9100.0            | 8800.0   
        | 0.0               | 0.0                   | false    |
+      | 10 January 2026 | Credit Balance Refund | 300.0             | 300.0    
        | 0.0               | 0.0                   | false    |
+    And Customer undo "1"th "REPAYMENT" transaction made on "02 January 2026" 
on Working Capital loan
+    Then Working Capital loan status will be "ACTIVE"
+    And Working capital loan account has the correct data:
+      | principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | 
overpaymentAmount |
+      | 9000.0    | 9100.0             | 0.0            | 0.0              | 
0.0               |

Review Comment:
   **Expectation:**
   principal: $9200 ($9000 original + $200 principal adjustment)
   total paid principal: $9000 (it cannot be more than principal due)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to