FINERACT-1981: Fix Disbursement on overpaid loan (Cumulative)
This commit is contained in:
+2
-2
@@ -534,8 +534,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
||||
final List<Long> existingTransactionIds = new ArrayList<>();
|
||||
final List<Long> existingReversedTransactionIds = new ArrayList<>();
|
||||
final Money amount = Money.of(loan.getCurrency(), transactionAmount);
|
||||
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), amount, paymentDetail, transactionDate,
|
||||
txnExternalId, loan.getTotalOverpaidAsMoney());
|
||||
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan, amount, paymentDetail, transactionDate, txnExternalId,
|
||||
loan.getTotalOverpaidAsMoney());
|
||||
|
||||
// Subtract Previous loan outstanding balance from netDisbursalAmount
|
||||
loan.deductFromNetDisbursalAmount(transactionAmount);
|
||||
|
||||
+1
-1
@@ -1715,7 +1715,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
|
||||
public Collection<DisbursementData> retrieveLoanDisbursementDetails(final Long loanId) {
|
||||
final LoanDisbursementDetailMapper rm = new LoanDisbursementDetailMapper(sqlGenerator);
|
||||
final String sql = "select " + rm.schema()
|
||||
+ " where dd.loan_id=? and dd.is_reversed=false group by dd.id, lc.amount_waived_derived order by dd.expected_disburse_date,dd.disbursedon_date";
|
||||
+ " where dd.loan_id=? and dd.is_reversed=false group by dd.id, lc.amount_waived_derived order by dd.expected_disburse_date,dd.disbursedon_date,dd.id";
|
||||
return this.jdbcTemplate.query(sql, rm, loanId); // NOSONAR
|
||||
}
|
||||
|
||||
|
||||
+12
-13
@@ -435,8 +435,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
} else {
|
||||
existingTransactionIds.addAll(loan.findExistingTransactionIds());
|
||||
existingReversedTransactionIds.addAll(loan.findExistingReversedTransactionIds());
|
||||
disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), amountToDisburse, paymentDetail,
|
||||
actualDisbursementDate, txnExternalId, loan.getTotalOverpaidAsMoney());
|
||||
disbursementTransaction = LoanTransaction.disbursement(loan, amountToDisburse, paymentDetail, actualDisbursementDate,
|
||||
txnExternalId, loan.getTotalOverpaidAsMoney());
|
||||
disbursementTransaction.updateLoan(loan);
|
||||
loan.addLoanTransaction(disbursementTransaction);
|
||||
}
|
||||
@@ -461,6 +461,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
if (disbursementTransaction != null) {
|
||||
loanTransactionRepository.saveAndFlush(disbursementTransaction);
|
||||
}
|
||||
if (changedTransactionDetail != null) {
|
||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||
loanAccountDomainService.saveLoanTransactionWithDataIntegrityViolationChecks(mapEntry.getValue());
|
||||
accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||
}
|
||||
// Trigger transaction replayed event
|
||||
replayedTransactionBusinessEventService.raiseTransactionReplayedEvents(changedTransactionDetail);
|
||||
}
|
||||
if (loan.isAutoRepaymentForDownPaymentEnabled()) {
|
||||
// updating linked savings account for auto down payment transaction for disbursement to savings account
|
||||
if (isAccountTransfer && loan.shouldCreateStandingInstructionAtDisbursement()) {
|
||||
@@ -490,14 +498,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
}
|
||||
}
|
||||
if (!changes.isEmpty()) {
|
||||
if (changedTransactionDetail != null) {
|
||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||
loanAccountDomainService.saveLoanTransactionWithDataIntegrityViolationChecks(mapEntry.getValue());
|
||||
accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||
}
|
||||
// Trigger transaction replayed event
|
||||
replayedTransactionBusinessEventService.raiseTransactionReplayedEvents(changedTransactionDetail);
|
||||
}
|
||||
|
||||
loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
|
||||
|
||||
final String noteText = command.stringValueOfParameterNamed("note");
|
||||
@@ -563,8 +564,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
businessEventNotifierService.notifyPostBusinessEvent(new LoanDisbursalTransactionBusinessEvent(disbursalTransaction));
|
||||
}
|
||||
|
||||
loan.updateLoanSummaryAndStatus();
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
.withEntityId(loan.getId()) //
|
||||
@@ -751,7 +750,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
} else {
|
||||
existingTransactionIds.addAll(loan.findExistingTransactionIds());
|
||||
existingReversedTransactionIds.addAll(loan.findExistingReversedTransactionIds());
|
||||
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), disburseAmount, paymentDetail,
|
||||
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan, disburseAmount, paymentDetail,
|
||||
actualDisbursementDate, txnExternalId, loan.getTotalOverpaidAsMoney());
|
||||
disbursementTransaction.updateLoan(loan);
|
||||
loan.addLoanTransaction(disbursementTransaction);
|
||||
|
||||
Reference in New Issue
Block a user