FINERACT-1724: Test enhancement
This commit is contained in:
committed by
Arnold Gálovics
parent
18126f2a78
commit
c1def37088
+21
@@ -759,6 +759,25 @@ final class LoansApiResourceSwagger {
|
|||||||
public BigDecimal amount;
|
public BigDecimal amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final class GetLoansLoanIdLoanTransactionRelation {
|
||||||
|
|
||||||
|
private GetLoansLoanIdLoanTransactionRelation() {}
|
||||||
|
|
||||||
|
@Schema(example = "1")
|
||||||
|
public Long fromLoanTransaction;
|
||||||
|
@Schema(example = "10")
|
||||||
|
public Long toLoanTransaction;
|
||||||
|
@Schema(example = "10")
|
||||||
|
public Long toLoanCharge;
|
||||||
|
@Schema(example = "CHARGEBACK")
|
||||||
|
public String relationType;
|
||||||
|
@Schema(example = "100.00")
|
||||||
|
public Double amount;
|
||||||
|
@Schema(example = "Repayment Adjustment Chargeback")
|
||||||
|
public String paymentType;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Schema(example = "1")
|
@Schema(example = "1")
|
||||||
public Long id;
|
public Long id;
|
||||||
@Schema(example = "1")
|
@Schema(example = "1")
|
||||||
@@ -838,6 +857,8 @@ final class LoansApiResourceSwagger {
|
|||||||
public String reversalExternalId;
|
public String reversalExternalId;
|
||||||
@Schema(example = "[2022, 9, 19]")
|
@Schema(example = "[2022, 9, 19]")
|
||||||
public LocalDate reversedOnDate;
|
public LocalDate reversedOnDate;
|
||||||
|
@Schema(description = "List of GetLoansLoanIdLoanTransactionRelationData")
|
||||||
|
public Set<GetLoansLoanIdLoanTransactionRelation> transactionRelations;
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class GetLoansLoanIdLoanChargeData {
|
static final class GetLoansLoanIdLoanChargeData {
|
||||||
|
|||||||
+22
-16
@@ -54,6 +54,7 @@ import java.util.UUID;
|
|||||||
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
|
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
|
||||||
import org.apache.fineract.client.models.BusinessDateRequest;
|
import org.apache.fineract.client.models.BusinessDateRequest;
|
||||||
import org.apache.fineract.client.models.GetLoanTransactionRelation;
|
import org.apache.fineract.client.models.GetLoanTransactionRelation;
|
||||||
|
import org.apache.fineract.client.models.GetLoansLoanIdLoanTransactionRelation;
|
||||||
import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod;
|
import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod;
|
||||||
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
||||||
import org.apache.fineract.client.models.GetLoansLoanIdSummary;
|
import org.apache.fineract.client.models.GetLoansLoanIdSummary;
|
||||||
@@ -6108,9 +6109,10 @@ public class ClientLoanIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void chargeAdjustmentForUnpaidCharge() {
|
public void chargeAdjustmentForUnpaidCharge() {
|
||||||
|
try {
|
||||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||||
businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()).date("2022.11.01")
|
businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName())
|
||||||
.dateFormat("yyyy.MM.dd").locale("en"));
|
.date("2022.11.01").dateFormat("yyyy.MM.dd").locale("en"));
|
||||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||||
@@ -6118,8 +6120,8 @@ public class ClientLoanIntegrationTest {
|
|||||||
|
|
||||||
Integer penalty = ChargesHelper.createCharges(requestSpec, responseSpec,
|
Integer penalty = ChargesHelper.createCharges(requestSpec, responseSpec,
|
||||||
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", true));
|
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", true));
|
||||||
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccountingNoInterest(assetAccount, incomeAccount, expenseAccount,
|
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccountingNoInterest(assetAccount, incomeAccount,
|
||||||
overpaymentAccount);
|
expenseAccount, overpaymentAccount);
|
||||||
|
|
||||||
final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec, "01 January 2011");
|
final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec, "01 January 2011");
|
||||||
|
|
||||||
@@ -6218,24 +6220,26 @@ public class ClientLoanIntegrationTest {
|
|||||||
assertEquals(5.0f, loanSummary.get("principalPaid"));
|
assertEquals(5.0f, loanSummary.get("principalPaid"));
|
||||||
assertEquals(995.0f, loanSummary.get("totalOutstanding"));
|
assertEquals(995.0f, loanSummary.get("totalOutstanding"));
|
||||||
|
|
||||||
Long chargeAdjustmentTxnId = repaymentResult.getResourceId() + 1;
|
GetLoansLoanIdResponse loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanID);
|
||||||
chargeAdjustmentTransaction = this.loanTransactionHelper.getLoanTransactionDetails((long) loanID, chargeAdjustmentTxnId);
|
GetLoansLoanIdTransactions replayedTransaction = loanDetails.getTransactions().stream()
|
||||||
assertEquals(10.0, chargeAdjustmentTransaction.getAmount());
|
.filter(t -> externalId.equals(t.getExternalId())).findFirst().get();
|
||||||
assertEquals(5.0, chargeAdjustmentTransaction.getPenaltyChargesPortion());
|
|
||||||
assertEquals(5.0, chargeAdjustmentTransaction.getPrincipalPortion());
|
|
||||||
assertEquals("loanTransactionType.chargeAdjustment", chargeAdjustmentTransaction.getType().getCode());
|
|
||||||
assertEquals(externalId, chargeAdjustmentTransaction.getExternalId());
|
|
||||||
|
|
||||||
Set<GetLoanTransactionRelation> transactionRelations = chargeAdjustmentTransaction.getTransactionRelations();
|
assertEquals(10.0, replayedTransaction.getAmount());
|
||||||
for (GetLoanTransactionRelation loanTransactionRelation : transactionRelations) {
|
assertEquals(5.0, replayedTransaction.getPenaltyChargesPortion());
|
||||||
if (loanTransactionRelation.getRelationType().equals("CHARGE_ADJUSTMENT")) {
|
assertEquals(5.0, replayedTransaction.getPrincipalPortion());
|
||||||
assertEquals(chargeAdjustmentTxnId, loanTransactionRelation.getFromLoanTransaction());
|
assertEquals("loanTransactionType.chargeAdjustment", replayedTransaction.getType().getCode());
|
||||||
|
assertEquals(externalId, replayedTransaction.getExternalId());
|
||||||
|
|
||||||
|
Set<GetLoansLoanIdLoanTransactionRelation> transactionRelations = replayedTransaction.getTransactionRelations();
|
||||||
|
for (GetLoansLoanIdLoanTransactionRelation loanTransactionRelation : transactionRelations) {
|
||||||
|
if ("CHARGE_ADJUSTMENT".equals(loanTransactionRelation.getRelationType())) {
|
||||||
|
assertEquals(replayedTransaction.getId(), loanTransactionRelation.getFromLoanTransaction());
|
||||||
assertEquals((long) penalty1LoanChargeId, loanTransactionRelation.getToLoanCharge());
|
assertEquals((long) penalty1LoanChargeId, loanTransactionRelation.getToLoanCharge());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
this.loanTransactionHelper.reverseLoanTransaction((long) loanID, chargeAdjustmentTxnId,
|
this.loanTransactionHelper.reverseLoanTransaction((long) loanID, replayedTransaction.getId(),
|
||||||
new PostLoansLoanIdTransactionsTransactionIdRequest().dateFormat("dd MMMM yyyy").transactionDate("08 September 2022")
|
new PostLoansLoanIdTransactionsTransactionIdRequest().dateFormat("dd MMMM yyyy").transactionDate("08 September 2022")
|
||||||
.transactionAmount(0.0).locale("en").reversalExternalId(uuid));
|
.transactionAmount(0.0).locale("en").reversalExternalId(uuid));
|
||||||
|
|
||||||
@@ -6265,8 +6269,10 @@ public class ClientLoanIntegrationTest {
|
|||||||
assertEquals(1000.0f, loanSummary.get("principalOutstanding"));
|
assertEquals(1000.0f, loanSummary.get("principalOutstanding"));
|
||||||
assertEquals(0.0f, loanSummary.get("principalPaid"));
|
assertEquals(0.0f, loanSummary.get("principalPaid"));
|
||||||
assertEquals(1005.0f, loanSummary.get("totalOutstanding"));
|
assertEquals(1005.0f, loanSummary.get("totalOutstanding"));
|
||||||
|
} finally {
|
||||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void chargeAdjustmentAccountingValidation() {
|
public void chargeAdjustmentAccountingValidation() {
|
||||||
|
|||||||
+2
-16
@@ -1001,8 +1001,6 @@ public class SchedulerJobsTestResults {
|
|||||||
this.loanTransactionHelper.approveLoan("02 September 2022", loanId);
|
this.loanTransactionHelper.approveLoan("02 September 2022", loanId);
|
||||||
this.loanTransactionHelper.disburseLoan("03 September 2022", loanId, "1000", null);
|
this.loanTransactionHelper.disburseLoan("03 September 2022", loanId, "1000", null);
|
||||||
|
|
||||||
this.schedulerJobHelper.updateSchedulerJob(16L, new PutJobsJobIDRequest().cronExpression("0/5 * * * * ?"));
|
|
||||||
|
|
||||||
businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName())
|
businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName())
|
||||||
.date("2022.09.05").dateFormat("yyyy.MM.dd").locale("en"));
|
.date("2022.09.05").dateFormat("yyyy.MM.dd").locale("en"));
|
||||||
|
|
||||||
@@ -1011,23 +1009,11 @@ public class SchedulerJobsTestResults {
|
|||||||
|
|
||||||
this.loanTransactionHelper.addChargesForLoan(loanId, LoanTransactionHelper
|
this.loanTransactionHelper.addChargesForLoan(loanId, LoanTransactionHelper
|
||||||
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(penalty), penaltyCharge1AddedDate, "10", null));
|
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(penalty), penaltyCharge1AddedDate, "10", null));
|
||||||
|
this.schedulerJobHelper.updateSchedulerJob(16L, new PutJobsJobIDRequest().cronExpression("0/5 * * * * ?"));
|
||||||
|
|
||||||
Thread.sleep(6000);
|
Thread.sleep(11000);
|
||||||
GetLoansLoanIdResponse loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanId);
|
GetLoansLoanIdResponse loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanId);
|
||||||
assertEquals(LocalDate.of(2022, 9, 5), loanDetails.getTransactions().get(1).getDate());
|
assertEquals(LocalDate.of(2022, 9, 5), loanDetails.getTransactions().get(1).getDate());
|
||||||
|
|
||||||
businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName())
|
|
||||||
.date("2022.09.06").dateFormat("yyyy.MM.dd").locale("en"));
|
|
||||||
|
|
||||||
targetDate = LocalDate.of(2022, 9, 6);
|
|
||||||
penaltyCharge1AddedDate = dateFormatter.format(targetDate);
|
|
||||||
|
|
||||||
this.loanTransactionHelper.addChargesForLoan(loanId, LoanTransactionHelper
|
|
||||||
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(penalty), penaltyCharge1AddedDate, "10", null));
|
|
||||||
|
|
||||||
Thread.sleep(6000);
|
|
||||||
loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanId);
|
|
||||||
assertEquals(LocalDate.of(2022, 9, 6), loanDetails.getTransactions().get(2).getDate());
|
|
||||||
} finally {
|
} finally {
|
||||||
this.schedulerJobHelper.updateSchedulerJob(16L, new PutJobsJobIDRequest().cronExpression("0 2 0 1/1 * ? *"));
|
this.schedulerJobHelper.updateSchedulerJob(16L, new PutJobsJobIDRequest().cronExpression("0 2 0 1/1 * ? *"));
|
||||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||||
|
|||||||
Reference in New Issue
Block a user