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


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java:
##########
@@ -0,0 +1,440 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests;
+
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
+import static 
org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType.BUSINESS_DATE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.builder.ResponseSpecBuilder;
+import io.restassured.http.ContentType;
+import io.restassured.specification.RequestSpecification;
+import io.restassured.specification.ResponseSpecification;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.fineract.client.models.AdvancedPaymentData;
+import org.apache.fineract.client.models.AllowAttributeOverrides;
+import org.apache.fineract.client.models.BusinessDateRequest;
+import org.apache.fineract.client.models.ChargeData;
+import org.apache.fineract.client.models.ChargeToGLAccountMapper;
+import org.apache.fineract.client.models.GetLoanFeeToIncomeAccountMappings;
+import 
org.apache.fineract.client.models.GetLoanPaymentChannelToFundSourceMappings;
+import org.apache.fineract.client.models.GetLoansLoanIdResponse;
+import org.apache.fineract.client.models.PaymentAllocationOrder;
+import org.apache.fineract.client.models.PostLoanProductsRequest;
+import org.apache.fineract.client.models.PostLoanProductsResponse;
+import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
+import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
+import org.apache.fineract.integrationtests.common.BusinessDateHelper;
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
+import org.apache.fineract.integrationtests.common.PaymentTypeHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.fineract.integrationtests.common.accounting.Account;
+import org.apache.fineract.integrationtests.common.accounting.AccountHelper;
+import 
org.apache.fineract.integrationtests.common.accounting.JournalEntryHelper;
+import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
+import org.apache.fineract.integrationtests.common.funds.FundsHelper;
+import org.apache.fineract.integrationtests.common.funds.FundsResourceHandler;
+import 
org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
+import org.apache.fineract.integrationtests.common.loans.LoanProductHelper;
+import 
org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension;
+import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
+import 
org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper;
+import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(LoanTestLifecycleExtension.class)
+public class LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest {
+
+    private static final DateTimeFormatter DATE_FORMATTER = new 
DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter();
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+    private ClientHelper clientHelper;
+    private LoanTransactionHelper loanTransactionHelper;
+    private JournalEntryHelper journalEntryHelper;
+    private AccountHelper accountHelper;
+    private LoanProductHelper loanProductHelper;
+    private PaymentTypeHelper paymentTypeHelper;
+    private final BusinessDateHelper businessDateHelper = new 
BusinessDateHelper();
+    private static final String DATETIME_PATTERN = "dd MMMM yyyy";
+    // asset
+    private Account loansReceivable;
+    private Account interestFeeReceivable;
+    private Account suspenseAccount;
+    private Account fundReceivables;
+    // liability
+    private Account suspenseClearingAccount;
+    private Account overpaymentAccount;
+    // income
+    private Account interestIncome;
+    private Account feeIncome;
+    private Account feeChargeOff;
+    private Account recoveries;
+    private Account interestIncomeChargeOff;
+    // expense
+    private Account creditLossBadDebt;
+    private Account creditLossBadDebtFraud;
+    private Account writtenOff;
+    private Account goodwillExpenseAccount;
+
+    @BeforeEach
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new 
RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.requestSpec.header("Authorization", "Basic " + 
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        this.responseSpec = new 
ResponseSpecBuilder().expectStatusCode(200).build();
+        this.loanTransactionHelper = new 
LoanTransactionHelper(this.requestSpec, this.responseSpec);
+        this.accountHelper = new AccountHelper(this.requestSpec, 
this.responseSpec);
+        this.loanProductHelper = new LoanProductHelper();
+        this.paymentTypeHelper = new PaymentTypeHelper();
+
+        // Asset
+        this.loansReceivable = this.accountHelper.createAssetAccount();
+        this.interestFeeReceivable = this.accountHelper.createAssetAccount();
+        this.suspenseAccount = this.accountHelper.createAssetAccount();
+        this.fundReceivables = this.accountHelper.createAssetAccount();
+
+        // Liability
+        this.suspenseClearingAccount = 
this.accountHelper.createLiabilityAccount();
+        this.overpaymentAccount = this.accountHelper.createLiabilityAccount();
+
+        // income
+        this.interestIncome = this.accountHelper.createIncomeAccount();
+        this.feeIncome = this.accountHelper.createIncomeAccount();
+        this.feeChargeOff = this.accountHelper.createIncomeAccount();
+        this.recoveries = this.accountHelper.createIncomeAccount();
+        this.interestIncomeChargeOff = 
this.accountHelper.createIncomeAccount();
+
+        // expense
+        this.creditLossBadDebt = this.accountHelper.createExpenseAccount();
+        this.creditLossBadDebtFraud = 
this.accountHelper.createExpenseAccount();
+        this.writtenOff = this.accountHelper.createExpenseAccount();
+        this.goodwillExpenseAccount = 
this.accountHelper.createExpenseAccount();
+
+        this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, 
this.responseSpec);
+        this.clientHelper = new ClientHelper(this.requestSpec, 
this.responseSpec);
+    }
+
+    @Test
+    public void testLoanChargeReverseReplayWithAdvancedPaymentStrategy() {

Review Comment:
   Could you please add the following extra test case:
   Submitted on date & Txn date: Sept 1: Disbursed 1000
   Submitted on date & Txn date:Sept 3: Repayment 500
   Submitted on date Sept 4 & Txn date:Sept 2: Add charge
   Outcome:
   Repayment transaction reverse-replayed and pays the charge



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