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


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java:
##########
@@ -4106,6 +4108,184 @@ public void uc137() {
         });
     }
 
+    @Test
+    public void 
testChargebackTransactionForProgressiveWithLoanAdvancedPaymentAllocationStrategyAndChargebackAllocation()
 {
+        runAt("15 January 2023", () -> {
+            Integer numberOfRepayments = 4;
+            double amount = 1000.0;
+            String loanDisbursementDate = "1 January 2023";
+
+            Long clientId = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+
+            LOG.info("------------------------------CREATING NEW LOAN PRODUCT 
---------------------------------------");
+            PostLoanProductsResponse loanProductResponse = loanProductHelper
+                    
.createLoanProduct(createOnePeriod30DaysLongNoInterestPeriodicAccrualProductWithAdvancedPaymentAllocation()
+                            
.addCreditAllocationItem(createChargebackAllocation())
+                            
.loanScheduleType(LoanScheduleType.PROGRESSIVE.toString()));
+
+            Long loanId = 
applyAndApproveLoanProgressiveAdvancedPaymentAllocationStrategyMonthlyRepayments(clientId,
+                    loanProductResponse.getResourceId(), numberOfRepayments, 
loanDisbursementDate, amount);
+
+            verifyRepaymentSchedule(loanId, //
+                    installment(1000.0, null, "01 January 2023"), //
+                    installment(250.0, false, "01 February 2023"), //
+                    installment(250.0, false, "01 March 2023"), //
+                    installment(250.0, false, "01 April 2023"), //
+                    installment(250.0, false, "01 May 2023") //
+            );
+
+            loanTransactionHelper.disburseLoan(loanId, new 
PostLoansLoanIdRequest().actualDisbursementDate("1 January 2023")
+                    
.dateFormat(DATETIME_PATTERN).transactionAmount(BigDecimal.valueOf(1000.0)).locale("en"));
+
+            verifyTransactions(loanId, //
+                    transaction(1000.0, "Disbursement", "01 January 2023") //
+            );
+
+            addCharge(loanId, true, 25, "1 January 2023");
+
+            verifyRepaymentSchedule(loanId, //
+                    installment(1000.0, null, "01 January 2023"), //
+                    installment(250.0, 0, 0, 25, 275.0, false, "01 February 
2023", 750.0), //
+                    installment(250.0, false, "01 March 2023"), //
+                    installment(250.0, false, "01 April 2023"), //
+                    installment(250.0, false, "01 May 2023") //
+            );
+
+            Long repayment1TransactionId = addRepaymentForLoan(loanId, 265.0, 
"2 January 2023");
+
+            assertNotNull(repayment1TransactionId);
+
+            verifyTransactions(loanId, //
+                    transaction(1000.0, "Disbursement", "01 January 2023"), //
+                    transaction(265.0, "Repayment", "02 January 2023") //
+            );
+
+            verifyRepaymentSchedule(loanId, //
+                    installment(1000.0, null, "01 January 2023"), //
+                    installment(250.0, 0, 0, 25, 10.0, false, "01 February 
2023", 750.0), //
+                    installment(250.0, false, "01 March 2023"), //
+                    installment(250.0, false, "01 April 2023"), //
+                    installment(250.0, false, "01 May 2023") //
+            );
+
+            Long repayment2TransactionId = addRepaymentForLoan(loanId, 250.0, 
"3 January 2023");
+
+            assertNotNull(repayment2TransactionId);
+
+            verifyTransactions(loanId, //
+                    transaction(1000.0, "Disbursement", "01 January 2023"), //
+                    transaction(265.0, "Repayment", "02 January 2023"), //

Review Comment:
   It would be better if you are checking the allocations as well:
   `transactions(265.0, "Repayment", "02 January 2023", 760.0, 240.0, 0.0, 0.0, 
25.0, 0.0, 0.0)`



-- 
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