From 01f850aecc0d6c50f84970d08a8f43d26b2b1e97 Mon Sep 17 00:00:00 2001 From: MarianaDmytrivBinariks Date: Thu, 3 Jul 2025 15:42:26 +0300 Subject: [PATCH] FINERACT-2311: added e2e auto test scenarios for add buy down fees to loan --- .../fineract/test/data/TransactionType.java | 1 + .../factory/LoanProductsRequestFactory.java | 45 ++--- .../test/factory/LoanRequestFactory.java | 5 + .../LoanProductGlobalInitializerStep.java | 6 + .../test/stepdef/loan/LoanStepDef.java | 27 +++ .../features/LoanBuyDownFees.feature | 158 ++++++++++++++++++ 6 files changed, 222 insertions(+), 20 deletions(-) create mode 100644 fineract-e2e-tests-runner/src/test/resources/features/LoanBuyDownFees.feature diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/TransactionType.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/TransactionType.java index a90d5886a..55b499a24 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/TransactionType.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/TransactionType.java @@ -38,6 +38,7 @@ public enum TransactionType { CAPITALIZED_INCOME_AMORTIZATION("capitalizedIncomeAmortization"), // CAPITALIZED_INCOME_ADJUSTMENT("capitalizedIncomeAdjustment"), // CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT("capitalizedIncomeAmortizationAdjustment"), // + BUY_DOWN_FEE("buyDownFee"), // ; public final String value; diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/LoanProductsRequestFactory.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/LoanProductsRequestFactory.java index e355322f9..6fda915a5 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/LoanProductsRequestFactory.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/LoanProductsRequestFactory.java @@ -1658,10 +1658,10 @@ public class LoanProductsRequestFactory { return new PostLoanProductsRequest()// .name(name)// .shortName(shortName)// - .description(DESCRIPTION_LP2)// - .enableDownPayment(true)// - .enableAutoRepaymentForDownPayment(true)// - .disbursedAmountPercentageForDownPayment(new BigDecimal(25))// + .description(DESCRIPTION_LP2_EMI)// + .loanScheduleType("PROGRESSIVE") // + .interestCalculationPeriodType(InterestCalculationPeriodTime.DAILY.value)// + .transactionProcessingStrategyCode(ADVANCED_PAYMENT_ALLOCATION.getValue())// .fundId(FUND_ID)// .startDate(null)// .closeDate(null)// @@ -1669,20 +1669,20 @@ public class LoanProductsRequestFactory { .currencyCode(CURRENCY_CODE)// .digitsAfterDecimal(2)// .inMultiplesOf(0)// - .installmentAmountInMultiplesOf(1)// .useBorrowerCycle(false)// - .minPrincipal(100.0)// + .minPrincipal(10.0)// .principal(1000.0)// .maxPrincipal(10000.0)// .minNumberOfRepayments(1)// - .numberOfRepayments(3)// + .numberOfRepayments(4)// .maxNumberOfRepayments(30)// .isLinkedToFloatingInterestRates(false)// .minInterestRatePerPeriod((double) 0)// - .interestRatePerPeriod((double) 7)// - .maxInterestRatePerPeriod((double) 60)// - .interestRateFrequencyType(INTEREST_RATE_FREQUENCY_TYPE_MONTH)// + .interestRatePerPeriod((double) 12)// + .maxInterestRatePerPeriod((double) 90)// + .interestRateFrequencyType(INTEREST_RATE_FREQUENCY_TYPE_YEAR)// .repaymentEvery(15)// + .repaymentStartDateType(1)// .repaymentFrequencyType(REPAYMENT_FREQUENCY_TYPE_DAYS)// .principalVariationsForBorrowerCycle(principalVariationsForBorrowerCycle)// .numberOfRepaymentVariationsForBorrowerCycle(numberOfRepaymentVariationsForBorrowerCycle)// @@ -1690,10 +1690,10 @@ public class LoanProductsRequestFactory { .amortizationType(AMORTIZATION_TYPE)// .interestType(INTEREST_TYPE_DECLINING_BALANCE)// .isEqualAmortization(false)// - .interestCalculationPeriodType(INTEREST_CALCULATION_PERIOD_TYPE_SAME_AS_REPAYMENT)// - .transactionProcessingStrategyCode(TRANSACTION_PROCESSING_STRATEGY_CODE)// - .daysInYearType(360)// - .daysInMonthType(30)// + .interestCalculationPeriodType(INTEREST_CALCULATION_PERIOD_TYPE_DAILY)// + .transactionProcessingStrategyCode(TRANSACTION_PROCESSING_STRATEGY_CODE_ADVANCED)// + .daysInYearType(DAYS_IN_YEAR_TYPE_360)// + .daysInMonthType(DAYS_IN_MONTH_TYPE_30)// .canDefineInstallmentAmount(true)// .graceOnArrearsAgeing(3)// .overdueDaysForNPA(179)// @@ -1703,7 +1703,7 @@ public class LoanProductsRequestFactory { .canUseForTopup(false)// .isInterestRecalculationEnabled(false)// .holdGuaranteeFunds(false)// - .multiDisburseLoan(true)// + .multiDisburseLoan(false)// .allowAttributeOverrides(new AllowAttributeOverrides()// .amortizationType(true)// .interestType(true)// @@ -1713,7 +1713,7 @@ public class LoanProductsRequestFactory { .repaymentEvery(true)// .graceOnPrincipalAndInterestPayment(true)// .graceOnArrearsAgeing(true))// - .allowPartialPeriodInterestCalcualtion(true)// + .allowPartialPeriodInterestCalcualtion(false)// .maxTrancheCount(10)// .outstandingLoanBalance(10000.0)// .charges(charges)// @@ -1732,10 +1732,7 @@ public class LoanProductsRequestFactory { .receivablePenaltyAccountId(accountTypeResolver.resolve(DefaultAccountType.INTEREST_FEE_RECEIVABLE))// .dateFormat(DATE_FORMAT)// .locale(LOCALE_EN)// - .disallowExpectedDisbursements(true)// - .allowApprovedDisbursedAmountsOverApplied(true)// - .overAppliedCalculationType(OVER_APPLIED_CALCULATION_TYPE)// - .overAppliedNumber(OVER_APPLIED_NUMBER)// + .disallowExpectedDisbursements(false)// .delinquencyBucketId(DELINQUENCY_BUCKET_ID.longValue())// .goodwillCreditAccountId(accountTypeResolver.resolve(DefaultAccountType.GOODWILL_EXPENSE_ACCOUNT))// .incomeFromGoodwillCreditInterestAccountId(accountTypeResolver.resolve(DefaultAccountType.INTEREST_INCOME_CHARGE_OFF))// @@ -1749,6 +1746,14 @@ public class LoanProductsRequestFactory { .chargeOffExpenseAccountId(accountTypeResolver.resolve(DefaultAccountType.CREDIT_LOSS_BAD_DEBT))// .chargeOffFraudExpenseAccountId(accountTypeResolver.resolve(DefaultAccountType.CREDIT_LOSS_BAD_DEBT_FRAUD))// .incomeFromChargeOffPenaltyAccountId(accountTypeResolver.resolve(DefaultAccountType.FEE_CHARGE_OFF))// + + .enableIncomeCapitalization(true) + .capitalizedIncomeStrategy(PostLoanProductsRequest.CapitalizedIncomeStrategyEnum.EQUAL_AMORTIZATION)// + .capitalizedIncomeCalculationType(PostLoanProductsRequest.CapitalizedIncomeCalculationTypeEnum.FLAT)// + .capitalizedIncomeType(PostLoanProductsRequest.CapitalizedIncomeTypeEnum.INTEREST)// + .deferredIncomeLiabilityAccountId(accountTypeResolver.resolve(DefaultAccountType.DEFERRED_CAPITALIZED_INCOME))// + .incomeFromCapitalizationAccountId(accountTypeResolver.resolve(DefaultAccountType.INTEREST_INCOME))// + .buyDownFeeStrategy(PostLoanProductsRequest.BuyDownFeeStrategyEnum.EQUAL_AMORTIZATION)// .buyDownFeeCalculationType(PostLoanProductsRequest.BuyDownFeeCalculationTypeEnum.FLAT)// .buyDownFeeIncomeType(PostLoanProductsRequest.BuyDownFeeIncomeTypeEnum.INTEREST)// diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/LoanRequestFactory.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/LoanRequestFactory.java index bd538658e..c3836a19b 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/LoanRequestFactory.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/LoanRequestFactory.java @@ -320,6 +320,11 @@ public class LoanRequestFactory { return new PostLoansLoanIdRequest().dateFormat(DATE_FORMAT).locale(DEFAULT_LOCALE).note("Contract Termination"); } + public static PostLoansLoanIdTransactionsRequest defaultBuyDownFeeIncomeRequest() { + return new PostLoansLoanIdTransactionsRequest().transactionDate(DEFAULT_TRANSACTION_DATE).dateFormat(DATE_FORMAT) + .locale(DEFAULT_LOCALE).note("Buy Down Fee"); + } + public JournalEntryCommand defaultManualJournalEntryRequest(BigDecimal amount) { final Long glAccountDebit = accountTypeResolver.resolve(DefaultAccountType.LOANS_RECEIVABLE); final Long glAccountCredit = accountTypeResolver.resolve(DefaultAccountType.SUSPENSE_CLEARING_ACCOUNT); diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java index d1939eab9..16ad9c75d 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java @@ -2946,6 +2946,12 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ .name(name114)// .transactionProcessingStrategyCode(ADVANCED_PAYMENT_ALLOCATION.getValue())// .loanScheduleType("PROGRESSIVE") // + .isInterestRecalculationEnabled(true)// + .preClosureInterestCalculationStrategy(1)// + .rescheduleStrategyMethod(4)// + .interestRecalculationCompoundingMethod(0)// + .recalculationRestFrequencyType(2)// + .recalculationRestFrequencyInterval(1)// .paymentAllocation(List.of(// createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), // createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), // diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java index 19f70a561..c736e32ea 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java @@ -4670,4 +4670,31 @@ public class LoanStepDef extends AbstractStepDef { assertThat(errorDetails.getSingleError().getDeveloperMessage()) .isEqualTo(ErrorMessageHelper.addCapitalizedIncomeFutureDateFailure()); } + + public Response addBuyDownFeeToTheLoanOnWithEURTransactionAmount( + final String transactionPaymentType, final String transactionDate, final String amount) throws IOException { + final Response loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); + final long loanId = loanResponse.body().getLoanId(); + + final DefaultPaymentType paymentType = DefaultPaymentType.valueOf(transactionPaymentType); + final Long paymentTypeValue = paymentTypeResolver.resolve(paymentType); + + final PostLoansLoanIdTransactionsRequest buyDownFeeRequest = LoanRequestFactory.defaultBuyDownFeeIncomeRequest() + .transactionDate(transactionDate).transactionAmount(Double.valueOf(amount)).paymentTypeId(paymentTypeValue) + .externalId("EXT-BUY-DOWN-FEES" + UUID.randomUUID()); + + final Response buyDownFeeResponse = loanTransactionsApi + .executeLoanTransaction(loanId, buyDownFeeRequest, "buyDownFee").execute(); + return buyDownFeeResponse; + } + + @And("Admin adds buy down fee with {string} payment type to the loan on {string} with {string} EUR transaction amount") + public void adminAddsBuyDownFeesToTheLoanOnWithEURTransactionAmount(final String transactionPaymentType, final String transactionDate, + final String amount) throws IOException { + final Response buyDownFeesIncomeResponse = addBuyDownFeeToTheLoanOnWithEURTransactionAmount( + transactionPaymentType, transactionDate, amount); + testContext().set(TestContextKey.LOAN_BUY_DOWN_FEE_RESPONSE, buyDownFeesIncomeResponse); + ErrorHelper.checkSuccessfulApiCall(buyDownFeesIncomeResponse); + } + } diff --git a/fineract-e2e-tests-runner/src/test/resources/features/LoanBuyDownFees.feature b/fineract-e2e-tests-runner/src/test/resources/features/LoanBuyDownFees.feature new file mode 100644 index 000000000..68dc49a4d --- /dev/null +++ b/fineract-e2e-tests-runner/src/test/resources/features/LoanBuyDownFees.feature @@ -0,0 +1,158 @@ +@BuyDownFeeFeature +Feature:Feature: Buy Down Fees + + @TestRailId:C3770 + Scenario: Simple loan with Buy Down fees and full payment - UC1 + When Admin sets the business date to "1 January 2024" + And Admin creates a client with random data + And Admin creates a fully customized loan with the following data: + | LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy | + | LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_BUYDOWN_FEES | 1 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 3 | MONTHS | 1 | MONTHS | 3 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | + And Admin successfully approves the loan on "1 January 2024" with "100" amount and expected disbursement date on "1 January 2024" + And Admin successfully disburse the loan on "1 January 2024" with "100" EUR transaction amount + Then Loan status will be "ACTIVE" + When Admin adds buy down fee with "AUTOPAY" payment type to the loan on "1 January 2024" with "50" EUR transaction amount + Then Loan Repayment schedule has 3 periods, with the following data for periods: + | Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | | + | 1 | 31 | 01 February 2024 | | 66.86 | 33.14 | 0.58 | 0.0 | 0.0 | 33.72 | 0.0 | 0.0 | 0.0 | 33.72 | + | 2 | 29 | 01 March 2024 | | 33.53 | 33.33 | 0.39 | 0.0 | 0.0 | 33.72 | 0.0 | 0.0 | 0.0 | 33.72 | + | 3 | 31 | 01 April 2024 | | 0.0 | 33.53 | 0.2 | 0.0 | 0.0 | 33.73 | 0.0 | 0.0 | 0.0 | 33.73 | + And Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 100.0 | 1.17 | 0.0 | 0.0 | 101.17 | 0.0 | 0.0 | 0.0 | 101.17 | + And Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | false | + And Loan Transactions tab has a "BUY_DOWN_FEE" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | EXPENSE | 450280 | Buy Down Expense | 50.0 | | + | LIABILITY | 145024 | Deferred Capitalized Income | | 50.0 | + When Admin sets the business date to "1 February 2024" + And Customer makes "AUTOPAY" repayment on "01 February 2024" with 33.72 EUR transaction amount + Then Loan status will be "ACTIVE" + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 February 2024 | Repayment | 33.72 | 33.14 | 0.58 | 0.0 | 0.0 | 66.86 | false | + When Admin sets the business date to "1 March 2024" + And Customer makes "AUTOPAY" repayment on "01 March 2024" with 33.72 EUR transaction amount + When Admin sets the business date to "1 April 2024" + When Admin runs inline COB job for Loan + And Customer makes "AUTOPAY" repayment on "01 April 2024" with 33.73 EUR transaction amount + Then Loan status will be "CLOSED_OBLIGATIONS_MET" + And Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 February 2024 | Repayment | 33.72 | 33.14 | 0.58 | 0.0 | 0.0 | 66.86 | false | + | 01 March 2024 | Repayment | 33.72 | 33.33 | 0.39 | 0.0 | 0.0 | 33.53 | false | + | 31 March 2024 | Accrual | 1.16 | 0.0 | 1.16 | 0.0 | 0.0 | 0.0 | false | + | 01 April 2024 | Repayment | 33.73 | 33.53 | 0.2 | 0.0 | 0.0 | 0.0 | false | + | 01 April 2024 | Accrual | 0.01 | 0.0 | 0.01 | 0.0 | 0.0 | 0.0 | false | + + @TestRailId:C3771 + Scenario: Loan with Buy Down fees and early payoff - UC2 + When Admin sets the business date to "1 January 2024" + And Admin creates a client with random data + And Admin creates a fully customized loan with the following data: + | LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy | + | LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_BUYDOWN_FEES | 1 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 3 | MONTHS | 1 | MONTHS | 3 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | + And Admin successfully approves the loan on "1 January 2024" with "100" amount and expected disbursement date on "1 January 2024" + And Admin successfully disburse the loan on "1 January 2024" with "100" EUR transaction amount + Then Loan status will be "ACTIVE" + When Admin adds buy down fee with "AUTOPAY" payment type to the loan on "1 January 2024" with "50" EUR transaction amount + Then Loan Repayment schedule has 3 periods, with the following data for periods: + | Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | | + | 1 | 31 | 01 February 2024 | | 66.86 | 33.14 | 0.58 | 0.0 | 0.0 | 33.72 | 0.0 | 0.0 | 0.0 | 33.72 | + | 2 | 29 | 01 March 2024 | | 33.53 | 33.33 | 0.39 | 0.0 | 0.0 | 33.72 | 0.0 | 0.0 | 0.0 | 33.72 | + | 3 | 31 | 01 April 2024 | | 0.0 | 33.53 | 0.2 | 0.0 | 0.0 | 33.73 | 0.0 | 0.0 | 0.0 | 33.73 | + And Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 100.0 | 1.17 | 0.0 | 0.0 | 101.17 | 0.0 | 0.0 | 0.0 | 101.17 | + And Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | false | + And Loan Transactions tab has a "BUY_DOWN_FEE" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | EXPENSE | 450280 | Buy Down Expense | 50.0 | | + | LIABILITY | 145024 | Deferred Capitalized Income | | 50.0 | + When Admin sets the business date to "1 February 2024" + And Customer makes "AUTOPAY" repayment on "01 February 2024" with 33.72 EUR transaction amount + Then Loan status will be "ACTIVE" + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 February 2024 | Repayment | 33.72 | 33.14 | 0.58 | 0.0 | 0.0 | 66.86 | false | + When Admin sets the business date to "1 March 2024" + When Loan Pay-off is made on "1 March 2024" + Then Loan's all installments have obligations met + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 February 2024 | Repayment | 33.72 | 33.14 | 0.58 | 0.0 | 0.0 | 66.86 | false | + | 01 March 2024 | Repayment | 67.25 | 66.86 | 0.39 | 0.0 | 0.0 | 0.0 | false | + | 01 March 2024 | Accrual | 0.97 | 0.0 | 0.97 | 0.0 | 0.0 | 0.0 | false | + + @TestRailId:C3772 + Scenario: Loan with Buy Down fees and charge-off - UC3 + When Admin sets the business date to "1 January 2024" + And Admin creates a client with random data + And Admin creates a fully customized loan with the following data: + | LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy | + | LP2_PROGRESSIVE_ADVANCED_PAYMENT_ALLOCATION_BUYDOWN_FEES | 1 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 3 | MONTHS | 1 | MONTHS | 3 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | + And Admin successfully approves the loan on "1 January 2024" with "100" amount and expected disbursement date on "1 January 2024" + And Admin successfully disburse the loan on "1 January 2024" with "100" EUR transaction amount + Then Loan status will be "ACTIVE" + When Admin adds buy down fee with "AUTOPAY" payment type to the loan on "1 January 2024" with "50" EUR transaction amount + Then Loan Repayment schedule has 3 periods, with the following data for periods: + | Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | | + | 1 | 31 | 01 February 2024 | | 66.86 | 33.14 | 0.58 | 0.0 | 0.0 | 33.72 | 0.0 | 0.0 | 0.0 | 33.72 | + | 2 | 29 | 01 March 2024 | | 33.53 | 33.33 | 0.39 | 0.0 | 0.0 | 33.72 | 0.0 | 0.0 | 0.0 | 33.72 | + | 3 | 31 | 01 April 2024 | | 0.0 | 33.53 | 0.2 | 0.0 | 0.0 | 33.73 | 0.0 | 0.0 | 0.0 | 33.73 | + And Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 100.0 | 1.17 | 0.0 | 0.0 | 101.17 | 0.0 | 0.0 | 0.0 | 101.17 | + And Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | false | + And Loan Transactions tab has a "BUY_DOWN_FEE" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | EXPENSE | 450280 | Buy Down Expense | 50.0 | | + | LIABILITY | 145024 | Deferred Capitalized Income | | 50.0 | + When Admin sets the business date to "1 February 2024" + And Customer makes "AUTOPAY" repayment on "01 February 2024" with 33.72 EUR transaction amount + Then Loan status will be "ACTIVE" + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 February 2024 | Repayment | 33.72 | 33.14 | 0.58 | 0.0 | 0.0 | 66.86 | false | + When Admin sets the business date to "1 March 2024" + And Admin does charge-off the loan on "1 March 2024" + Then Loan status will be "ACTIVE" + And Loan marked as charged-off on "01 March 2024" + And Loan Transactions tab has a "CHARGE_OFF" transaction with date "01 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | ASSET | 112601 | Loans Receivable | | 66.86 | + | ASSET | 112603 | Interest/Fee Receivable | | 0.59 | + | EXPENSE | 744007 | Credit Loss/Bad Debt | 66.86 | | + | INCOME | 404001 | Interest Income Charge Off | 0.59 | | + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 January 2024 | Buy Down Fee | 50.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | + | 01 February 2024 | Repayment | 33.72 | 33.14 | 0.58 | 0.0 | 0.0 | 66.86 | false | + | 01 March 2024 | Accrual | 0.97 | 0.0 | 0.97 | 0.0 | 0.0 | 0.0 | false | + | 01 March 2024 | Charge-off | 67.45 | 66.86 | 0.59 | 0.0 | 0.0 | 0.0 | false | + + When Loan Pay-off is made on "1 March 2024" + Then Loan's all installments have obligations met