Skip to content

Commit 54e85c7

Browse files
MarianaDmytrivBinariksadamsaghy
authored andcommitted
FINERACT-2382: e2e test scenarios for flat cumulative multidisbursal loan
1 parent 2269d61 commit 54e85c7

File tree

5 files changed

+451
-1
lines changed

5 files changed

+451
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ public enum DefaultLoanProduct implements LoanProduct {
165165
LP2_ADV_PYMNT_INTEREST_DECL_BAL_SARP_EMI_360_30_NO_INT_RECALC_MULTIDISB_NO_PARTIAL_PERIOD, //
166166
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_MIN_INT_3_MAX_INT_20, //
167167
LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_WRITE_OFF_REASON_MAP, //
168+
LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_ACTUAL_ACTUAL_MULTIDISB, //
169+
LP1_INTEREST_FLAT_SAR_RECALCULATION_DAILY_360_30_APPROVED_OVER_APPLIED_MULTIDISB, //
170+
LP1_INTEREST_FLAT_DAILY_RECALCULATION_DAILY_360_30_MULTIDISB, //
171+
LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_MULTIDISB_AUTO_DOWNPAYMENT, //
168172
;
169173

170174
@Override

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

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static org.apache.fineract.test.factory.LoanProductsRequestFactory.INTEREST_RATE_FREQUENCY_TYPE_MONTH;
2525
import static org.apache.fineract.test.factory.LoanProductsRequestFactory.INTEREST_RATE_FREQUENCY_TYPE_WHOLE_TERM;
2626
import static org.apache.fineract.test.factory.LoanProductsRequestFactory.INTEREST_RATE_FREQUENCY_TYPE_YEAR;
27+
import static org.apache.fineract.test.factory.LoanProductsRequestFactory.INTEREST_TYPE_FLAT;
2728
import static org.apache.fineract.test.factory.LoanProductsRequestFactory.LOAN_ACCOUNTING_RULE_NONE;
2829
import static org.apache.fineract.test.factory.LoanProductsRequestFactory.REPAYMENT_FREQUENCY_TYPE_MONTHS;
2930

@@ -1324,7 +1325,7 @@ public void initialize() throws Exception {
13241325
.recalculationRestFrequencyType(1)//
13251326
.recalculationRestFrequencyInterval(1)//
13261327
.repaymentEvery(1)//
1327-
.interestRatePerPeriod(7D)//
1328+
.interestRatePerPeriod((double) 7.0)//
13281329
.interestRateFrequencyType(INTEREST_RATE_FREQUENCY_TYPE_MONTH)//
13291330
.enableDownPayment(false)//
13301331
.interestRecalculationCompoundingMethod(0)//
@@ -3873,6 +3874,106 @@ public void initialize() throws Exception {
38733874
.createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentWriteOffReasonMap).execute();
38743875
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_WRITE_OFF_REASON_MAP,
38753876
responseLoanProductsRequestLP2ProgressiveAdvPaymentWriteOffReasonMap);
3877+
3878+
// LP1 with 12% Flat interest, interest period: Same as repayment,
3879+
// Interest recalculation-Same as repayment, Multi-disbursement
3880+
String name143 = DefaultLoanProduct.LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_ACTUAL_ACTUAL_MULTIDISB.getName();
3881+
PostLoanProductsRequest loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement = loanProductsRequestFactory
3882+
.defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone()//
3883+
.name(name143)//
3884+
.interestType(INTEREST_TYPE_FLAT)//
3885+
.interestCalculationPeriodType(InterestCalculationPeriodTime.SAME_AS_REPAYMENT_PERIOD.value)//
3886+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.SAME_AS_REPAYMENT.value)//
3887+
.installmentAmountInMultiplesOf(null)//
3888+
.multiDisburseLoan(true)//
3889+
.disallowExpectedDisbursements(true)//
3890+
.allowPartialPeriodInterestCalcualtion(true)//
3891+
.maxTrancheCount(10)//
3892+
.outstandingLoanBalance(10000.0)//
3893+
.allowApprovedDisbursedAmountsOverApplied(true)//
3894+
.overAppliedCalculationType(OverAppliedCalculationType.PERCENTAGE.value)//
3895+
.overAppliedNumber(50);//
3896+
Response<PostLoanProductsResponse> responseInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement = loanProductsApi
3897+
.createLoanProduct(loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement).execute();
3898+
TestContext.INSTANCE.set(
3899+
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_ACTUAL_ACTUAL_MULTIDISB,
3900+
responseInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement);
3901+
3902+
// LP1 with 12% Flat interest, interest period: Same as repayment,
3903+
// Interest recalculation-Daily, Multi-disbursement
3904+
String name144 = DefaultLoanProduct.LP1_INTEREST_FLAT_SAR_RECALCULATION_DAILY_360_30_APPROVED_OVER_APPLIED_MULTIDISB.getName();
3905+
PostLoanProductsRequest loanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement = loanProductsRequestFactory
3906+
.defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone()//
3907+
.name(name144)//
3908+
.interestType(INTEREST_TYPE_FLAT)//
3909+
.interestCalculationPeriodType(InterestCalculationPeriodTime.SAME_AS_REPAYMENT_PERIOD.value)//
3910+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY.value)//
3911+
.recalculationRestFrequencyInterval(1)//
3912+
.daysInYearType(DaysInYearType.DAYS360.value)//
3913+
.daysInMonthType(DaysInMonthType.DAYS30.value)//
3914+
.installmentAmountInMultiplesOf(null)//
3915+
.multiDisburseLoan(true)//
3916+
.disallowExpectedDisbursements(true)//
3917+
.allowPartialPeriodInterestCalcualtion(true)//
3918+
.maxTrancheCount(10)//
3919+
.outstandingLoanBalance(10000.0)//
3920+
.allowApprovedDisbursedAmountsOverApplied(true)//
3921+
.overAppliedCalculationType(OverAppliedCalculationType.PERCENTAGE.value)//
3922+
.overAppliedNumber(50);//
3923+
Response<PostLoanProductsResponse> responseLoanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement = loanProductsApi
3924+
.createLoanProduct(loanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement).execute();
3925+
TestContext.INSTANCE.set(
3926+
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_DAILY_360_30_APPROVED_OVER_APPLIED_MULTIDISB,
3927+
responseLoanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement);
3928+
3929+
// LP1 with 12% Flat interest, interest period: Daily, Interest recalculation-Daily,
3930+
// Multi-disbursement
3931+
String name145 = DefaultLoanProduct.LP1_INTEREST_FLAT_DAILY_RECALCULATION_DAILY_360_30_MULTIDISB.getName();
3932+
PostLoanProductsRequest loanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement = loanProductsRequestFactory
3933+
.defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone()//
3934+
.name(name145)//
3935+
.interestType(INTEREST_TYPE_FLAT)//
3936+
.interestCalculationPeriodType(InterestCalculationPeriodTime.DAILY.value)//
3937+
.allowPartialPeriodInterestCalcualtion(false)//
3938+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY.value)//
3939+
.recalculationRestFrequencyInterval(1)//
3940+
.daysInYearType(DaysInYearType.DAYS360.value)//
3941+
.daysInMonthType(DaysInMonthType.DAYS30.value)//
3942+
.installmentAmountInMultiplesOf(null)//
3943+
.multiDisburseLoan(true)//
3944+
.disallowExpectedDisbursements(true)//
3945+
.maxTrancheCount(10)//
3946+
.outstandingLoanBalance(10000.0);//
3947+
Response<PostLoanProductsResponse> responseLoanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement = loanProductsApi
3948+
.createLoanProduct(loanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement).execute();
3949+
TestContext.INSTANCE.set(
3950+
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_DAILY_RECALCULATION_DAILY_360_30_MULTIDISB,
3951+
responseLoanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement);
3952+
3953+
// LP1 with 12% Flat interest, interest period: Daily, Interest recalculation-Daily
3954+
// Multi-disbursement with auto down payment
3955+
String name146 = DefaultLoanProduct.LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_MULTIDISB_AUTO_DOWNPAYMENT.getName();
3956+
PostLoanProductsRequest loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment = loanProductsRequestFactory
3957+
.defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone()//
3958+
.name(name146)//
3959+
.interestType(INTEREST_TYPE_FLAT)//
3960+
.installmentAmountInMultiplesOf(null)//
3961+
.interestCalculationPeriodType(InterestCalculationPeriodTime.SAME_AS_REPAYMENT_PERIOD.value)//
3962+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.SAME_AS_REPAYMENT.value)//
3963+
.multiDisburseLoan(true)//
3964+
.disallowExpectedDisbursements(true)//
3965+
.enableDownPayment(true)//
3966+
.enableAutoRepaymentForDownPayment(true)//
3967+
.disbursedAmountPercentageForDownPayment(new BigDecimal(25))//
3968+
.allowPartialPeriodInterestCalcualtion(true)//
3969+
.maxTrancheCount(10)//
3970+
.outstandingLoanBalance(10000.0);//
3971+
Response<PostLoanProductsResponse> responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment = loanProductsApi
3972+
.createLoanProduct(loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment)
3973+
.execute();
3974+
TestContext.INSTANCE.set(
3975+
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_MULTIDISB_AUTO_DOWNPAYMENT,
3976+
responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment);
38763977
}
38773978

38783979
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,6 +2567,13 @@ public void loanInstallmentsObligationsMet() throws IOException {
25672567
assertThat(allInstallmentsObligationsMet).isTrue();
25682568
}
25692569

2570+
@Then("Loan is closed with zero outstanding balance and it's all installments have obligations met")
2571+
public void loanClosedAndInstallmentsObligationsMet() throws IOException {
2572+
loanInstallmentsObligationsMet();
2573+
loanOutstanding(0);
2574+
loanStatus("CLOSED_OBLIGATIONS_MET");
2575+
}
2576+
25702577
@Then("Loan closedon_date is {string}")
25712578
public void loanClosedonDate(String date) throws IOException {
25722579
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ public abstract class TestContextKey {
184184
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_REFUND_INTEREST_RECALC_ACCRUAL_ACTIVITY = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRefundInterestRecalculationAccrualActivity";
185185
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_REFUND_INTEREST_RECALC_DOWNPAYMENT_ACCRUAL_ACTIVITY = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRefundInterestRecalculatioDownpaymentnAccrualActivity";
186186
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_MULTIDISBURSAL_EXPECTS_TRANCHES = "loanProductCreateResponseLP1MultidisbursalThatExpectTranches";
187+
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_ACTUAL_ACTUAL_MULTIDISB = "loanProductCreateResponseLP1InterestFlatDailyRecalculationSameAsRepaymentActualActualMultiDisbursement";
188+
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_DAILY_360_30_APPROVED_OVER_APPLIED_MULTIDISB = "loanProductCreateResponseLP1InterestFlatSameAsRepaymentRecalculationDaily36030MultiDisbursement";
189+
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_DAILY_RECALCULATION_DAILY_360_30_MULTIDISB = "loanProductCreateResponseLP1InterestFlatDailyRecalculationDaily36030MultiDisbursement";
190+
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_MULTIDISB_AUTO_DOWNPAYMENT = "loanProductCreateResponseLP1InterestFlatDailyRecalculationSameAsRepaymentMultiDisbursementAutoDownPayment";
187191
public static final String CHARGE_FOR_LOAN_PERCENT_LATE_CREATE_RESPONSE = "ChargeForLoanPercentLateCreateResponse";
188192
public static final String CHARGE_FOR_LOAN_PERCENT_LATE_AMOUNT_PLUS_INTEREST_CREATE_RESPONSE = "ChargeForLoanPercentLateAmountPlusInterestCreateResponse";
189193
public static final String CHARGE_FOR_LOAN_PERCENT_PROCESSING_CREATE_RESPONSE = "ChargeForLoanPercentProcessingCreateResponse";

0 commit comments

Comments
 (0)