You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ta...@apache.org on 2023/05/16 12:05:02 UTC
[fineract] branch develop updated: [FINERACT-1906] Add disbursement charge to accrual transactions
This is an automated email from the ASF dual-hosted git repository.
taskain 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 6e69e66b8 [FINERACT-1906] Add disbursement charge to accrual transactions
6e69e66b8 is described below
commit 6e69e66b864a7d2352b1e2e2717779df65a03c0f
Author: taskain7 <ta...@gmail.com>
AuthorDate: Thu May 11 09:37:56 2023 +0200
[FINERACT-1906] Add disbursement charge to accrual transactions
---
.../service/LoanWritePlatformServiceJpaRepositoryImpl.java | 11 +++++++++++
.../integrationtests/ClientLoanIntegrationTest.java | 13 +++++++++++++
2 files changed, 24 insertions(+)
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
index 816e343fb..10f1c102f 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
@@ -192,6 +192,7 @@ import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.transfer.api.TransferApiConstants;
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -245,6 +246,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
private final ExternalIdFactory externalIdFactory;
private final ReplayedTransactionBusinessEventService replayedTransactionBusinessEventService;
private final LoanAccrualTransactionBusinessEventService loanAccrualTransactionBusinessEventService;
+ private final JdbcTemplate jdbcTemplate;
@Transactional
@Override
@@ -484,6 +486,15 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
&& loanCharge.isChargePending()) {
disBuLoanCharges.put(loanCharge.getId(), loanCharge.amountOutstanding());
}
+ if (loanCharge.isDisbursementCharge()) {
+ String transactionSql = "INSERT INTO m_loan_transaction (loan_id,office_id,is_reversed,transaction_type_enum,transaction_date,amount,"
+ + "fee_charges_portion_derived, submitted_on_date, created_by, last_modified_by, created_on_utc, last_modified_on_utc) "
+ + "VALUES (?, ?, false, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ AppUser user = context.authenticatedUser();
+ jdbcTemplate.update(transactionSql, loanId, loan.getOfficeId(), LoanTransactionType.ACCRUAL.getValue(),
+ actualDisbursementDate, loanCharge.amount(), loanCharge.amount(), DateUtils.getBusinessLocalDate(), user.getId(),
+ user.getId(), DateUtils.getOffsetDateTimeOfTenant(), DateUtils.getOffsetDateTimeOfTenant());
+ }
}
final Locale locale = command.extractLocale();
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 b204a2e88..68c2444ff 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
@@ -46,6 +46,7 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -3050,6 +3051,8 @@ public class ClientLoanIntegrationTest {
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
+ ArrayList<HashMap> loanTransactionDetails = loanTransactionHelper.getLoanTransactionDetails(requestSpec, responseSpec, 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) };
@@ -4744,6 +4747,16 @@ public class ClientLoanIntegrationTest {
LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap);
}
+ private void validateAccrualTransactionForDisbursementCharge(ArrayList<HashMap> loanTransactionDetails) {
+ List<HashMap> disbursementTransactions = loanTransactionDetails.stream()
+ .filter(transactionDetail -> (Boolean) ((LinkedHashMap) transactionDetail.get("type")).get("repaymentAtDisbursement"))
+ .toList();
+ List<HashMap> accrualTransactions = loanTransactionDetails.stream()
+ .filter(transactionDetail -> (Boolean) ((LinkedHashMap) transactionDetail.get("type")).get("accrual")).toList();
+ assertEquals(disbursementTransactions.size(), accrualTransactions.size(), 1);
+ assertEquals((Float) disbursementTransactions.get(0).get("amount"), (Float) accrualTransactions.get(0).get("amount"));
+ }
+
private void addRepaymentValues(List<Map<String, Object>> expectedvalues, Calendar todaysDate, int addPeriod, boolean isAddDays,
String principalDue, String interestDue, String feeChargesDue, String penaltyChargesDue) {
Map<String, Object> values = new HashMap<>(3);