ruchiD commented on code in PR #3465:
URL: https://github.com/apache/fineract/pull/3465#discussion_r1332883293
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java:
##########
@@ -2541,204 +2541,208 @@ public void
loanWithFlatChargesAndPeriodicAccrualAccountingEnabled() throws Inte
*/
@Test
public void
loanWithChargesOfTypeAmountPercentageAndPeriodicAccrualAccountingEnabled()
throws InterruptedException {
+ try {
+ final Integer clientID = ClientHelper.createClient(REQUEST_SPEC,
RESPONSE_SPEC);
+ ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC,
RESPONSE_SPEC, clientID);
- final Integer clientID = ClientHelper.createClient(REQUEST_SPEC,
RESPONSE_SPEC);
- ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC,
clientID);
-
- // Add charges with payment mode regular
- List<HashMap> charges = new ArrayList<>();
- Integer percentageDisbursementCharge =
ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
-
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
"1"));
- addCharges(charges, percentageDisbursementCharge, "1", null);
-
- Integer percentageSpecifiedDueDateCharge =
ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
-
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
"1", false));
- addCharges(charges, percentageSpecifiedDueDateCharge, "1", "29
September 2011");
-
- Integer percentageInstallmentFee =
ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
-
ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
"1", false));
- addCharges(charges, percentageInstallmentFee, "1", "29 September
2011");
-
- final Account assetAccount = ACCOUNT_HELPER.createAssetAccount();
- final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount();
- final Account expenseAccount = ACCOUNT_HELPER.createExpenseAccount();
- final Account overpaymentAccount =
ACCOUNT_HELPER.createLiabilityAccount();
-
- List<HashMap> collaterals = new ArrayList<>();
+ // Add charges with payment mode regular
+ List<HashMap> charges = new ArrayList<>();
+ Integer percentageDisbursementCharge =
ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
+
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
"1"));
+ addCharges(charges, percentageDisbursementCharge, "1", null);
- final Integer collateralId =
CollateralManagementHelper.createCollateralProduct(REQUEST_SPEC, RESPONSE_SPEC);
+ Integer percentageSpecifiedDueDateCharge =
ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
+
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
"1", false));
+ addCharges(charges, percentageSpecifiedDueDateCharge, "1", "29
September 2011");
- final Integer clientCollateralId =
CollateralManagementHelper.createClientCollateral(REQUEST_SPEC, RESPONSE_SPEC,
- String.valueOf(clientID), collateralId);
- addCollaterals(collaterals, clientCollateralId, BigDecimal.valueOf(1));
+ Integer percentageInstallmentFee =
ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
+
ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
"1", false));
+ addCharges(charges, percentageInstallmentFee, "1", "29 September
2011");
- final Integer loanProductID = createLoanProduct(false,
ACCRUAL_PERIODIC, assetAccount, incomeAccount, expenseAccount,
- overpaymentAccount);
- final Integer loanID = applyForLoanApplication(clientID,
loanProductID, charges, null, "12,000.00", collaterals);
- Assertions.assertNotNull(loanID);
- HashMap loanStatusHashMap =
LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
- LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
+ final Account assetAccount = ACCOUNT_HELPER.createAssetAccount();
+ final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount();
+ final Account expenseAccount =
ACCOUNT_HELPER.createExpenseAccount();
+ final Account overpaymentAccount =
ACCOUNT_HELPER.createLiabilityAccount();
- ArrayList<HashMap> loanSchedule =
LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC,
loanID);
- verifyLoanRepaymentSchedule(loanSchedule);
+ List<HashMap> collaterals = new ArrayList<>();
- List<HashMap> loanCharges =
LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
- validateCharge(percentageDisbursementCharge, loanCharges, "1",
"120.00", "0.0", "0.0");
- validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1",
"120.00", "0.0", "0.0");
- validateCharge(percentageInstallmentFee, loanCharges, "1", "120.00",
"0.0", "0.0");
+ final Integer collateralId =
CollateralManagementHelper.createCollateralProduct(REQUEST_SPEC, RESPONSE_SPEC);
- // check for disbursement fee
- HashMap disbursementDetail = loanSchedule.get(0);
- validateNumberForEqual("120.00",
String.valueOf(disbursementDetail.get("feeChargesDue")));
+ final Integer clientCollateralId =
CollateralManagementHelper.createClientCollateral(REQUEST_SPEC, RESPONSE_SPEC,
+ String.valueOf(clientID), collateralId);
+ addCollaterals(collaterals, clientCollateralId,
BigDecimal.valueOf(1));
- // check for charge at specified date and installment fee
- HashMap firstInstallment = loanSchedule.get(1);
- validateNumberForEqual("149.11",
String.valueOf(firstInstallment.get("feeChargesDue")));
+ final Integer loanProductID = createLoanProduct(false,
ACCRUAL_PERIODIC, assetAccount, incomeAccount, expenseAccount,
+ overpaymentAccount);
+ final Integer loanID = applyForLoanApplication(clientID,
loanProductID, charges, null, "12,000.00", collaterals);
+ Assertions.assertNotNull(loanID);
+ HashMap loanStatusHashMap =
LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
+ LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
- // check for installment fee
- HashMap secondInstallment = loanSchedule.get(2);
- validateNumberForEqual("29.70",
String.valueOf(secondInstallment.get("feeChargesDue")));
+ ArrayList<HashMap> loanSchedule =
LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC,
loanID);
+ verifyLoanRepaymentSchedule(loanSchedule);
- LOG.info("-----------------------------------APPROVE
LOAN-----------------------------------------");
- loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan("20 September
2011", loanID);
- LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
- LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
+ List<HashMap> loanCharges =
LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
+ validateCharge(percentageDisbursementCharge, loanCharges, "1",
"120.00", "0.0", "0.0");
+ validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1",
"120.00", "0.0", "0.0");
+ validateCharge(percentageInstallmentFee, loanCharges, "1",
"120.00", "0.0", "0.0");
- LOG.info("-------------------------------DISBURSE
LOAN-------------------------------------------");
- GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC,
RESPONSE_SPEC,
- GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID,
true);
- String loanDetails =
LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID);
- loanStatusHashMap =
LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount("20 September 2011",
loanID,
-
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
- LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
+ // check for disbursement fee
+ HashMap disbursementDetail = loanSchedule.get(0);
+ validateNumberForEqual("120.00",
String.valueOf(disbursementDetail.get("feeChargesDue")));
- ArrayList<HashMap> loanTransactionDetails =
LOAN_TRANSACTION_HELPER.getLoanTransactionDetails(REQUEST_SPEC, RESPONSE_SPEC,
loanID);
-
validateAccrualTransactionForDisbursementCharge(loanTransactionDetails);
- final JournalEntry[] assetAccountInitialEntry = { new
JournalEntry(Float.parseFloat("120.00"), JournalEntry.TransactionType.DEBIT),
- new JournalEntry(Float.parseFloat("12000.00"),
JournalEntry.TransactionType.CREDIT),
- new JournalEntry(Float.parseFloat("12000.00"),
JournalEntry.TransactionType.DEBIT) };
- JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount,
"20 September 2011", assetAccountInitialEntry);
- JOURNAL_ENTRY_HELPER.checkJournalEntryForIncomeAccount(incomeAccount,
"20 September 2011",
- new JournalEntry(Float.parseFloat("120.00"),
JournalEntry.TransactionType.CREDIT));
- loanCharges.clear();
- loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
- validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.0",
"120.00", "0.0");
+ // check for charge at specified date and installment fee
+ HashMap firstInstallment = loanSchedule.get(1);
+ validateNumberForEqual("149.11",
String.valueOf(firstInstallment.get("feeChargesDue")));
- LOG.info("-------------Make repayment 1-----------");
- LOAN_TRANSACTION_HELPER.makeRepayment("20 October 2011",
Float.parseFloat("3300.60"), loanID);
- loanCharges.clear();
- loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
- validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.00",
"120.00", "0.0");
- validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1",
"0.00", "120.0", "0.0");
- validateCharge(percentageInstallmentFee, loanCharges, "1", "90.89",
"29.11", "0.0");
+ // check for installment fee
+ HashMap secondInstallment = loanSchedule.get(2);
+ validateNumberForEqual("29.70",
String.valueOf(secondInstallment.get("feeChargesDue")));
- JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount,
"20 October 2011",
- new JournalEntry(Float.parseFloat("3300.60"),
JournalEntry.TransactionType.DEBIT),
- new JournalEntry(Float.parseFloat("3300.60"),
JournalEntry.TransactionType.CREDIT));
+ LOG.info("-----------------------------------APPROVE
LOAN-----------------------------------------");
+ loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan("20
September 2011", loanID);
+ LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
+
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
- LOAN_TRANSACTION_HELPER.addChargesForLoan(loanID, LoanTransactionHelper
-
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(percentageSpecifiedDueDateCharge),
"29 October 2011", "1"));
- loanSchedule.clear();
- loanSchedule =
LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC,
loanID);
+ LOG.info("-------------------------------DISBURSE
LOAN-------------------------------------------");
+ String loanDetails =
LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID);
Review Comment:
was this configuration setting got deleted and not added again?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]