Skip to content

Commit 641f755

Browse files
peter-kovacs-dpcadamsaghy
authored andcommitted
FINERACT-2374: Advance Accounting rule for classification type - E2E tests
1 parent cb70555 commit 641f755

File tree

7 files changed

+302
-6
lines changed

7 files changed

+302
-6
lines changed

fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public void updateChargeToIncomeAccountMappings(final JsonCommand command, final
297297

298298
// If input map is empty, delete all existing mappings
299299
if (inputChargeToIncomeAccountMap.size() == 0) {
300-
this.accountMappingRepository.deleteAllInBatch(existingChargeToIncomeAccountMappings);
300+
this.accountMappingRepository.deleteAll(existingChargeToIncomeAccountMappings);
301301
} /**
302302
* Else, <br/>
303303
* update existing mappings OR <br/>
@@ -377,7 +377,7 @@ public void updatePaymentChannelToFundSourceMappings(final JsonCommand command,
377377

378378
// If input map is empty, delete all existing mappings
379379
if (inputPaymentChannelFundSourceMap.isEmpty()) {
380-
this.accountMappingRepository.deleteAllInBatch(existingPaymentChannelToFundSourceMappings);
380+
this.accountMappingRepository.deleteAll(existingPaymentChannelToFundSourceMappings);
381381
} /**
382382
* Else, <br/>
383383
* update existing mappings OR <br/>
@@ -440,7 +440,7 @@ public void updateChargeOffReasonToGLAccountMappings(final JsonCommand command,
440440

441441
// If input map is empty, delete all existing mappings
442442
if (inputChargeOffReasonToGLAccountMap.isEmpty()) {
443-
this.accountMappingRepository.deleteAllInBatch(existingChargeOffReasonToGLAccountMappings);
443+
this.accountMappingRepository.deleteAll(existingChargeOffReasonToGLAccountMappings);
444444
} else {
445445
for (final ProductToGLAccountMapping existingChargeOffReasonToGLAccountMapping : existingChargeOffReasonToGLAccountMappings) {
446446
final Long currentChargeOffReasonId = existingChargeOffReasonToGLAccountMapping.getChargeOffReason().getId();
@@ -504,7 +504,7 @@ public void updateClassificationToGLAccountMappings(final JsonCommand command, f
504504

505505
// If input map is empty, delete all existing mappings
506506
if (inputClassificationToGLAccountMap.isEmpty()) {
507-
this.accountMappingRepository.deleteAllInBatch(existingClassificationToGLAccountMappings);
507+
this.accountMappingRepository.deleteAll(existingClassificationToGLAccountMappings);
508508
} else {
509509
for (final ProductToGLAccountMapping existingClassificationToGLAccountMapping : existingClassificationToGLAccountMappings) {
510510
final Long currentClassificationId = classificationParameter
@@ -699,7 +699,7 @@ public void deleteProductToGLAccountMapping(final Long loanProductId, final Port
699699
final List<ProductToGLAccountMapping> productToGLAccountMappings = this.accountMappingRepository
700700
.findByProductIdAndProductType(loanProductId, portfolioProductType.getValue());
701701
if (productToGLAccountMappings != null && !productToGLAccountMappings.isEmpty()) {
702-
this.accountMappingRepository.deleteAllInBatch(productToGLAccountMappings);
702+
this.accountMappingRepository.deleteAll(productToGLAccountMappings);
703703
}
704704
}
705705

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ public enum DefaultLoanProduct implements LoanProduct {
136136
LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_BUYDOWN_FEES_NON_MERCHANT, //
137137
LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_BUYDOWN_FEES_CHARGE_OFF_REASON, //
138138
LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_BUYDOWN_FEES_NON_MERCHANT_CHARGE_OFF_REASON, //
139+
LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_BUYDOWN_FEES_CLASSIFICATION_INCOME_MAP, //
139140
LP2_PROGRESSIVE_ADV_PYMNT_INTEREST_RECALC_360_30_MULTIDISB_OVER_APPLIED_EXPECTED_TRANCHES, //
140141
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC, //
142+
LP2_PROGRESSIVE_ADV_PMNT_ALLOCATION_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC_CLASSIFICATION_INCOME_MAP, //
141143
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME, //
142144
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_FEE, //
143145
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSAL_CAPITALIZED_INCOME, //

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.fineract.client.models.LoanProductChargeData;
4141
import org.apache.fineract.client.models.LoanProductPaymentAllocationRule;
4242
import org.apache.fineract.client.models.PaymentAllocationOrder;
43+
import org.apache.fineract.client.models.PostClassificationToIncomeAccountMappings;
4344
import org.apache.fineract.client.models.PostLoanProductsRequest;
4445
import org.apache.fineract.client.models.PostLoanProductsResponse;
4546
import org.apache.fineract.client.services.LoanProductsApi;
@@ -3728,6 +3729,95 @@ public void initialize() throws Exception {
37283729
TestContext.INSTANCE.set(
37293730
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_ZERO_CHARGE_OFF,
37303731
responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanScheduleZeroChargeOff);
3732+
3733+
// LP2 with progressive loan schedule + horizontal + interest EMI + 360/30
3734+
// + interest recalculation, buy down fees enabled
3735+
// + Classification income map
3736+
final String name140 = DefaultLoanProduct.LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_BUYDOWN_FEES_CLASSIFICATION_INCOME_MAP
3737+
.getName();
3738+
3739+
List<PostClassificationToIncomeAccountMappings> buydownfeeClassificationToIncomeAccountMappings = new ArrayList<>();
3740+
PostClassificationToIncomeAccountMappings classificationToIncomeAccountMappings = new PostClassificationToIncomeAccountMappings();
3741+
classificationToIncomeAccountMappings.setClassificationCodeValueId(25L);
3742+
classificationToIncomeAccountMappings.setIncomeAccountId(10L);
3743+
buydownfeeClassificationToIncomeAccountMappings.add(classificationToIncomeAccountMappings);
3744+
3745+
final PostLoanProductsRequest loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap = loanProductsRequestFactory
3746+
.defaultLoanProductsRequestLP2BuyDownFees()//
3747+
.name(name140)//
3748+
.transactionProcessingStrategyCode(ADVANCED_PAYMENT_ALLOCATION.getValue())//
3749+
.loanScheduleType("PROGRESSIVE") //
3750+
.isInterestRecalculationEnabled(true)//
3751+
.preClosureInterestCalculationStrategy(1)//
3752+
.rescheduleStrategyMethod(4)//
3753+
.interestRecalculationCompoundingMethod(0)//
3754+
.recalculationRestFrequencyType(2)//
3755+
.recalculationRestFrequencyInterval(1)//
3756+
.paymentAllocation(List.of(//
3757+
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), //
3758+
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
3759+
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
3760+
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
3761+
.buydownfeeClassificationToIncomeAccountMappings(buydownfeeClassificationToIncomeAccountMappings);//
3762+
3763+
final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap = loanProductsApi
3764+
.createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap).execute();
3765+
TestContext.INSTANCE.set(
3766+
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_BUYDOWN_FEES_CLASSIFICATION_INCOME_MAP,
3767+
responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap);
3768+
3769+
// LP2 with progressive loan schedule + horizontal + interest EMI + 360/30 + custom allocation capital
3770+
// adjustment
3771+
// + interest recalculation, preClosureInterestCalculationStrategy= till preclose,
3772+
// Frequency for recalculate Outstanding Principal: Daily, Frequency Interval for recalculation: 1
3773+
// capitalized income enabled + income type - fee
3774+
// + Classification income map
3775+
final String name141 = DefaultLoanProduct.LP2_PROGRESSIVE_ADV_PMNT_ALLOCATION_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC_CLASSIFICATION_INCOME_MAP
3776+
.getName();
3777+
3778+
List<PostClassificationToIncomeAccountMappings> capitalizedIncomeClassificationToIncomeAccountMappings = new ArrayList<>();
3779+
PostClassificationToIncomeAccountMappings classificationToIncomeAccountMappingsCapitalizedIncome = new PostClassificationToIncomeAccountMappings();
3780+
classificationToIncomeAccountMappingsCapitalizedIncome.setClassificationCodeValueId(24L);
3781+
classificationToIncomeAccountMappingsCapitalizedIncome.setIncomeAccountId(15L);
3782+
capitalizedIncomeClassificationToIncomeAccountMappings.add(classificationToIncomeAccountMappingsCapitalizedIncome);
3783+
3784+
final PostLoanProductsRequest loanProductsRequestLP2ProgressiveAdvPaymAllocCapitaizedIncomeClassificationIncomeMap = loanProductsRequestFactory
3785+
.defaultLoanProductsRequestLP2EmiCapitalizedIncome()//
3786+
.name(name141)//
3787+
.daysInYearType(DaysInYearType.DAYS360.value)//
3788+
.daysInMonthType(DaysInMonthType.DAYS30.value)//
3789+
.isInterestRecalculationEnabled(true)//
3790+
.preClosureInterestCalculationStrategy(1)//
3791+
.rescheduleStrategyMethod(4)//
3792+
.interestRecalculationCompoundingMethod(0)//
3793+
.recalculationRestFrequencyType(2)//
3794+
.recalculationRestFrequencyInterval(1)//
3795+
.paymentAllocation(List.of(//
3796+
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), //
3797+
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
3798+
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
3799+
createPaymentAllocation("CAPITALIZED_INCOME_ADJUSTMENT", "NEXT_INSTALLMENT",
3800+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_PRINCIPAL, //
3801+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_INTEREST, //
3802+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_FEE, //
3803+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_PENALTY, //
3804+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_PRINCIPAL, //
3805+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_INTEREST, //
3806+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_FEE, //
3807+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_PENALTY, //
3808+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL, //
3809+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_INTEREST, //
3810+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE, //
3811+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PENALTY), //
3812+
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
3813+
.capitalizedIncomeClassificationToIncomeAccountMappings(capitalizedIncomeClassificationToIncomeAccountMappings);//
3814+
3815+
final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymAllocCapitaizedIncomeClassificationIncomeMap = loanProductsApi
3816+
.createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymAllocCapitaizedIncomeClassificationIncomeMap).execute();
3817+
3818+
TestContext.INSTANCE.set(
3819+
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PMNT_ALLOCATION_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC_CLASSIFICATION_INCOME_MAP,
3820+
responseLoanProductsRequestLP2ProgressiveAdvPaymAllocCapitaizedIncomeClassificationIncomeMap);
37313821
}
37323822

37333823
public static AdvancedPaymentData createPaymentAllocation(String transactionType, String futureInstallmentAllocationRule,

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4773,6 +4773,23 @@ public Response<PostLoansLoanIdTransactionsResponse> addCapitalizedIncomeToTheLo
47734773
return capitalizedIncomeResponse;
47744774
}
47754775

4776+
public Response<PostLoansLoanIdTransactionsResponse> addCapitalizedIncomeToTheLoanOnWithEURTransactionAmountWithClassificationScheduledPayment(
4777+
final String transactionPaymentType, final String transactionDate, final String amount) throws IOException {
4778+
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
4779+
final long loanId = loanResponse.body().getLoanId();
4780+
4781+
final DefaultPaymentType paymentType = DefaultPaymentType.valueOf(transactionPaymentType);
4782+
final Long paymentTypeValue = paymentTypeResolver.resolve(paymentType);
4783+
4784+
final PostLoansLoanIdTransactionsRequest capitalizedIncomeRequest = LoanRequestFactory.defaultCapitalizedIncomeRequest()
4785+
.transactionDate(transactionDate).transactionAmount(Double.valueOf(amount)).paymentTypeId(paymentTypeValue)
4786+
.externalId("EXT-CAP-INC-" + UUID.randomUUID()).classificationId(24L);
4787+
4788+
final Response<PostLoansLoanIdTransactionsResponse> capitalizedIncomeResponse = loanTransactionsApi
4789+
.executeLoanTransaction(loanId, capitalizedIncomeRequest, "capitalizedIncome").execute();
4790+
return capitalizedIncomeResponse;
4791+
}
4792+
47764793
@And("Admin adds capitalized income with {string} payment type to the loan on {string} with {string} EUR transaction amount")
47774794
public void adminAddsCapitalizedIncomeToTheLoanOnWithEURTransactionAmount(final String transactionPaymentType,
47784795
final String transactionDate, final String amount) throws IOException {
@@ -4782,6 +4799,15 @@ public void adminAddsCapitalizedIncomeToTheLoanOnWithEURTransactionAmount(final
47824799
ErrorHelper.checkSuccessfulApiCall(capitalizedIncomeResponse);
47834800
}
47844801

4802+
@And("Admin adds capitalized income with {string} payment type to the loan on {string} with {string} EUR transaction amount and classification: scheduled_payment")
4803+
public void adminAddsCapitalizedIncomeToTheLoanOnWithEURTransactionAmountWithClassificationScheduledPayment(
4804+
final String transactionPaymentType, final String transactionDate, final String amount) throws IOException {
4805+
final Response<PostLoansLoanIdTransactionsResponse> capitalizedIncomeResponse = addCapitalizedIncomeToTheLoanOnWithEURTransactionAmountWithClassificationScheduledPayment(
4806+
transactionPaymentType, transactionDate, amount);
4807+
testContext().set(TestContextKey.LOAN_CAPITALIZED_INCOME_RESPONSE, capitalizedIncomeResponse);
4808+
ErrorHelper.checkSuccessfulApiCall(capitalizedIncomeResponse);
4809+
}
4810+
47854811
@And("Admin adds capitalized income with {string} payment type to the loan on {string} with {string} EUR transaction amount and {string} classification")
47864812
public void adminAddsCapitalizedIncomeWithClassification(final String transactionPaymentType, final String transactionDate,
47874813
final String amount, final String classificationCodeName) throws IOException {
@@ -5214,6 +5240,23 @@ public Response<PostLoansLoanIdTransactionsResponse> addBuyDownFeeToTheLoanOnWit
52145240
return buyDownFeeResponse;
52155241
}
52165242

5243+
public Response<PostLoansLoanIdTransactionsResponse> addBuyDownFeeToTheLoanOnWithEURTransactionAmountWithClassification(
5244+
final String transactionPaymentType, final String transactionDate, final String amount) throws IOException {
5245+
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
5246+
final long loanId = loanResponse.body().getLoanId();
5247+
5248+
final DefaultPaymentType paymentType = DefaultPaymentType.valueOf(transactionPaymentType);
5249+
final Long paymentTypeValue = paymentTypeResolver.resolve(paymentType);
5250+
5251+
final PostLoansLoanIdTransactionsRequest buyDownFeeRequest = LoanRequestFactory.defaultBuyDownFeeIncomeRequest()
5252+
.transactionDate(transactionDate).transactionAmount(Double.valueOf(amount)).paymentTypeId(paymentTypeValue)
5253+
.externalId("EXT-BUY-DOWN-FEE" + UUID.randomUUID()).classificationId(25L);
5254+
5255+
final Response<PostLoansLoanIdTransactionsResponse> buyDownFeeResponse = loanTransactionsApi
5256+
.executeLoanTransaction(loanId, buyDownFeeRequest, "buyDownFee").execute();
5257+
return buyDownFeeResponse;
5258+
}
5259+
52175260
public Response<PostLoansLoanIdTransactionsResponse> adjustBuyDownFee(final String transactionPaymentType, final String transactionDate,
52185261
final String amount, final Long transactionId) throws IOException {
52195262
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
@@ -5242,6 +5285,15 @@ public void adminAddsBuyDownFeesToTheLoanOnWithEURTransactionAmount(final String
52425285
ErrorHelper.checkSuccessfulApiCall(buyDownFeesIncomeResponse);
52435286
}
52445287

5288+
@And("Admin adds buy down fee with {string} payment type to the loan on {string} with {string} EUR transaction amount and classification: pending_bankruptcy")
5289+
public void adminAddsBuyDownFeesToTheLoanOnWithEURTransactionAmountWithClassification(final String transactionPaymentType,
5290+
final String transactionDate, final String amount) throws IOException {
5291+
final Response<PostLoansLoanIdTransactionsResponse> buyDownFeesIncomeResponse = addBuyDownFeeToTheLoanOnWithEURTransactionAmountWithClassification(
5292+
transactionPaymentType, transactionDate, amount);
5293+
testContext().set(TestContextKey.LOAN_BUY_DOWN_FEE_RESPONSE, buyDownFeesIncomeResponse);
5294+
ErrorHelper.checkSuccessfulApiCall(buyDownFeesIncomeResponse);
5295+
}
5296+
52455297
@When("Admin adds buy down fee with {string} payment type to the loan on {string} with {string} EUR transaction amount and {string} classification")
52465298
public void adminAddsBuyDownFeeWithClassification(final String transactionPaymentType, final String transactionDate,
52475299
final String amount, final String classificationCodeName) throws IOException {

0 commit comments

Comments
 (0)