This is an automated email from the ASF dual-hosted git repository.

arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new d1f3ffe49 FINERACT-1724-9: Fixing the retrieval of loan charge details 
with including the loanId as well
d1f3ffe49 is described below

commit d1f3ffe4902b4451c925572f9d6f804a91505ff7
Author: Arnold Galovics <[email protected]>
AuthorDate: Thu Oct 20 13:17:26 2022 +0200

    FINERACT-1724-9: Fixing the retrieval of loan charge details with including 
the loanId as well
---
 .../service/LoanChargeReadPlatformServiceImpl.java |  5 +++--
 .../ClientLoanIntegrationTest.java                 | 23 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeReadPlatformServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeReadPlatformServiceImpl.java
index f9300bcc2..69725b0d7 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeReadPlatformServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeReadPlatformServiceImpl.java
@@ -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);
         }
     }
 
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
index d068f74ab..26273f3aa 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
@@ -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);

Reply via email to