Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FINERACT-1724-9: Fixing the retrieval of loan charge details with including the loanId as well #2688

Merged
merged 1 commit into from Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -67,7 +67,7 @@ public String schema() {
+ "lc.due_for_collection_as_of_date as dueAsOfDate, " + "lc.charge_calculation_enum as chargeCalculation, "
+ "lc.charge_payment_mode_enum as chargePaymentMode, " + "lc.is_paid_derived as paid, " + "lc.waived as waied, "
+ "lc.min_cap as minCap, lc.max_cap as maxCap, " + "lc.charge_amount_or_percentage as amountOrPercentage, "
+ "c.currency_code as currencyCode, oc.name as currencyName, "
+ "lc.loan_id as loanId, c.currency_code as currencyCode, oc.name as currencyName, "
+ "date(coalesce(dd.disbursedon_date,dd.expected_disburse_date)) as disbursementDate, "
+ "oc.decimal_places as currencyDecimalPlaces, oc.currency_multiplesof as inMultiplesOf, oc.display_symbol as currencyDisplaySymbol, "
+ "oc.internationalized_name_code as currencyNameCode from m_charge c "
Expand All @@ -79,6 +79,7 @@ public String schema() {
public LoanChargeData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
final Long id = rs.getLong("id");
final Long chargeId = rs.getLong("chargeId");
final Long loanId = rs.getLong("loanId");
final String name = rs.getString("name");
final BigDecimal amount = rs.getBigDecimal("amountDue");
final BigDecimal amountPaid = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "amountPaid");
Expand Down Expand Up @@ -125,7 +126,7 @@ public LoanChargeData mapRow(final ResultSet rs, @SuppressWarnings("unused") fin

return new LoanChargeData(id, chargeId, name, currency, amount, amountPaid, amountWaived, amountWrittenOff, amountOutstanding,
chargeTimeType, submittedOnDate, dueAsOfDate, chargeCalculationType, percentageOf, amountPercentageAppliedTo, penalty,
paymentMode, paid, waived, null, minCap, maxCap, amountOrPercentage, null, externalId);
paymentMode, paid, waived, loanId, minCap, maxCap, amountOrPercentage, null, externalId);
}
}

Expand Down
Expand Up @@ -147,6 +147,29 @@ public void validateClientLoanWithUniqueExternalId() {
applyForLoanApplicationWithExternalId(this.requestSpec, responseSpec403, clientID, loanProductID, "12,000.00", externalId);
}

@Test
public void testAddingLoanChargeIncludesLoanIdInTheResponse() {
// given
loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Integer loanProductId = createLoanProduct(false, NONE);
Integer collateralId = CollateralManagementHelper.createCollateralProduct(this.requestSpec, this.responseSpec);
Integer clientCollateralId = CollateralManagementHelper.createClientCollateral(this.requestSpec, this.responseSpec,
String.valueOf(clientId), collateralId);
List<HashMap> collaterals = List.of(collaterals(clientCollateralId, BigDecimal.ONE));

Integer chargeId = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1"));
List<HashMap> charges = List.of(charges(chargeId, "1", null));
// when
Integer loanId = applyForLoanApplication(clientId, loanProductId, charges, null, "12,000.00", collaterals);
// then
List<HashMap> loanCharges = loanTransactionHelper.getLoanCharges(loanId);
Integer loanChargeId = (Integer) loanCharges.get(0).get("id");
HashMap loanChargeDetail = loanTransactionHelper.getLoanCharge(loanId, loanChargeId);
assertEquals(loanId, loanChargeDetail.get("loanId"));
}

@Test
public void testLoanCharges_DISBURSEMENT_FEE() {
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
Expand Down