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

This commit is contained in:
Arnold Galovics
2022-10-21 11:21:21 +02:00
committed by Arnold Gálovics
parent 3cd4db8209
commit d1f3ffe490
2 changed files with 26 additions and 2 deletions
@@ -67,7 +67,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
+ "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 "
@@ -79,6 +79,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
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");
@@ -125,7 +126,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
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);
}
}
@@ -147,6 +147,29 @@ public class ClientLoanIntegrationTest {
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);