DeathGun44 commented on code in PR #6084:
URL: https://github.com/apache/fineract/pull/6084#discussion_r3525517259
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanCreditBalanceRefundandRepaymentTypeIntegrationTest.java:
##########
@@ -520,296 +501,266 @@ public void
paymentRefundWillCloseTheLoanCorrectly(LoanProductTestBuilder loanPr
@ParameterizedTest
@MethodSource("loanProductFactory")
public void
newGoodwillCreditCreatesCorrectJournalEntriesForPeriodicAccrualsTest(LoanProductTestBuilder
loanProductTestBuilder) {
-
- disburseLoanOfAccountingRule(ACCRUAL_PERIODIC, loanProductTestBuilder);
- HashMap loanSummaryMap =
this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec,
disbursedLoanID);
-
- // pay off all of principal, interest (no fees or penalties)
- final Float principalOutstanding = (Float)
loanSummaryMap.get("principalOutstanding");
- final Float interestOutstanding = (Float)
loanSummaryMap.get("interestOutstanding");
- final Float totalOutstanding = (Float)
loanSummaryMap.get("totalOutstanding");
- final Float overpaidAmount = 159.00f;
- final Float goodwillAmount = totalOutstanding + overpaidAmount;
- final Float goodwillAmountInExpense = principalOutstanding +
overpaidAmount;
- final String goodwillDate = "09 January 2022";
- HashMap loanStatusHashMap = (HashMap)
this.loanTransactionHelper.makeRepaymentTypePayment(GOODWILL_CREDIT,
goodwillDate,
- goodwillAmount, this.disbursedLoanID, "");
-
- // only a single credit for principal and interest as test sets up
same GL account for both (summed up)
- this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount,
goodwillDate,
- new JournalEntry(totalOutstanding,
JournalEntry.TransactionType.CREDIT));
-
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount,
goodwillDate,
- new JournalEntry(overpaidAmount,
JournalEntry.TransactionType.CREDIT));
-
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount,
goodwillDate,
- new JournalEntry(goodwillAmountInExpense,
JournalEntry.TransactionType.DEBIT));
-
+ runJanuary2022(() -> {
+ disburseLoanOfAccountingRule(ACCRUAL_PERIODIC,
loanProductTestBuilder);
+ GetLoansLoanIdSummary loanSummary =
getLoanDetails(disbursedLoanID).getSummary();
+
+ final Float principalOutstanding =
Utils.getDoubleValue(loanSummary.getPrincipalOutstanding()).floatValue();
+ final Float interestOutstanding =
Utils.getDoubleValue(loanSummary.getInterestOutstanding()).floatValue();
+ final Float totalOutstanding =
Utils.getDoubleValue(loanSummary.getTotalOutstanding()).floatValue();
+ final Float overpaidAmount = 159.00f;
+ final Float goodwillAmount = totalOutstanding + overpaidAmount;
+ final Float goodwillAmountInExpense = principalOutstanding +
overpaidAmount;
+ final String goodwillDate = "09 January 2022";
+ makeRepaymentTypePayment(GOODWILL_CREDIT, goodwillDate,
goodwillAmount.doubleValue(), disbursedLoanID);
+
+
checkJournalEntryForAssetAccount(getAccounts().getLoansReceivableAccount(),
goodwillDate,
+ journalEntry(totalOutstanding,
getAccounts().getLoansReceivableAccount(), "CREDIT"));
+
checkJournalEntryForLiabilityAccount(getAccounts().getOverpaymentAccount(),
goodwillDate,
+ journalEntry(overpaidAmount,
getAccounts().getOverpaymentAccount(), "CREDIT"));
+
checkJournalEntryForExpenseAccount(getAccounts().getGoodwillExpenseAccount(),
goodwillDate,
+ journalEntry(goodwillAmountInExpense,
getAccounts().getGoodwillExpenseAccount(), "DEBIT"));
+ });
}
@ParameterizedTest
@MethodSource("loanProductFactory")
public void
newGoodwillCreditCreatesCorrectJournalEntriesForCashAccountingTest(LoanProductTestBuilder
loanProductTestBuilder) {
-
- disburseLoanOfAccountingRule(CASH_BASED, loanProductTestBuilder);
- HashMap loanSummaryMap =
this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec,
disbursedLoanID);
-
- // pay off all of principal, interest (no fees or penalties)
- final Float principalOutstanding = (Float)
loanSummaryMap.get("principalOutstanding");
- final Float interestOutstanding = (Float)
loanSummaryMap.get("interestOutstanding");
- final Float totalOutstanding = (Float)
loanSummaryMap.get("totalOutstanding");
- final Float overpaidAmount = 159.00f;
- final Float goodwillAmount = totalOutstanding + overpaidAmount;
- final Float goodwillAmountInExpense = principalOutstanding +
overpaidAmount;
- final String goodwillDate = "09 January 2022";
- HashMap loanStatusHashMap = (HashMap)
this.loanTransactionHelper.makeRepaymentTypePayment(GOODWILL_CREDIT,
goodwillDate,
- goodwillAmount, this.disbursedLoanID, "");
-
- this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount,
goodwillDate,
- new JournalEntry(principalOutstanding,
JournalEntry.TransactionType.CREDIT));
-
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount,
goodwillDate,
- new JournalEntry(interestOutstanding,
JournalEntry.TransactionType.CREDIT));
-
-
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount,
goodwillDate,
- new JournalEntry(overpaidAmount,
JournalEntry.TransactionType.CREDIT));
-
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount,
goodwillDate,
- new JournalEntry(goodwillAmountInExpense,
JournalEntry.TransactionType.DEBIT));
-
+ runJanuary2022(() -> {
+ disburseLoanOfAccountingRule(CASH_BASED, loanProductTestBuilder);
+ GetLoansLoanIdSummary loanSummary =
getLoanDetails(disbursedLoanID).getSummary();
+
+ final Float principalOutstanding =
Utils.getDoubleValue(loanSummary.getPrincipalOutstanding()).floatValue();
+ final Float interestOutstanding =
Utils.getDoubleValue(loanSummary.getInterestOutstanding()).floatValue();
+ final Float totalOutstanding =
Utils.getDoubleValue(loanSummary.getTotalOutstanding()).floatValue();
+ final Float overpaidAmount = 159.00f;
+ final Float goodwillAmount = totalOutstanding + overpaidAmount;
+ final Float goodwillAmountInExpense = principalOutstanding +
overpaidAmount;
+ final String goodwillDate = "09 January 2022";
+ makeRepaymentTypePayment(GOODWILL_CREDIT, goodwillDate,
goodwillAmount.doubleValue(), disbursedLoanID);
+
+
checkJournalEntryForAssetAccount(getAccounts().getLoansReceivableAccount(),
goodwillDate,
+ journalEntry(principalOutstanding,
getAccounts().getLoansReceivableAccount(), "CREDIT"));
Review Comment:
Done, switched to JournalEntry.TransactionType.CREDIT / DEBIT
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyAndChargebackIntegrationTest.java:
##########
@@ -24,300 +24,218 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-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.math.BigDecimal;
import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
-import org.apache.fineract.client.models.AdvancedPaymentData;
-import org.apache.fineract.client.models.DelinquencyBucketResponse;
import org.apache.fineract.client.models.DelinquencyRangeData;
-import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod;
import org.apache.fineract.client.models.GetLoansLoanIdRepaymentSchedule;
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.PostLoansLoanIdTransactionsResponse;
+import org.apache.fineract.client.models.PostLoansRequest;
import org.apache.fineract.client.models.PutGlobalConfigurationsRequest;
-import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
import
org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants;
import org.apache.fineract.infrastructure.core.service.DateUtils;
-import org.apache.fineract.integrationtests.common.BusinessDateHelper;
-import org.apache.fineract.integrationtests.common.ClientHelper;
-import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
+import org.apache.fineract.integrationtests.client.feign.FeignLoanTestBase;
+import
org.apache.fineract.integrationtests.client.feign.modules.LoanRequestBuilders;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
import org.apache.fineract.integrationtests.common.Utils;
-import
org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
-import
org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
-import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import
org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper;
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
-import
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
-import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Named;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@Slf4j
-public class DelinquencyAndChargebackIntegrationTest extends
BaseLoanIntegrationTest {
+public class DelinquencyAndChargebackIntegrationTest extends FeignLoanTestBase
{
- private ResponseSpecification responseSpec;
- private RequestSpecification requestSpec;
- private LoanTransactionHelper loanTransactionHelper;
private static final String principalAmount = "1200.00";
private static final Double doubleZERO = Double.valueOf("0.00");
-
- @BeforeEach
- public void setup() {
- Utils.initializeRESTAssured();
-
- requestSpec = new
RequestSpecBuilder().setContentType(ContentType.JSON).build();
- requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
- responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
-
- loanTransactionHelper = new LoanTransactionHelper(this.requestSpec,
this.responseSpec);
- }
+ private static final DateTimeFormatter BUSINESS_DATE_FORMAT =
DateTimeFormatter.ofPattern(LoanTestData.DATETIME_PATTERN);
@ParameterizedTest
@MethodSource("loanProductFactory")
- public void testLoanClassificationStepAsPartOfCOB(LoanProductTestBuilder
loanProductTestBuilder) {
+ public void testLoanClassificationStepAsPartOfCOB(String strategyCode,
boolean advancedAllocation) {
try {
-
globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
+
updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
new PutGlobalConfigurationsRequest().enabled(true));
final LocalDate todaysDate = Utils.getDateAsLocalDate("01 April
2012");
LocalDate businessDate = todaysDate.minusMonths(3);
log.info("Current Business date {}", businessDate);
-
BusinessDateHelper.updateBusinessDate(BusinessDateType.BUSINESS_DATE,
businessDate);
+ updateBusinessDate("BUSINESS_DATE",
formatBusinessDate(businessDate));
- final SchedulerJobHelper schedulerJobHelper = new
SchedulerJobHelper(requestSpec);
- // Delinquency Bucket
final Long delinquencyBucketId =
DelinquencyBucketsHelper.createDefaultBucket();
- final DelinquencyBucketResponse delinquencyBucket =
DelinquencyBucketsHelper.getBucket(delinquencyBucketId);
-
- // Client and Loan account creation
- final Integer clientId =
ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January
2012");
- final GetLoanProductsProductIdResponse
getLoanProductsProductResponse = createLoanProduct(loanTransactionHelper,
- delinquencyBucket.getId(), loanProductTestBuilder);
- assertNotNull(getLoanProductsProductResponse);
+ final Long clientId = createClient("01 January 2012");
+ final Long loanProductId = createLoanProduct(strategyCode,
advancedAllocation, delinquencyBucketId);
- // Older date to have more than one overdue installment
- String operationDate = Utils.dateFormatter.format(businessDate);
+ String operationDate = formatBusinessDate(businessDate);
log.info("Operation date {}", businessDate);
- // Create Loan Account
- final Integer loanId = createLoanAccount(loanTransactionHelper,
clientId.toString(),
- getLoanProductsProductResponse.getId().toString(),
operationDate, "12",
-
loanProductTestBuilder.getTransactionProcessingStrategyCode());
+ final Long loanId = createLoanAccount(clientId, loanProductId,
operationDate, "12", strategyCode);
- // Move the Business date 1 month to apply the first repayment
businessDate = businessDate.plusMonths(1);
-
BusinessDateHelper.updateBusinessDate(BusinessDateType.BUSINESS_DATE,
businessDate);
+ updateBusinessDate("BUSINESS_DATE",
formatBusinessDate(businessDate));
log.info("Current Business date {}", businessDate);
String amountVal = "100.00";
- Float transactionAmount = Float.valueOf(amountVal);
- operationDate = Utils.dateFormatter.format(businessDate);
- PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse =
loanTransactionHelper.makeLoanRepayment(operationDate,
- transactionAmount, loanId);
+ operationDate = formatBusinessDate(businessDate);
+ PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse =
makeLoanRepayment(loanId, "Repayment", operationDate,
+ Double.valueOf(amountVal));
assertNotNull(loanIdTransactionsResponse);
Long transactionId = loanIdTransactionsResponse.getResourceId();
- loanTransactionHelper.reviewLoanTransactionRelations(loanId,
transactionId, 0);
+ reviewLoanTransactionRelations(loanId, transactionId, 0);
- // Move the Business date 1 month more to apply the second
repayment
businessDate = businessDate.plusMonths(1);
-
BusinessDateHelper.updateBusinessDate(BusinessDateType.BUSINESS_DATE,
businessDate);
+ updateBusinessDate("BUSINESS_DATE",
formatBusinessDate(businessDate));
log.info("Current Business date {}", businessDate);
- operationDate = Utils.dateFormatter.format(businessDate);
- loanIdTransactionsResponse =
loanTransactionHelper.makeLoanRepayment(operationDate, transactionAmount,
loanId);
+ operationDate = formatBusinessDate(businessDate);
+ loanIdTransactionsResponse = makeLoanRepayment(loanId,
"Repayment", operationDate, Double.valueOf(amountVal));
assertNotNull(loanIdTransactionsResponse);
transactionId = loanIdTransactionsResponse.getResourceId();
- loanTransactionHelper.reviewLoanTransactionRelations(loanId,
transactionId, 0);
+ reviewLoanTransactionRelations(loanId, transactionId, 0);
- // Get loan details expecting to have not a delinquency
classification and 1,000 as Outstanding
- GetLoansLoanIdResponse getLoansLoanIdResponse =
loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
+ GetLoansLoanIdResponse getLoansLoanIdResponse =
getLoanDetails(loanId);
validateLoanAccount(getLoansLoanIdResponse, "0.00", "1000.00", 0,
doubleZERO);
- // Move the Business date n days to apply the chargeback for the
previous repayment
businessDate = businessDate.plusDays(21);
-
BusinessDateHelper.updateBusinessDate(BusinessDateType.BUSINESS_DATE,
businessDate);
+ updateBusinessDate("BUSINESS_DATE",
formatBusinessDate(businessDate));
Review Comment:
Done!
--
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]