FINERACT-1981: added e2e tests for disbursement charge feature
This commit is contained in:
+3
-3
@@ -21,9 +21,9 @@ package org.apache.fineract.test.data;
|
||||
public enum ChargeProductType {
|
||||
|
||||
LOAN_PERCENTAGE_LATE_FEE(1L), LOAN_PERCENTAGE_PROCESSING_FEE(2L), LOAN_FIXED_LATE_FEE(3L), LOAN_FIXED_RETURNED_PAYMENT_FEE(
|
||||
4L), LOAN_SNOOZE_FEE(5L), LOAN_NSF_FEE(6L), LOAN_DISBURSEMENT_PERCENTAGE_FEE(
|
||||
7L), LOAN_TRANCHE_DISBURSEMENT_PERCENTAGE_FEE(8L), LOAN_INSTALLMENT_PERCENTAGE_FEE(
|
||||
9L), LOAN_PERCENTAGE_LATE_FEE_AMOUNT_PLUS_INTEREST(10L), CLIENT_TEST_CHARGE_FEE(11L);
|
||||
4L), LOAN_SNOOZE_FEE(5L), LOAN_NSF_FEE(6L), LOAN_DISBURSEMENT_PERCENTAGE_FEE(7L), LOAN_TRANCHE_DISBURSEMENT_PERCENTAGE_FEE(
|
||||
8L), LOAN_INSTALLMENT_PERCENTAGE_FEE(9L), LOAN_PERCENTAGE_LATE_FEE_AMOUNT_PLUS_INTEREST(
|
||||
10L), CLIENT_TEST_CHARGE_FEE(11L), LOAN_DISBURSEMENT_CHARGE(12L);
|
||||
|
||||
public final Long value;
|
||||
|
||||
|
||||
+2
-1
@@ -32,7 +32,8 @@ public enum TransactionType {
|
||||
ACCRUAL("accrual"), //
|
||||
CHARGE_OFF("chargeOff"), //
|
||||
CHARGE_ADJUSTMENT("chargeAdjustment"), //
|
||||
INTEREST_PAYMENT_WAIVER("interestPaymentWaiver");//
|
||||
INTEREST_PAYMENT_WAIVER("interestPaymentWaiver"), //
|
||||
REPAYMENT_AT_DISBURSEMENT("repaymentAtDisbursement"); //
|
||||
|
||||
public final String value;
|
||||
|
||||
|
||||
+4
@@ -108,6 +108,10 @@ public enum DefaultLoanProduct implements LoanProduct {
|
||||
LP2_ADV_PYMNT_ZERO_INTEREST_CHARGE_OFF_DELINQUENT_REASON, //
|
||||
LP2_ADV_DP_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL, //
|
||||
LP2_ADV_DP_IR_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL, //
|
||||
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_DISBURSEMENT_CHARGES, //
|
||||
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE, //
|
||||
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE, //
|
||||
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CASH_ACCOUNTING_DISBURSEMENT_CHARGES, //
|
||||
;
|
||||
|
||||
@Override
|
||||
|
||||
+128
@@ -110,6 +110,7 @@ public class LoanProductsRequestFactory {
|
||||
public static final Integer DAYS_IN_MONTH_TYPE = DaysInMonthType.ACTUAL.value;
|
||||
public static final Integer LOAN_ACCOUNTING_RULE = AccountingRule.ACCRUAL_PERIODIC.value;
|
||||
public static final Integer LOAN_ACCOUNTING_RULE_NONE = AccountingRule.NONE.value;
|
||||
public static final Integer CASH_ACCOUNTING_RULE = AccountingRule.CASH_BASED.value;
|
||||
public static final String OVER_APPLIED_CALCULATION_TYPE = "percentage";
|
||||
public static final Integer OVER_APPLIED_NUMBER = 50;
|
||||
public static final Integer DELINQUENCY_BUCKET_ID = DelinquencyBucket.BASIC_DELINQUENCY_BUCKET.value;
|
||||
@@ -1372,4 +1373,131 @@ public class LoanProductsRequestFactory {
|
||||
.chargeOffReasonToExpenseAccountMappings(chargeOffReasonToExpenseAccountMappings)//
|
||||
.incomeFromChargeOffPenaltyAccountId(accountTypeResolver.resolve(DefaultAccountType.FEE_CHARGE_OFF));//
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2EmiCashAccounting() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_LP2_EMI, 4);
|
||||
String shortName = Utils.randomNameGenerator(SHORT_NAME_PREFIX_EMI, 3);
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
List<Integer> numberOfRepaymentVariationsForBorrowerCycle = new ArrayList<>();
|
||||
List<Integer> interestRateVariationsForBorrowerCycle = new ArrayList<>();
|
||||
List<LoanProductChargeData> charges = new ArrayList<>();
|
||||
List<LoanProductChargeToGLAccountMapper> penaltyToIncomeAccountMappings = new ArrayList<>();
|
||||
List<LoanProductChargeToGLAccountMapper> feeToIncomeAccountMappings = new ArrayList<>();
|
||||
|
||||
List<GetLoanPaymentChannelToFundSourceMappings> paymentChannelToFundSourceMappings = new ArrayList<>();
|
||||
GetLoanPaymentChannelToFundSourceMappings loanPaymentChannelToFundSourceMappings = new GetLoanPaymentChannelToFundSourceMappings();
|
||||
loanPaymentChannelToFundSourceMappings.fundSourceAccountId(accountTypeResolver.resolve(DefaultAccountType.FUND_RECEIVABLES));
|
||||
loanPaymentChannelToFundSourceMappings.paymentTypeId(paymentTypeResolver.resolve(DefaultPaymentType.MONEY_TRANSFER));
|
||||
paymentChannelToFundSourceMappings.add(loanPaymentChannelToFundSourceMappings);
|
||||
|
||||
Long chargeOffReasonId = codeHelper.retrieveCodeByName(CHARGE_OFF_REASONS).getId();
|
||||
|
||||
List<PostChargeOffReasonToExpenseAccountMappings> chargeOffReasonToExpenseAccountMappings = new ArrayList<>();
|
||||
PostChargeOffReasonToExpenseAccountMappings chargeOffFraudReason = new PostChargeOffReasonToExpenseAccountMappings();
|
||||
PostChargeOffReasonToExpenseAccountMappings chargeOffDelinquentReason = new PostChargeOffReasonToExpenseAccountMappings();
|
||||
PostChargeOffReasonToExpenseAccountMappings chargeOffOtherReason = new PostChargeOffReasonToExpenseAccountMappings();
|
||||
chargeOffFraudReason.chargeOffReasonCodeValueId(codeValueResolver.resolve(chargeOffReasonId, DefaultCodeValue.FRAUD));
|
||||
chargeOffFraudReason.expenseAccountId(accountTypeResolver.resolve(DefaultAccountType.CREDIT_LOSS_BAD_DEBT_FRAUD));
|
||||
chargeOffDelinquentReason.chargeOffReasonCodeValueId(codeValueResolver.resolve(chargeOffReasonId, DefaultCodeValue.DELINQUENT));
|
||||
chargeOffDelinquentReason.expenseAccountId(accountTypeResolver.resolve(DefaultAccountType.CREDIT_LOSS_BAD_DEBT));
|
||||
chargeOffOtherReason.chargeOffReasonCodeValueId(codeValueResolver.resolve(chargeOffReasonId, DefaultCodeValue.OTHER));
|
||||
chargeOffOtherReason.expenseAccountId(accountTypeResolver.resolve(DefaultAccountType.CREDIT_LOSS_BAD_DEBT));
|
||||
chargeOffReasonToExpenseAccountMappings.add(chargeOffFraudReason);
|
||||
chargeOffReasonToExpenseAccountMappings.add(chargeOffDelinquentReason);
|
||||
chargeOffReasonToExpenseAccountMappings.add(chargeOffOtherReason);
|
||||
|
||||
return new PostLoanProductsRequest()//
|
||||
.name(name)//
|
||||
.shortName(shortName)//
|
||||
.description(DESCRIPTION_LP2_EMI)//
|
||||
.loanScheduleType("PROGRESSIVE") //
|
||||
.interestCalculationPeriodType(InterestCalculationPeriodTime.DAILY.value)//
|
||||
.transactionProcessingStrategyCode(ADVANCED_PAYMENT_ALLOCATION.getValue())//
|
||||
.fundId(FUND_ID)//
|
||||
.startDate(null)//
|
||||
.closeDate(null)//
|
||||
.includeInBorrowerCycle(false)//
|
||||
.currencyCode(CURRENCY_CODE)//
|
||||
.digitsAfterDecimal(2)//
|
||||
.inMultiplesOf(0)//
|
||||
.useBorrowerCycle(false)//
|
||||
.minPrincipal(10.0)//
|
||||
.principal(1000.0)//
|
||||
.maxPrincipal(10000.0)//
|
||||
.minNumberOfRepayments(1)//
|
||||
.numberOfRepayments(4)//
|
||||
.maxNumberOfRepayments(30)//
|
||||
.isLinkedToFloatingInterestRates(false)//
|
||||
.minInterestRatePerPeriod((double) 0)//
|
||||
.interestRatePerPeriod((double) 12)//
|
||||
.maxInterestRatePerPeriod((double) 60)//
|
||||
.interestRateFrequencyType(INTEREST_RATE_FREQUENCY_TYPE_YEAR)//
|
||||
.repaymentEvery(15)//
|
||||
.repaymentStartDateType(1)//
|
||||
.repaymentFrequencyType(REPAYMENT_FREQUENCY_TYPE_DAYS)//
|
||||
.principalVariationsForBorrowerCycle(principalVariationsForBorrowerCycle)//
|
||||
.numberOfRepaymentVariationsForBorrowerCycle(numberOfRepaymentVariationsForBorrowerCycle)//
|
||||
.interestRateVariationsForBorrowerCycle(interestRateVariationsForBorrowerCycle)//
|
||||
.amortizationType(AMORTIZATION_TYPE)//
|
||||
.interestType(INTEREST_TYPE_DECLINING_BALANCE)//
|
||||
.isEqualAmortization(false)//
|
||||
.interestCalculationPeriodType(INTEREST_CALCULATION_PERIOD_TYPE_DAILY)//
|
||||
.transactionProcessingStrategyCode(TRANSACTION_PROCESSING_STRATEGY_CODE_ADVANCED)//
|
||||
.daysInYearType(DAYS_IN_YEAR_TYPE)//
|
||||
.daysInMonthType(DAYS_IN_MONTH_TYPE)//
|
||||
.canDefineInstallmentAmount(true)//
|
||||
.graceOnArrearsAgeing(3)//
|
||||
.overdueDaysForNPA(179)//
|
||||
.accountMovesOutOfNPAOnlyOnArrearsCompletion(false)//
|
||||
.principalThresholdForLastInstallment(50)//
|
||||
.allowVariableInstallments(false)//
|
||||
.canUseForTopup(false)//
|
||||
|
||||
.chargeOffBehaviour(ChargeOffBehaviour.ZERO_INTEREST.value)
|
||||
.chargeOffReasonToExpenseAccountMappings(chargeOffReasonToExpenseAccountMappings)
|
||||
|
||||
.isInterestRecalculationEnabled(false)//
|
||||
.holdGuaranteeFunds(false)//
|
||||
.multiDisburseLoan(false)//
|
||||
.allowAttributeOverrides(new AllowAttributeOverrides()//
|
||||
.amortizationType(true)//
|
||||
.interestType(true)//
|
||||
.transactionProcessingStrategyCode(true)//
|
||||
.interestCalculationPeriodType(true)//
|
||||
.inArrearsTolerance(true)//
|
||||
.repaymentEvery(true)//
|
||||
.graceOnPrincipalAndInterestPayment(true)//
|
||||
.graceOnArrearsAgeing(true))//
|
||||
.allowPartialPeriodInterestCalcualtion(false)//
|
||||
.maxTrancheCount(10)//
|
||||
.outstandingLoanBalance(10000.0)//
|
||||
.charges(charges)//
|
||||
.accountingRule(CASH_ACCOUNTING_RULE)//
|
||||
.fundSourceAccountId(accountTypeResolver.resolve(DefaultAccountType.SUSPENSE_CLEARING_ACCOUNT))//
|
||||
.loanPortfolioAccountId(accountTypeResolver.resolve(DefaultAccountType.LOANS_RECEIVABLE))//
|
||||
.transfersInSuspenseAccountId(accountTypeResolver.resolve(DefaultAccountType.TRANSFER_IN_SUSPENSE_ACCOUNT))//
|
||||
.interestOnLoanAccountId(accountTypeResolver.resolve(DefaultAccountType.INTEREST_INCOME))//
|
||||
.incomeFromFeeAccountId(accountTypeResolver.resolve(DefaultAccountType.FEE_INCOME))//
|
||||
.incomeFromPenaltyAccountId(accountTypeResolver.resolve(DefaultAccountType.FEE_INCOME))//
|
||||
.incomeFromRecoveryAccountId(accountTypeResolver.resolve(DefaultAccountType.RECOVERIES))//
|
||||
.writeOffAccountId(accountTypeResolver.resolve(DefaultAccountType.WRITTEN_OFF))//
|
||||
.overpaymentLiabilityAccountId(accountTypeResolver.resolve(DefaultAccountType.OVERPAYMENT_ACCOUNT))//
|
||||
.dateFormat(DATE_FORMAT)//
|
||||
.locale(LOCALE_EN)//
|
||||
.disallowExpectedDisbursements(false)//
|
||||
.delinquencyBucketId(DELINQUENCY_BUCKET_ID.longValue())//
|
||||
.goodwillCreditAccountId(accountTypeResolver.resolve(DefaultAccountType.GOODWILL_EXPENSE_ACCOUNT))//
|
||||
.incomeFromGoodwillCreditInterestAccountId(accountTypeResolver.resolve(DefaultAccountType.INTEREST_INCOME_CHARGE_OFF))//
|
||||
.incomeFromGoodwillCreditFeesAccountId(accountTypeResolver.resolve(DefaultAccountType.FEE_CHARGE_OFF))//
|
||||
.incomeFromGoodwillCreditPenaltyAccountId(accountTypeResolver.resolve(DefaultAccountType.FEE_CHARGE_OFF))//
|
||||
.paymentChannelToFundSourceMappings(paymentChannelToFundSourceMappings)//
|
||||
.penaltyToIncomeAccountMappings(penaltyToIncomeAccountMappings)//
|
||||
.feeToIncomeAccountMappings(feeToIncomeAccountMappings)//
|
||||
.incomeFromChargeOffInterestAccountId(accountTypeResolver.resolve(DefaultAccountType.INTEREST_INCOME_CHARGE_OFF))//
|
||||
.incomeFromChargeOffFeesAccountId(accountTypeResolver.resolve(DefaultAccountType.FEE_CHARGE_OFF))//
|
||||
.chargeOffExpenseAccountId(accountTypeResolver.resolve(DefaultAccountType.CREDIT_LOSS_BAD_DEBT))//
|
||||
.chargeOffFraudExpenseAccountId(accountTypeResolver.resolve(DefaultAccountType.CREDIT_LOSS_BAD_DEBT_FRAUD))//
|
||||
.incomeFromChargeOffPenaltyAccountId(accountTypeResolver.resolve(DefaultAccountType.FEE_CHARGE_OFF));//
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -54,6 +54,7 @@ public class ChargeGlobalInitializerStep implements FineractGlobalInitializerSte
|
||||
public static final String CHARGE_LOAN_TRANCHE_DISBURSEMENT_PERCENT_FEE = "Tranche Disbursement percentage fee";
|
||||
public static final String CHARGE_LOAN_INSTALLMENT_PERCENT_FEE = "Installment percentage fee";
|
||||
public static final String CHARGE_CLIENT_FIXED_FEE = "Fixed fee for Client";
|
||||
public static final String CHARGE_DISBURSEMENT_CHARGE = "Disbursement Charge";
|
||||
public static final Double CHARGE_AMOUNT_FLAT = 25D;
|
||||
public static final Double CHARGE_AMOUNT_PERCENTAGE = 5D;
|
||||
public static final Double CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE = 1.5D;
|
||||
@@ -124,7 +125,8 @@ public class ChargeGlobalInitializerStep implements FineractGlobalInitializerSte
|
||||
CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT, CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE, true, false);
|
||||
Response<PostChargesResponse> responseLoanTrancheDisbursePercent = chargesApi.createCharge(requestLoanTrancheDisbursePercent)
|
||||
.execute();
|
||||
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_DISBURSEMENET_FEE_CREATE_RESPONSE, responseLoanTrancheDisbursePercent);
|
||||
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_PERCENT_CREATE_RESPONSE,
|
||||
responseLoanTrancheDisbursePercent);
|
||||
|
||||
// Loan - Installment % fee
|
||||
ChargeRequest requestLoanInstallmentPercent = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_INSTALLMENT_PERCENT_FEE,
|
||||
@@ -147,6 +149,12 @@ public class ChargeGlobalInitializerStep implements FineractGlobalInitializerSte
|
||||
CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
|
||||
Response<PostChargesResponse> responseClientFixed = chargesApi.createCharge(requestClientFixed).execute();
|
||||
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_CLIENT_FIXED_FEE_CREATE_RESPONSE, responseClientFixed);
|
||||
|
||||
// Loan - Disbursement fixed fee
|
||||
ChargeRequest requestDisbursementCharge = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_DISBURSEMENT_CHARGE,
|
||||
CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
|
||||
Response<PostChargesResponse> responseDisbursementCharge = chargesApi.createCharge(requestDisbursementCharge).execute();
|
||||
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_DISBURSEMENT_CHARGE_CREATE_RESPONSE, responseDisbursementCharge);
|
||||
}
|
||||
|
||||
public static ChargeRequest defaultChargesRequest(Enum<ChargeProductAppliesTo> appliesTo, String name, Integer chargeTimeType,
|
||||
|
||||
+126
@@ -2101,6 +2101,132 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
|
||||
TestContext.INSTANCE.set(
|
||||
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_DP_IR_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE,
|
||||
responseLoanProductsResponseAdvDPIRCustomPaymentAllocationProgressiveLoanSchedule);
|
||||
|
||||
// LP2 with progressive loan schedule + horizontal + interest EMI + 360/30 + interest recalculation
|
||||
// Frequency for recalculate Outstanding Principal: Daily, Frequency Interval for recalculation: 1
|
||||
// charges - Disbursement Charge
|
||||
// (LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_DISBURSEMENT_CHARGES)
|
||||
String name86 = DefaultLoanProduct.LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_DISBURSEMENT_CHARGES.getName();
|
||||
List<LoanProductChargeData> chargesDisbursement = new ArrayList<>();
|
||||
chargesDisbursement.add(new LoanProductChargeData().id(ChargeProductType.LOAN_DISBURSEMENT_CHARGE.value));
|
||||
PostLoanProductsRequest loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge = loanProductsRequestFactory
|
||||
.defaultLoanProductsRequestLP2Emi()//
|
||||
.name(name86)//
|
||||
.daysInYearType(DaysInYearType.DAYS360.value)//
|
||||
.daysInMonthType(DaysInMonthType.DAYS30.value)//
|
||||
.isInterestRecalculationEnabled(true)//
|
||||
.preClosureInterestCalculationStrategy(1)//
|
||||
.rescheduleStrategyMethod(4)//
|
||||
.interestRecalculationCompoundingMethod(0)//
|
||||
.recalculationRestFrequencyType(2)//
|
||||
.recalculationRestFrequencyInterval(1)//
|
||||
.charges(chargesDisbursement)//
|
||||
.paymentAllocation(List.of(//
|
||||
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), //
|
||||
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
|
||||
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
|
||||
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
|
||||
Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge = loanProductsApi
|
||||
.createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge).execute();
|
||||
TestContext.INSTANCE.set(
|
||||
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_DISBURSEMENT_CHARGES,
|
||||
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge);
|
||||
|
||||
// LP2 with progressive loan schedule + horizontal + interest recalculation daily EMI + 360/30 +
|
||||
// multidisbursement
|
||||
// Frequency for recalculate Outstanding Principal: Daily, Frequency Interval for recalculation: 1
|
||||
// (LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE)
|
||||
String name87 = DefaultLoanProduct.LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE
|
||||
.getName();
|
||||
PostLoanProductsRequest loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse = loanProductsRequestFactory
|
||||
.defaultLoanProductsRequestLP2Emi()//
|
||||
.name(name87)//
|
||||
.daysInYearType(DaysInYearType.DAYS360.value)//
|
||||
.daysInMonthType(DaysInMonthType.DAYS30.value)//
|
||||
.isInterestRecalculationEnabled(true)//
|
||||
.preClosureInterestCalculationStrategy(1)//
|
||||
.rescheduleStrategyMethod(4)//
|
||||
.interestRecalculationCompoundingMethod(0)//
|
||||
.recalculationRestFrequencyType(2)//
|
||||
.recalculationRestFrequencyInterval(1)//
|
||||
.paymentAllocation(List.of(//
|
||||
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), //
|
||||
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
|
||||
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
|
||||
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
|
||||
.multiDisburseLoan(true)//
|
||||
.disallowExpectedDisbursements(false)//
|
||||
.maxTrancheCount(10)//
|
||||
.outstandingLoanBalance(10000.0);//
|
||||
Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse = loanProductsApi
|
||||
.createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse).execute();
|
||||
TestContext.INSTANCE.set(
|
||||
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE,
|
||||
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse);
|
||||
|
||||
// LP2 with progressive loan schedule + horizontal + interest recalculation daily EMI + 360/30 +
|
||||
// multidisbursement
|
||||
// Frequency for recalculate Outstanding Principal: Daily, Frequency Interval for recalculation: 1
|
||||
// charges - Disbursement Charge
|
||||
// (LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE)
|
||||
String name88 = DefaultLoanProduct.LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE.getName();
|
||||
PostLoanProductsRequest loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge = loanProductsRequestFactory
|
||||
.defaultLoanProductsRequestLP2Emi()//
|
||||
.name(name88)//
|
||||
.daysInYearType(DaysInYearType.DAYS360.value)//
|
||||
.daysInMonthType(DaysInMonthType.DAYS30.value)//
|
||||
.isInterestRecalculationEnabled(true)//
|
||||
.preClosureInterestCalculationStrategy(1)//
|
||||
.rescheduleStrategyMethod(4)//
|
||||
.interestRecalculationCompoundingMethod(0)//
|
||||
.recalculationRestFrequencyType(2)//
|
||||
.recalculationRestFrequencyInterval(1)//
|
||||
.paymentAllocation(List.of(//
|
||||
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), //
|
||||
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
|
||||
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
|
||||
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
|
||||
.multiDisburseLoan(true)//
|
||||
.disallowExpectedDisbursements(true)//
|
||||
.maxTrancheCount(10)//
|
||||
.outstandingLoanBalance(10000.0);//
|
||||
Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge = loanProductsApi
|
||||
.createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge)
|
||||
.execute();
|
||||
TestContext.INSTANCE.set(
|
||||
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE,
|
||||
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge);
|
||||
|
||||
// LP2 with progressive loan schedule + horizontal + interest recalculation daily EMI + 360/30 + cash based
|
||||
// accounting
|
||||
// Frequency for recalculate Outstanding Principal: Daily, Frequency Interval for recalculation: 1
|
||||
// charges - Disbursement Charge
|
||||
// (LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CASH_ACCOUNTING_DISBURSEMENT_CHARGES)
|
||||
String name89 = DefaultLoanProduct.LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CASH_ACCOUNTING_DISBURSEMENT_CHARGES
|
||||
.getName();
|
||||
PostLoanProductsRequest loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge = loanProductsRequestFactory
|
||||
.defaultLoanProductsRequestLP2EmiCashAccounting()//
|
||||
.name(name89)//
|
||||
.daysInYearType(DaysInYearType.DAYS360.value)//
|
||||
.daysInMonthType(DaysInMonthType.DAYS30.value)//
|
||||
.isInterestRecalculationEnabled(true)//
|
||||
.preClosureInterestCalculationStrategy(1)//
|
||||
.rescheduleStrategyMethod(4)//
|
||||
.interestRecalculationCompoundingMethod(0)//
|
||||
.recalculationRestFrequencyType(2)//
|
||||
.recalculationRestFrequencyInterval(1)//
|
||||
.charges(chargesDisbursement)//
|
||||
.paymentAllocation(List.of(//
|
||||
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), //
|
||||
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
|
||||
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
|
||||
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
|
||||
Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge = loanProductsApi
|
||||
.createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge)
|
||||
.execute();
|
||||
TestContext.INSTANCE.set(
|
||||
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CASH_ACCOUNTING_DISBURSEMENT_CHARGES,
|
||||
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge);
|
||||
}
|
||||
|
||||
public static AdvancedPaymentData createPaymentAllocation(String transactionType, String futureInstallmentAllocationRule,
|
||||
|
||||
+54
@@ -225,4 +225,58 @@ public class JournalEntriesStepDef extends AbstractStepDef {
|
||||
.isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Then("Loan Transactions tab has a {string} transaction with date {string} has no the Journal entries")
|
||||
public void journalEntryNoDataCheck(String transactionType, String transactionDate) throws IOException {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
|
||||
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
long loanId = loanResponse.body().getLoanId();
|
||||
|
||||
Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
|
||||
|
||||
TransactionType transactionType1 = TransactionType.valueOf(transactionType);
|
||||
String transactionTypeExpected = transactionType1.getValue();
|
||||
|
||||
List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
|
||||
List<GetLoansLoanIdTransactions> transactionsMatch = transactions.stream()
|
||||
.filter(t -> transactionDate.equals(formatter.format(t.getDate()))
|
||||
&& transactionTypeExpected.equals(t.getType().getCode().substring(20)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<List<JournalEntryTransactionItem>> journalLinesActualList = transactionsMatch.stream().map(t -> {
|
||||
String transactionId = "L" + t.getId();
|
||||
Response<GetJournalEntriesTransactionIdResponse> journalEntryDataResponse = null;
|
||||
try {
|
||||
journalEntryDataResponse = journalEntriesApi.retrieveAll1(//
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
transactionId, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
null, //
|
||||
true//
|
||||
).execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(journalEntryDataResponse);
|
||||
} catch (IOException e) {
|
||||
log.error("Exception", e);
|
||||
}
|
||||
|
||||
return journalEntryDataResponse.body().getPageItems();
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
assertThat(journalLinesActualList.stream().findFirst().get().size()).isZero();
|
||||
}
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.test.stepdef.loan;
|
||||
|
||||
import io.cucumber.java.en.When;
|
||||
import java.io.IOException;
|
||||
import org.apache.fineract.client.models.ChargeRequest;
|
||||
import org.apache.fineract.client.models.PutChargesChargeIdResponse;
|
||||
import org.apache.fineract.client.services.ChargesApi;
|
||||
import org.apache.fineract.test.data.ChargeCalculationType;
|
||||
import org.apache.fineract.test.data.ChargeProductType;
|
||||
import org.apache.fineract.test.helper.ErrorHelper;
|
||||
import org.apache.fineract.test.stepdef.AbstractStepDef;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class ChargeStepDef extends AbstractStepDef {
|
||||
|
||||
@Autowired
|
||||
private ChargesApi chargesApi;
|
||||
|
||||
@When("Admin updates charge {string} with {string} calculation type and {double} % of transaction amount")
|
||||
public void updateCharge(String chargeType, String chargeCalculationType, double amount) throws IOException {
|
||||
ChargeRequest disbursementChargeUpdateRequest = new ChargeRequest();
|
||||
ChargeCalculationType chargeProductTypeValue = ChargeCalculationType.valueOf(chargeCalculationType);
|
||||
disbursementChargeUpdateRequest.chargeCalculationType(chargeProductTypeValue.value).amount(amount).locale("en");
|
||||
|
||||
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
|
||||
Long chargeId = chargeProductType.getValue();
|
||||
|
||||
Response<PutChargesChargeIdResponse> responseDisbursementCharge = chargesApi.updateCharge(chargeId, disbursementChargeUpdateRequest)
|
||||
.execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(responseDisbursementCharge);
|
||||
}
|
||||
}
|
||||
+218
@@ -82,12 +82,14 @@ import org.apache.fineract.client.models.InterestPauseRequestDto;
|
||||
import org.apache.fineract.client.models.IsCatchUpRunningDTO;
|
||||
import org.apache.fineract.client.models.PaymentAllocationOrder;
|
||||
import org.apache.fineract.client.models.PostClientsResponse;
|
||||
import org.apache.fineract.client.models.PostLoansDisbursementData;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdRequest;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest;
|
||||
import org.apache.fineract.client.models.PostLoansRequest;
|
||||
import org.apache.fineract.client.models.PostLoansRequestChargeData;
|
||||
import org.apache.fineract.client.models.PostLoansResponse;
|
||||
import org.apache.fineract.client.models.PutLoanProductsProductIdRequest;
|
||||
import org.apache.fineract.client.models.PutLoanProductsProductIdResponse;
|
||||
@@ -100,6 +102,7 @@ import org.apache.fineract.client.services.LoanTransactionsApi;
|
||||
import org.apache.fineract.client.services.LoansApi;
|
||||
import org.apache.fineract.client.util.JSON;
|
||||
import org.apache.fineract.test.data.AmortizationType;
|
||||
import org.apache.fineract.test.data.ChargeProductType;
|
||||
import org.apache.fineract.test.data.InterestCalculationPeriodTime;
|
||||
import org.apache.fineract.test.data.InterestRateFrequencyType;
|
||||
import org.apache.fineract.test.data.InterestType;
|
||||
@@ -448,6 +451,24 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
createFullyCustomizedLoanWithInterestRateFrequency(data.get(1));
|
||||
}
|
||||
|
||||
@When("Admin creates a fully customized loan with charges and following data:")
|
||||
public void createFullyCustomizedLoanWithLoanCharges(final DataTable table) throws IOException {
|
||||
final List<List<String>> data = table.asLists();
|
||||
createFullyCustomizedLoanWithCharges(data.get(1));
|
||||
}
|
||||
|
||||
@When("Admin creates a fully customized loan with charges and disbursement details and following data:")
|
||||
public void createFullyCustomizedLoanWithChargesAndDisbursementDetails(final DataTable table) throws IOException {
|
||||
final List<List<String>> data = table.asLists();
|
||||
createFullyCustomizedLoanWithChargesAndExpectedTrancheDisbursementDetails(data.get(1));
|
||||
}
|
||||
|
||||
@When("Admin creates a fully customized loan with charges and disbursements details and following data:")
|
||||
public void createFullyCustomizedLoanWithChargesAndDisbursementsDetails(final DataTable table) throws IOException {
|
||||
final List<List<String>> data = table.asLists();
|
||||
createFullyCustomizedLoanWithChargesAndExpectedTrancheDisbursementsDetails(data.get(1));
|
||||
}
|
||||
|
||||
@When("Admin creates a fully customized loan with forced disabled downpayment with the following data:")
|
||||
public void createFullyCustomizedLoanWithForcedDisabledDownpayment(DataTable table) throws IOException {
|
||||
List<List<String>> data = table.asLists();
|
||||
@@ -1950,6 +1971,17 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
.as(ErrorMessageHelper.transactionHasNullResourceValue(transaction.getType().getCode(), "external-id")).isNotNull();
|
||||
}
|
||||
|
||||
@Then("Loan Transactions tab has none transaction")
|
||||
public void loanTransactionsTabNoneTransaction() throws IOException {
|
||||
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
long loanId = loanCreateResponse.body().getLoanId();
|
||||
|
||||
Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
|
||||
List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
|
||||
assertThat(transactions.size()).isZero();
|
||||
}
|
||||
|
||||
@Then("Loan Charges tab has a given charge with the following data:")
|
||||
public void loanChargesGivenChargeDataCheck(DataTable table) throws IOException {
|
||||
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
@@ -3098,6 +3130,192 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
eventCheckHelper.createLoanEventCheck(response);
|
||||
}
|
||||
|
||||
public void createFullyCustomizedLoanWithCharges(final List<String> loanData) throws IOException {
|
||||
final String loanProduct = loanData.get(0);
|
||||
final String submitDate = loanData.get(1);
|
||||
final String principal = loanData.get(2);
|
||||
final BigDecimal interestRate = new BigDecimal(loanData.get(3));
|
||||
final String interestTypeStr = loanData.get(4);
|
||||
final String interestCalculationPeriodStr = loanData.get(5);
|
||||
final String amortizationTypeStr = loanData.get(6);
|
||||
final Integer loanTermFrequency = Integer.valueOf(loanData.get(7));
|
||||
final String loanTermFrequencyType = loanData.get(8);
|
||||
final Integer repaymentFrequency = Integer.valueOf(loanData.get(9));
|
||||
final String repaymentFrequencyTypeStr = loanData.get(10);
|
||||
final Integer numberOfRepayments = Integer.valueOf(loanData.get(11));
|
||||
final Integer graceOnPrincipalPayment = Integer.valueOf(loanData.get(12));
|
||||
final Integer graceOnInterestPayment = Integer.valueOf(loanData.get(13));
|
||||
final Integer graceOnInterestCharged = Integer.valueOf(loanData.get(14));
|
||||
final String transactionProcessingStrategyCode = loanData.get(15);
|
||||
final String chargesCalculationType = loanData.get(16);
|
||||
final BigDecimal chargesAmount = new BigDecimal(loanData.get(17));
|
||||
|
||||
final Response<PostClientsResponse> clientResponse = testContext().get(TestContextKey.CLIENT_CREATE_RESPONSE);
|
||||
final Long clientId = clientResponse.body().getClientId();
|
||||
|
||||
final DefaultLoanProduct product = DefaultLoanProduct.valueOf(loanProduct);
|
||||
final Long loanProductId = loanProductResolver.resolve(product);
|
||||
|
||||
final LoanTermFrequencyType termFrequencyType = LoanTermFrequencyType.valueOf(loanTermFrequencyType);
|
||||
final Integer loanTermFrequencyTypeValue = termFrequencyType.getValue();
|
||||
|
||||
final RepaymentFrequencyType repaymentFrequencyType = RepaymentFrequencyType.valueOf(repaymentFrequencyTypeStr);
|
||||
final Integer repaymentFrequencyTypeValue = repaymentFrequencyType.getValue();
|
||||
|
||||
final InterestType interestType = InterestType.valueOf(interestTypeStr);
|
||||
final Integer interestTypeValue = interestType.getValue();
|
||||
|
||||
final InterestCalculationPeriodTime interestCalculationPeriod = InterestCalculationPeriodTime.valueOf(interestCalculationPeriodStr);
|
||||
final Integer interestCalculationPeriodValue = interestCalculationPeriod.getValue();
|
||||
|
||||
final AmortizationType amortizationType = AmortizationType.valueOf(amortizationTypeStr);
|
||||
final Integer amortizationTypeValue = amortizationType.getValue();
|
||||
|
||||
final TransactionProcessingStrategyCode processingStrategyCode = TransactionProcessingStrategyCode
|
||||
.valueOf(transactionProcessingStrategyCode);
|
||||
final String transactionProcessingStrategyCodeValue = processingStrategyCode.getValue();
|
||||
|
||||
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargesCalculationType);
|
||||
Long chargeId = chargeProductType.getValue();
|
||||
|
||||
List<PostLoansRequestChargeData> charges = new ArrayList<>();
|
||||
charges.add(new PostLoansRequestChargeData().chargeId(chargeId).amount(chargesAmount));
|
||||
|
||||
final PostLoansRequest loansRequest = loanRequestFactory//
|
||||
.defaultLoansRequest(clientId)//
|
||||
.productId(loanProductId)//
|
||||
.principal(new BigDecimal(principal))//
|
||||
.interestRatePerPeriod(interestRate)//
|
||||
.interestType(interestTypeValue)//
|
||||
.interestCalculationPeriodType(interestCalculationPeriodValue)//
|
||||
.amortizationType(amortizationTypeValue)//
|
||||
.loanTermFrequency(loanTermFrequency)//
|
||||
.loanTermFrequencyType(loanTermFrequencyTypeValue)//
|
||||
.numberOfRepayments(numberOfRepayments)//
|
||||
.repaymentEvery(repaymentFrequency)//
|
||||
.repaymentFrequencyType(repaymentFrequencyTypeValue)//
|
||||
.submittedOnDate(submitDate)//
|
||||
.expectedDisbursementDate(submitDate)//
|
||||
.graceOnPrincipalPayment(graceOnPrincipalPayment)//
|
||||
.graceOnInterestPayment(graceOnInterestPayment)//
|
||||
.graceOnInterestPayment(graceOnInterestCharged)//
|
||||
.transactionProcessingStrategyCode(transactionProcessingStrategyCodeValue)//
|
||||
.charges(charges);//
|
||||
|
||||
final Response<PostLoansResponse> response = loansApi.calculateLoanScheduleOrSubmitLoanApplication(loansRequest, "").execute();
|
||||
testContext().set(TestContextKey.LOAN_CREATE_RESPONSE, response);
|
||||
ErrorHelper.checkSuccessfulApiCall(response);
|
||||
|
||||
eventCheckHelper.createLoanEventCheck(response);
|
||||
}
|
||||
|
||||
public void createFullyCustomizedLoanWithChargesAndExpectedTrancheDisbursementDetails(final List<String> loanData) throws IOException {
|
||||
final String expectedDisbursementDate = loanData.get(18);
|
||||
final Double disbursementPrincipalAmount = Double.valueOf(loanData.get(19));
|
||||
|
||||
List<PostLoansDisbursementData> disbursementDetail = new ArrayList<>();
|
||||
disbursementDetail.add(
|
||||
new PostLoansDisbursementData().expectedDisbursementDate(expectedDisbursementDate).principal(disbursementPrincipalAmount));
|
||||
|
||||
createFullyCustomizedLoanWithChargesExpectsTrancheDisbursementDetails(loanData, disbursementDetail);
|
||||
}
|
||||
|
||||
public void createFullyCustomizedLoanWithChargesAndExpectedTrancheDisbursementsDetails(final List<String> loanData) throws IOException {
|
||||
final String expectedDisbursementDateFirstDisbursal = loanData.get(18);
|
||||
final Double disbursementPrincipalAmountFirstDisbursal = Double.valueOf(loanData.get(19));
|
||||
|
||||
final String expectedDisbursementDateSecondDisbursal = loanData.get(20);
|
||||
final Double disbursementPrincipalAmountSecondDisbursal = Double.valueOf(loanData.get(21));
|
||||
|
||||
List<PostLoansDisbursementData> disbursementDetail = new ArrayList<>();
|
||||
disbursementDetail.add(new PostLoansDisbursementData().expectedDisbursementDate(expectedDisbursementDateFirstDisbursal)
|
||||
.principal(disbursementPrincipalAmountFirstDisbursal));
|
||||
disbursementDetail.add(new PostLoansDisbursementData().expectedDisbursementDate(expectedDisbursementDateSecondDisbursal)
|
||||
.principal(disbursementPrincipalAmountSecondDisbursal));
|
||||
|
||||
createFullyCustomizedLoanWithChargesExpectsTrancheDisbursementDetails(loanData, disbursementDetail);
|
||||
}
|
||||
|
||||
public void createFullyCustomizedLoanWithChargesExpectsTrancheDisbursementDetails(final List<String> loanData,
|
||||
List<PostLoansDisbursementData> disbursementDetail) throws IOException {
|
||||
final String loanProduct = loanData.get(0);
|
||||
final String submitDate = loanData.get(1);
|
||||
final String principal = loanData.get(2);
|
||||
final BigDecimal interestRate = new BigDecimal(loanData.get(3));
|
||||
final String interestTypeStr = loanData.get(4);
|
||||
final String interestCalculationPeriodStr = loanData.get(5);
|
||||
final String amortizationTypeStr = loanData.get(6);
|
||||
final Integer loanTermFrequency = Integer.valueOf(loanData.get(7));
|
||||
final String loanTermFrequencyType = loanData.get(8);
|
||||
final Integer repaymentFrequency = Integer.valueOf(loanData.get(9));
|
||||
final String repaymentFrequencyTypeStr = loanData.get(10);
|
||||
final Integer numberOfRepayments = Integer.valueOf(loanData.get(11));
|
||||
final Integer graceOnPrincipalPayment = Integer.valueOf(loanData.get(12));
|
||||
final Integer graceOnInterestPayment = Integer.valueOf(loanData.get(13));
|
||||
final Integer graceOnInterestCharged = Integer.valueOf(loanData.get(14));
|
||||
final String transactionProcessingStrategyCode = loanData.get(15);
|
||||
final String chargesCalculationType = loanData.get(16);
|
||||
final BigDecimal chargesAmount = new BigDecimal(loanData.get(17));
|
||||
|
||||
final Response<PostClientsResponse> clientResponse = testContext().get(TestContextKey.CLIENT_CREATE_RESPONSE);
|
||||
final Long clientId = clientResponse.body().getClientId();
|
||||
|
||||
final DefaultLoanProduct product = DefaultLoanProduct.valueOf(loanProduct);
|
||||
final Long loanProductId = loanProductResolver.resolve(product);
|
||||
|
||||
final LoanTermFrequencyType termFrequencyType = LoanTermFrequencyType.valueOf(loanTermFrequencyType);
|
||||
final Integer loanTermFrequencyTypeValue = termFrequencyType.getValue();
|
||||
|
||||
final RepaymentFrequencyType repaymentFrequencyType = RepaymentFrequencyType.valueOf(repaymentFrequencyTypeStr);
|
||||
final Integer repaymentFrequencyTypeValue = repaymentFrequencyType.getValue();
|
||||
|
||||
final InterestType interestType = InterestType.valueOf(interestTypeStr);
|
||||
final Integer interestTypeValue = interestType.getValue();
|
||||
|
||||
final InterestCalculationPeriodTime interestCalculationPeriod = InterestCalculationPeriodTime.valueOf(interestCalculationPeriodStr);
|
||||
final Integer interestCalculationPeriodValue = interestCalculationPeriod.getValue();
|
||||
|
||||
final AmortizationType amortizationType = AmortizationType.valueOf(amortizationTypeStr);
|
||||
final Integer amortizationTypeValue = amortizationType.getValue();
|
||||
|
||||
final TransactionProcessingStrategyCode processingStrategyCode = TransactionProcessingStrategyCode
|
||||
.valueOf(transactionProcessingStrategyCode);
|
||||
final String transactionProcessingStrategyCodeValue = processingStrategyCode.getValue();
|
||||
|
||||
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargesCalculationType);
|
||||
Long chargeId = chargeProductType.getValue();
|
||||
|
||||
List<PostLoansRequestChargeData> charges = new ArrayList<>();
|
||||
charges.add(new PostLoansRequestChargeData().chargeId(chargeId).amount(chargesAmount));
|
||||
|
||||
final PostLoansRequest loansRequest = loanRequestFactory//
|
||||
.defaultLoansRequest(clientId)//
|
||||
.productId(loanProductId)//
|
||||
.principal(new BigDecimal(principal))//
|
||||
.interestRatePerPeriod(interestRate)//
|
||||
.interestType(interestTypeValue)//
|
||||
.interestCalculationPeriodType(interestCalculationPeriodValue)//
|
||||
.amortizationType(amortizationTypeValue)//
|
||||
.loanTermFrequency(loanTermFrequency)//
|
||||
.loanTermFrequencyType(loanTermFrequencyTypeValue)//
|
||||
.numberOfRepayments(numberOfRepayments)//
|
||||
.repaymentEvery(repaymentFrequency)//
|
||||
.repaymentFrequencyType(repaymentFrequencyTypeValue)//
|
||||
.submittedOnDate(submitDate)//
|
||||
.expectedDisbursementDate(submitDate)//
|
||||
.graceOnPrincipalPayment(graceOnPrincipalPayment)//
|
||||
.graceOnInterestPayment(graceOnInterestPayment)//
|
||||
.graceOnInterestPayment(graceOnInterestCharged)//
|
||||
.transactionProcessingStrategyCode(transactionProcessingStrategyCodeValue)//
|
||||
.disbursementData(disbursementDetail).charges(charges);//
|
||||
|
||||
final Response<PostLoansResponse> response = loansApi.calculateLoanScheduleOrSubmitLoanApplication(loansRequest, "").execute();
|
||||
testContext().set(TestContextKey.LOAN_CREATE_RESPONSE, response);
|
||||
ErrorHelper.checkSuccessfulApiCall(response);
|
||||
|
||||
eventCheckHelper.createLoanEventCheck(response);
|
||||
}
|
||||
|
||||
@When("Admin creates a new zero charge-off Loan with interest recalculation and date: {string}")
|
||||
public void createLoanWithInterestRecalculationAndZeroChargeOffBehaviour(final String date) throws IOException {
|
||||
createLoanWithZeroChargeOffBehaviour(date, true);
|
||||
|
||||
+6
@@ -134,6 +134,10 @@ public abstract class TestContextKey {
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_INTEREST_PENALTY_FEE_PRINCIPAL = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyInterestRecalcEmi36030ChargebackInterestPenaltyFeePrincipal";
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_INTEREST_FEE_PRINCIPAL = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyInterestRecalcEmi36030ChargebackInterestFeePrincipal";
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_PRINCIPAL_INTEREST_FEE = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyInterestRecalcEmi36030ChargebackPrincipalInterestFee";
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_DISBURSEMENT_CHARGES = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRecalculationDailyDisbursementCharge";
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRecalculationDailyMultidisburseExpectTranche";
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE = "loanProductCreateResponseLP2AdvancedPaymentInterestRecalculationDailyEmi36030Multidisburse";
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CASH_ACCOUNTING_DISBURSEMENT_CHARGES = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRecalculationDailyCashBasedDisbursementCharge";
|
||||
public static final String LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST_RESPONSE = "loanProductCreateResponseLP2NoInterestRecalculationChargebackAllocationInterestFirst";
|
||||
public static final String LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST_RESPONSE = "loanProductCreateResponseLP2NoInterestRecalculationChargebackAllocationPrincipalFirst";
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR_LAST_INSTALLMENT_STRATEGY = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyInterestRecalculationAccelerateMaturityChargeOffBehaviourLastInstallmentStrategy";
|
||||
@@ -146,8 +150,10 @@ public abstract class TestContextKey {
|
||||
public static final String CHARGE_FOR_LOAN_SNOOZE_FEE_CREATE_RESPONSE = "ChargeForLoanSnoozeFeeCreateResponse";
|
||||
public static final String CHARGE_FOR_LOAN_NSF_FEE_CREATE_RESPONSE = "ChargeForLoanNsfFeeCreateResponse";
|
||||
public static final String CHARGE_FOR_LOAN_DISBURSEMENET_FEE_CREATE_RESPONSE = "ChargeForLoanDisbursementCreateResponse";
|
||||
public static final String CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_PERCENT_CREATE_RESPONSE = "ChargeForLoanTrancheDisbursementPercentCreateResponse";
|
||||
public static final String CHARGE_FOR_LOAN_INSTALLMENT_FEE_CREATE_RESPONSE = "ChargeForLoanInstallmentCreateResponse";
|
||||
public static final String CHARGE_FOR_CLIENT_FIXED_FEE_CREATE_RESPONSE = "ChargeForClientFixedFeeCreateResponse";
|
||||
public static final String CHARGE_FOR_LOAN_DISBURSEMENT_CHARGE_CREATE_RESPONSE = "ChargeForLoanDisbursementChargeCreateResponse";
|
||||
public static final String LOAN_RESPONSE = "loanResponse";
|
||||
public static final String LOAN_REPAYMENT_UNDO_RESPONSE = "loanRepaymentUndoResponse";
|
||||
public static final String LOAN_TRANSACTION_UNDO_RESPONSE = "loanTransactionUndoResponse";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user