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


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java:
##########
@@ -233,6 +233,73 @@ public void 
testApplyLoanSpecificDueDatePenaltyWithDisbursementDate() {
 
     }
 
+    @Test
+    public void testApplyAndWaiveInstallmentFee() {
+        GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, 
responseSpec, Boolean.TRUE);
+        final LocalDate todaysDate = Utils.getLocalDateOfTenant();
+        BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, 
BusinessDateType.BUSINESS_DATE, todaysDate);
+
+        // Client and Loan account creation
+        final Integer clientId = ClientHelper.createClient(this.requestSpec, 
this.responseSpec, "01 January 2012");
+        final GetLoanProductsProductIdResponse getLoanProductsProductResponse 
= createLoanProduct(loanTransactionHelper, null);
+        assertNotNull(getLoanProductsProductResponse);
+
+        // Older date to have more than one overdue installment
+        LocalDate transactionDate = todaysDate;
+        String operationDate = Utils.dateFormatter.format(transactionDate);
+        log.info("Operation date {}", transactionDate);
+
+        // Create Loan Account
+        final Integer loanId = createLoanAccount(loanTransactionHelper, 
clientId.toString(),
+                getLoanProductsProductResponse.getId().toString(), 
operationDate, "1", "0");
+
+        // Get loan details
+        GetLoansLoanIdResponse getLoansLoanIdResponse = 
loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
+        validateLoanAccount(getLoansLoanIdResponse, 
Double.valueOf(principalAmount), Double.valueOf("0.00"), false);
+
+        // Apply Loan Charge with specific due date
+        final String feeAmount = "1.500000";
+        String payloadJSON = ChargesHelper.getLoanSpecificInstallmentFeeJSON();
+        final PostChargesResponse postChargesResponse = 
ChargesHelper.createLoanCharge(requestSpec, responseSpec, payloadJSON);
+        assertNotNull(postChargesResponse);
+        final Long chargeId = postChargesResponse.getResourceId();
+        assertNotNull(chargeId);
+
+        float amount = Float.valueOf("5.00");
+        PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse = 
loanTransactionHelper.makeLoanRepayment(operationDate, amount,
+                loanId);
+
+        payloadJSON = 
LoanTransactionHelper.getSpecifiedInstallmentChargesForLoanAsJSON(chargeId.toString(),
 feeAmount);
+        PostLoansLoanIdChargesResponse postLoansLoanIdChargesResponse = 
loanTransactionHelper.addChargeForLoan(loanId, payloadJSON,
+                responseSpec);
+        assertNotNull(postLoansLoanIdChargesResponse);
+        final Long loanChargeId = 
postLoansLoanIdChargesResponse.getResourceId();
+        assertNotNull(loanChargeId);
+
+        getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, 
responseSpec, loanId);
+        validateLoanAccount(getLoansLoanIdResponse, 
Double.valueOf(principalAmount), Double.valueOf("10.00"), false);
+
+        // Waive the Loan Charge
+        final PostLoansLoanIdChargesChargeIdResponse 
postWaiveLoanChargesResponse = 
loanTransactionHelper.applyLoanChargeCommand(loanId,
+                loanChargeId, "waive", Utils.emptyJson());
+        assertNotNull(postWaiveLoanChargesResponse);
+
+        // evaluate the outstanding
+        getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, 
responseSpec, loanId);

Review Comment:
   I dont see any backdated transaction or anything that would trigger a 
reverse-replay :/



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