FINERACT-2082: New Transaction Type - Interest Payment Waiver
This commit is contained in:
+9
@@ -138,6 +138,7 @@ public abstract class BaseLoanIntegrationTest {
|
||||
protected final Account chargeOffFraudExpenseAccount = accountHelper.createExpenseAccount("chargeOffFraud");
|
||||
protected final Account writtenOffAccount = accountHelper.createExpenseAccount();
|
||||
protected final Account goodwillExpenseAccount = accountHelper.createExpenseAccount();
|
||||
protected final Account goodwillIncomeAccount = accountHelper.createIncomeAccount();
|
||||
protected final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
||||
protected JournalEntryHelper journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
|
||||
protected ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
|
||||
@@ -710,6 +711,14 @@ public abstract class BaseLoanIntegrationTest {
|
||||
return response.getResourceId();
|
||||
}
|
||||
|
||||
protected Long addInterestPaymentWaiverForLoan(Long loanId, Double amount, String date) {
|
||||
String firstRepaymentUUID = UUID.randomUUID().toString();
|
||||
PostLoansLoanIdTransactionsResponse response = loanTransactionHelper.makeInterestPaymentWaiver(loanId,
|
||||
new PostLoansLoanIdTransactionsRequest().dateFormat(DATETIME_PATTERN).transactionDate(date).locale("en")
|
||||
.transactionAmount(amount).externalId(firstRepaymentUUID));
|
||||
return response.getResourceId();
|
||||
}
|
||||
|
||||
protected Long chargeOffLoan(Long loanId, String date) {
|
||||
String randomText = Utils.randomStringGenerator("en", 5) + Utils.randomNumberGenerator(6) + Utils.randomStringGenerator("is", 5);
|
||||
Integer chargeOffReasonId = CodeHelper.createChargeOffCodeValue(requestSpec, responseSpec, randomText, 1);
|
||||
|
||||
+69
@@ -235,6 +235,62 @@ public class LoanProductWithAdvancedPaymentAllocationIntegrationTests {
|
||||
loanProductError.get(0).get("defaultUserMessage"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndReadLoanProductWithAdvancedPaymentAndInterestPaymentWaiverTransaction() {
|
||||
// given
|
||||
AdvancedPaymentData defaultAllocation = createDefaultPaymentAllocation();
|
||||
AdvancedPaymentData interestPaymentWaiverAllocation = createInterestPaymentWaiverAllocation();
|
||||
|
||||
// when
|
||||
Integer loanProductId = LOAN_TRANSACTION_HELPER
|
||||
.getLoanProductId(createLoanJSON(defaultAllocation, interestPaymentWaiverAllocation));
|
||||
Assertions.assertNotNull(loanProductId);
|
||||
GetLoanProductsProductIdResponse loanProduct = LOAN_TRANSACTION_HELPER.getLoanProduct(loanProductId);
|
||||
|
||||
// then
|
||||
Assertions.assertNotNull(loanProduct.getPaymentAllocation());
|
||||
Assertions.assertEquals(2, loanProduct.getPaymentAllocation().size());
|
||||
Optional<AdvancedPaymentData> first = loanProduct.getPaymentAllocation().stream()
|
||||
.filter(advancedPaymentData -> "DEFAULT".equals(advancedPaymentData.getTransactionType())).findFirst();
|
||||
Assertions.assertTrue(first.isPresent());
|
||||
Assertions.assertEquals(defaultAllocation, first.get());
|
||||
|
||||
Optional<AdvancedPaymentData> second = loanProduct.getPaymentAllocation().stream()
|
||||
.filter(advancedPaymentData -> "INTEREST_PAYMENT_WAIVER".equals(advancedPaymentData.getTransactionType())).findFirst();
|
||||
Assertions.assertTrue(second.isPresent());
|
||||
Assertions.assertEquals(interestPaymentWaiverAllocation, second.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateLoanProductInterestPaymentWaiverAllocationIsAdded() {
|
||||
// given a loan with one allocation
|
||||
AdvancedPaymentData defaultAllocation = createDefaultPaymentAllocation();
|
||||
AdvancedPaymentData interestPaymentWaiverAllocation = createInterestPaymentWaiverAllocation();
|
||||
Integer loanProductId = LOAN_TRANSACTION_HELPER.getLoanProductId(createLoanJSON(defaultAllocation));
|
||||
Assertions.assertNotNull(loanProductId);
|
||||
GetLoanProductsProductIdResponse loanProduct = LOAN_TRANSACTION_HELPER.getLoanProduct(loanProductId);
|
||||
Assertions.assertNotNull(loanProduct.getPaymentAllocation());
|
||||
Assertions.assertEquals(1, loanProduct.getPaymentAllocation().size());
|
||||
|
||||
// when a new allocation is added
|
||||
LOAN_TRANSACTION_HELPER.updateLoanProduct(loanProductId.longValue(),
|
||||
updateLoanProductRequest(defaultAllocation, interestPaymentWaiverAllocation));
|
||||
|
||||
// then it shall be added.
|
||||
loanProduct = LOAN_TRANSACTION_HELPER.getLoanProduct(loanProductId);
|
||||
Assertions.assertNotNull(loanProduct.getPaymentAllocation());
|
||||
Assertions.assertEquals(2, loanProduct.getPaymentAllocation().size());
|
||||
Optional<AdvancedPaymentData> first = loanProduct.getPaymentAllocation().stream()
|
||||
.filter(advancedPaymentData -> "DEFAULT".equals(advancedPaymentData.getTransactionType())).findFirst();
|
||||
Assertions.assertTrue(first.isPresent());
|
||||
Assertions.assertEquals(defaultAllocation, first.get());
|
||||
|
||||
Optional<AdvancedPaymentData> second = loanProduct.getPaymentAllocation().stream()
|
||||
.filter(advancedPaymentData -> "INTEREST_PAYMENT_WAIVER".equals(advancedPaymentData.getTransactionType())).findFirst();
|
||||
Assertions.assertTrue(second.isPresent());
|
||||
Assertions.assertEquals(interestPaymentWaiverAllocation, second.get());
|
||||
}
|
||||
|
||||
private String createLoanJSON(AdvancedPaymentData... advancedPaymentData) {
|
||||
return new LoanProductTestBuilder().withPrincipal("15,000.00").withNumberOfRepayments("4").withRepaymentAfterEvery("1")
|
||||
.withRepaymentTypeAsMonth().withinterestRatePerPeriod("1")
|
||||
@@ -267,7 +323,20 @@ public class LoanProductWithAdvancedPaymentAllocationIntegrationTests {
|
||||
PaymentAllocationType.DUE_PENALTY, PaymentAllocationType.DUE_FEE, PaymentAllocationType.DUE_INTEREST,
|
||||
PaymentAllocationType.DUE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_PENALTY, PaymentAllocationType.IN_ADVANCE_FEE,
|
||||
PaymentAllocationType.IN_ADVANCE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_INTEREST);
|
||||
advancedPaymentData.setPaymentAllocationOrder(paymentAllocationOrders);
|
||||
return advancedPaymentData;
|
||||
}
|
||||
|
||||
private AdvancedPaymentData createInterestPaymentWaiverAllocation() {
|
||||
AdvancedPaymentData advancedPaymentData = new AdvancedPaymentData();
|
||||
advancedPaymentData.setTransactionType("INTEREST_PAYMENT_WAIVER");
|
||||
advancedPaymentData.setFutureInstallmentAllocationRule("NEXT_INSTALLMENT");
|
||||
|
||||
List<PaymentAllocationOrder> paymentAllocationOrders = getPaymentAllocationOrder(PaymentAllocationType.PAST_DUE_FEE,
|
||||
PaymentAllocationType.PAST_DUE_PENALTY, PaymentAllocationType.PAST_DUE_INTEREST, PaymentAllocationType.PAST_DUE_PRINCIPAL,
|
||||
PaymentAllocationType.DUE_PENALTY, PaymentAllocationType.DUE_FEE, PaymentAllocationType.DUE_INTEREST,
|
||||
PaymentAllocationType.DUE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_PENALTY, PaymentAllocationType.IN_ADVANCE_FEE,
|
||||
PaymentAllocationType.IN_ADVANCE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_INTEREST);
|
||||
advancedPaymentData.setPaymentAllocationOrder(paymentAllocationOrders);
|
||||
return advancedPaymentData;
|
||||
}
|
||||
|
||||
+1767
File diff suppressed because it is too large
Load Diff
+17
@@ -917,6 +917,23 @@ public final class BatchHelper {
|
||||
return createTransactionRequest(requestId, reference, "goodwillCredit", amount, LocalDate.now(Utils.getZoneIdOfTenant()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a {@link CreateTransactionLoanCommandStrategy} request with given request ID for payment
|
||||
* waiver transaction.
|
||||
*
|
||||
*
|
||||
* @param requestId
|
||||
* the request ID
|
||||
* @param reference
|
||||
* the reference
|
||||
* @param amount
|
||||
* the amount
|
||||
* @return BatchRequest the created {@link BatchRequest}
|
||||
*/
|
||||
public static BatchRequest interestPaymentWaiverRequest(final Long requestId, final Long reference, final String amount) {
|
||||
return createTransactionRequest(requestId, reference, "interestPaymentWaiver", amount, LocalDate.now(Utils.getZoneIdOfTenant()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a {@link CreateTransactionLoanCommandStrategy} request with given request ID for merchant
|
||||
* issued refund transaction.
|
||||
|
||||
+10
@@ -540,6 +540,16 @@ public class ExternalEventConfigurationHelper {
|
||||
loanUndoReAmortizeBusinessEvent.put("enabled", false);
|
||||
defaults.add(loanUndoReAmortizeBusinessEvent);
|
||||
|
||||
Map<String, Object> loanTransactionInterestPaymentWaiverPostBusinessEvent = new HashMap<>();
|
||||
loanTransactionInterestPaymentWaiverPostBusinessEvent.put("type", "LoanTransactionInterestPaymentWaiverPostBusinessEvent");
|
||||
loanTransactionInterestPaymentWaiverPostBusinessEvent.put("enabled", false);
|
||||
defaults.add(loanTransactionInterestPaymentWaiverPostBusinessEvent);
|
||||
|
||||
Map<String, Object> loanTransactionInterestPaymentWaiverPreBusinessEvent = new HashMap<>();
|
||||
loanTransactionInterestPaymentWaiverPreBusinessEvent.put("type", "LoanTransactionInterestPaymentWaiverPreBusinessEvent");
|
||||
loanTransactionInterestPaymentWaiverPreBusinessEvent.put("enabled", false);
|
||||
defaults.add(loanTransactionInterestPaymentWaiverPreBusinessEvent);
|
||||
|
||||
return defaults;
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -601,6 +601,16 @@ public class LoanTransactionHelper extends IntegrationTest {
|
||||
return ok(fineract().loanTransactions.executeLoanTransaction(loanId, request, "repayment"));
|
||||
}
|
||||
|
||||
public PostLoansLoanIdTransactionsResponse makeInterestPaymentWaiver(final Long loanId,
|
||||
final PostLoansLoanIdTransactionsRequest request) {
|
||||
return ok(fineract().loanTransactions.executeLoanTransaction(loanId, request, "interestPaymentWaiver"));
|
||||
}
|
||||
|
||||
public PostLoansLoanIdTransactionsResponse makeInterestPaymentWaiver(final String loanExternalId,
|
||||
final PostLoansLoanIdTransactionsRequest request) {
|
||||
return ok(fineract().loanTransactions.executeLoanTransaction1(loanExternalId, request, "interestPaymentWaiver"));
|
||||
}
|
||||
|
||||
public PostLoansLoanIdTransactionsResponse reAge(final Long loanId, final PostLoansLoanIdTransactionsRequest request) {
|
||||
return ok(fineract().loanTransactions.executeLoanTransaction(loanId, request, "reAge"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user