FINERACT-2107: Fix transaction order
This commit is contained in:
committed by
Arnold Gálovics
parent
15e013b90e
commit
3e64cc1536
+11
-4
@@ -860,7 +860,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
||||
transactionDate, txnExternalId);
|
||||
|
||||
final boolean isTransactionChronologicallyLatest = loan.isChronologicallyLatestRepaymentOrWaiver(refundTransaction);
|
||||
loan.getLoanTransactions().add(refundTransaction);
|
||||
|
||||
boolean shouldCreateInterestRefundTransaction = loan.getLoanProductRelatedDetail().getSupportedInterestRefundTypes().stream()
|
||||
.map(LoanSupportedInterestRefundTypes::getTransactionType)
|
||||
@@ -869,9 +868,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
||||
|
||||
if (shouldCreateInterestRefundTransaction) {
|
||||
interestRefundTransaction = createInterestRefundLoanTransaction(loan, transactionDate, transactionAmount);
|
||||
if (interestRefundTransaction != null) {
|
||||
loan.addLoanTransaction(interestRefundTransaction);
|
||||
}
|
||||
}
|
||||
|
||||
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = transactionProcessorFactory
|
||||
@@ -887,13 +883,24 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
||||
|| !currentInstallment.getTotalOutstanding(loan.getCurrency()).isEqualTo(refundTransaction.getAmount(loan.getCurrency())); //
|
||||
|
||||
if (!reprocess) {
|
||||
loan.getLoanTransactions().add(refundTransaction);
|
||||
loanRepaymentScheduleTransactionProcessor.processLatestTransaction(refundTransaction,
|
||||
new TransactionCtx(loan.getCurrency(), loan.getRepaymentScheduleInstallments(), loan.getActiveCharges(),
|
||||
new MoneyHolder(loan.getTotalOverpaidAsMoney()), null));
|
||||
if (interestRefundTransaction != null) {
|
||||
loan.addLoanTransaction(interestRefundTransaction);
|
||||
loanRepaymentScheduleTransactionProcessor.processLatestTransaction(interestRefundTransaction,
|
||||
new TransactionCtx(loan.getCurrency(), loan.getRepaymentScheduleInstallments(), loan.getActiveCharges(),
|
||||
new MoneyHolder(loan.getTotalOverpaidAsMoney()), null));
|
||||
}
|
||||
} else {
|
||||
if (loan.getLoanRepaymentScheduleDetail().isInterestRecalculationEnabled()) {
|
||||
loan.regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO);
|
||||
}
|
||||
loan.getLoanTransactions().add(refundTransaction);
|
||||
if (interestRefundTransaction != null) {
|
||||
loan.addLoanTransaction(interestRefundTransaction);
|
||||
}
|
||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = loan.retrieveListOfTransactionsForReprocessing();
|
||||
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.reprocessLoanTransactions(
|
||||
loan.getDisbursementDate(), allNonContraTransactionsPostDisbursement, loan.getCurrency(),
|
||||
|
||||
Reference in New Issue
Block a user