FINERACT-1724: Accrual transactions - external id fix
This commit is contained in:
committed by
Adam Saghy
parent
47aceb923d
commit
81e3e2200b
-6
@@ -229,12 +229,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
principalPortion, interestPortion, feesPortion, penaltiesPortion, overPaymentPortion, reversed, paymentDetail, externalId);
|
||||
}
|
||||
|
||||
public static LoanTransaction accrual(final Loan loan, final Office office, final Money amount, final Money interest,
|
||||
final Money feeCharges, final Money penaltyCharges, final LocalDate transactionDate, final ExternalId externalId) {
|
||||
return accrueTransaction(loan, office, transactionDate, amount.getAmount(), interest.getAmount(), feeCharges.getAmount(),
|
||||
penaltyCharges.getAmount(), externalId);
|
||||
}
|
||||
|
||||
public static LoanTransaction accrueTransaction(final Loan loan, final Office office, final LocalDate dateOf, final BigDecimal amount,
|
||||
final BigDecimal interestPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion,
|
||||
final ExternalId externalId) {
|
||||
|
||||
+7
-5
@@ -33,6 +33,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.infrastructure.core.service.ExternalIdFactory;
|
||||
import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanAccrualTransactionCreatedBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
||||
@@ -75,6 +76,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
|
||||
private final LoanTransactionRepository loanTransactionRepository;
|
||||
private final LoanAccrualTransactionBusinessEventService loanAccrualTransactionBusinessEventService;
|
||||
private final ConfigurationDomainService configurationDomainService;
|
||||
private final ExternalIdFactory externalIdFactory;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -263,13 +265,13 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
|
||||
BigDecimal totalAccInterest, BigDecimal feePortion, BigDecimal totalAccFee, BigDecimal penaltyPortion,
|
||||
BigDecimal totalAccPenalty, final LocalDate accruedTill) throws DataAccessException {
|
||||
AppUser user = context.authenticatedUser();
|
||||
String transactionSql = "INSERT INTO m_loan_transaction (loan_id,office_id,is_reversed,transaction_type_enum,transaction_date,amount,interest_portion_derived,"
|
||||
String transactionSql = "INSERT INTO m_loan_transaction (loan_id,office_id,is_reversed,external_id,transaction_type_enum,transaction_date,amount,interest_portion_derived,"
|
||||
+ "fee_charges_portion_derived,penalty_charges_portion_derived, submitted_on_date, created_by, last_modified_by, created_on_utc, last_modified_on_utc) "
|
||||
+ "VALUES (?, ?, false, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
+ "VALUES (?, ?, false, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
this.jdbcTemplate.update(transactionSql, scheduleAccrualData.getLoanId(), scheduleAccrualData.getOfficeId(),
|
||||
LoanTransactionType.ACCRUAL.getValue(), accruedTill, amount, interestPortion, feePortion, penaltyPortion,
|
||||
DateUtils.getBusinessLocalDate(), user.getId(), user.getId(), DateUtils.getOffsetDateTimeOfTenant(),
|
||||
DateUtils.getOffsetDateTimeOfTenant());
|
||||
externalIdFactory.create().getValue(), LoanTransactionType.ACCRUAL.getValue(), accruedTill, amount, interestPortion,
|
||||
feePortion, penaltyPortion, DateUtils.getBusinessLocalDate(), user.getId(), user.getId(),
|
||||
DateUtils.getOffsetDateTimeOfTenant(), DateUtils.getOffsetDateTimeOfTenant());
|
||||
final Long transactionId = this.jdbcTemplate.queryForObject("SELECT " + sqlGenerator.lastInsertId(), Long.class); // NOSONAR
|
||||
|
||||
Map<LoanChargeData, BigDecimal> applicableCharges = scheduleAccrualData.getApplicableCharges();
|
||||
|
||||
+6
-5
@@ -487,13 +487,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
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,"
|
||||
String transactionSql = "INSERT INTO m_loan_transaction (loan_id,office_id,is_reversed,external_id,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, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
+ "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());
|
||||
jdbcTemplate.update(transactionSql, loanId, loan.getOfficeId(), externalIdFactory.create().getValue(),
|
||||
LoanTransactionType.ACCRUAL.getValue(), actualDisbursementDate, loanCharge.amount(), loanCharge.amount(),
|
||||
DateUtils.getBusinessLocalDate(), user.getId(), user.getId(), DateUtils.getOffsetDateTimeOfTenant(),
|
||||
DateUtils.getOffsetDateTimeOfTenant());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -106,6 +106,7 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.platform.commons.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -3046,6 +3047,8 @@ public class ClientLoanIntegrationTest {
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
|
||||
GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec,
|
||||
GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true);
|
||||
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
|
||||
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
|
||||
@@ -4755,6 +4758,7 @@ public class ClientLoanIntegrationTest {
|
||||
.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"));
|
||||
assertTrue(StringUtils.isNotBlank((String) accrualTransactions.get(0).get("externalId")));
|
||||
}
|
||||
|
||||
private void addRepaymentValues(List<Map<String, Object>> expectedvalues, Calendar todaysDate, int addPeriod, boolean isAddDays,
|
||||
@@ -6512,6 +6516,8 @@ public class ClientLoanIntegrationTest {
|
||||
Integer feeLoanChargeId = this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper
|
||||
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(feeCharge.getResourceId()), feeCharge1AddedDate, "3"));
|
||||
|
||||
GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec,
|
||||
GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true);
|
||||
final String feeLoanChargeDate = dateFormatter.format(targetDate);
|
||||
this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(feeLoanChargeDate);
|
||||
|
||||
@@ -6520,6 +6526,7 @@ public class ClientLoanIntegrationTest {
|
||||
assertEquals(3.0, transactions.get(2).getAmount());
|
||||
assertTrue(transactions.get(2).getType().getAccrual());
|
||||
assertEquals(3.0, transactions.get(2).getFeeChargesPortion());
|
||||
assertTrue(StringUtils.isNotBlank(transactions.get(2).getExternalId()));
|
||||
accrualTransactionId = transactions.get(2).getId();
|
||||
|
||||
journalEntries = this.journalEntryHelper.getJournalEntriesByTransactionId("L" + accrualTransactionId);
|
||||
|
||||
Reference in New Issue
Block a user