FINERACT-2042 Chargeback with credit allocation, accounting
This commit is contained in:
committed by
Peter Bagrij
parent
5f9845f86a
commit
697449e7e7
+5
@@ -60,4 +60,9 @@ public class LoanTransactionDTO {
|
||||
|
||||
private final String chargeRefundChargeType;
|
||||
private final LoanChargeData loanChargeData;
|
||||
|
||||
/** In case chargeback and overpayment the below field contains the distribution payment **/
|
||||
private final BigDecimal principalPaid;
|
||||
private final BigDecimal feePaid;
|
||||
private final BigDecimal penaltyPaid;
|
||||
}
|
||||
|
||||
+7
-1
@@ -156,9 +156,15 @@ public class AccountingProcessorHelper {
|
||||
isAccountTransfer = this.accountTransfersReadPlatformService.isAccountTransfer(Long.parseLong(transactionId),
|
||||
PortfolioAccountType.LOAN);
|
||||
}
|
||||
|
||||
BigDecimal principalPaid = (BigDecimal) map.get("principalPaid");
|
||||
BigDecimal feePaid = (BigDecimal) map.get("feePaid");
|
||||
BigDecimal penaltyPaid = (BigDecimal) map.get("penaltyPaid");
|
||||
|
||||
final LoanTransactionDTO transaction = new LoanTransactionDTO(transactionOfficeId, paymentTypeId, transactionId,
|
||||
transactionDate, transactionType, amount, principal, interest, fees, penalties, overPayments, reversed,
|
||||
penaltyPaymentDetails, feePaymentDetails, isAccountTransfer, chargeRefundChargeType, loanChargeData);
|
||||
penaltyPaymentDetails, feePaymentDetails, isAccountTransfer, chargeRefundChargeType, loanChargeData, principalPaid,
|
||||
feePaid, penaltyPaid);
|
||||
Boolean isLoanToLoanTransfer = (Boolean) accountingBridgeData.get("isLoanToLoanTransfer");
|
||||
transaction.setLoanToLoanTransfer(isLoanToLoanTransfer != null && isLoanToLoanTransfer);
|
||||
newLoanTransactions.add(transaction);
|
||||
|
||||
+44
-15
@@ -430,25 +430,54 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
final BigDecimal overpaidAmount = Objects.isNull(loanTransactionDTO.getOverPayment()) ? BigDecimal.ZERO
|
||||
: loanTransactionDTO.getOverPayment();
|
||||
|
||||
if (BigDecimal.ZERO.compareTo(overpaidAmount) == 0) { // when no overpay
|
||||
helper.createJournalEntriesAndReversalsForLoan(office, currencyCode, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
|
||||
AccrualAccountsForLoan.FUND_SOURCE.getValue(), loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
amount, isReversal);
|
||||
} else if (overpaidAmount.compareTo(amount) >= 0) { // when the overpay amount is matching with the normal
|
||||
// amount
|
||||
helper.createJournalEntriesAndReversalsForLoan(office, currencyCode, AccrualAccountsForLoan.OVERPAYMENT.getValue(),
|
||||
AccrualAccountsForLoan.FUND_SOURCE.getValue(), loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
amount, isReversal);
|
||||
} else {
|
||||
BigDecimal diff = amount.subtract(overpaidAmount);
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, diff, isReversal);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.FUND_SOURCE, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, amount, isReversal);
|
||||
final BigDecimal principalCredited = Objects.isNull(loanTransactionDTO.getPrincipal()) ? BigDecimal.ZERO
|
||||
: loanTransactionDTO.getPrincipal();
|
||||
final BigDecimal feeCredited = Objects.isNull(loanTransactionDTO.getFees()) ? BigDecimal.ZERO : loanTransactionDTO.getFees();
|
||||
final BigDecimal penaltyCredited = Objects.isNull(loanTransactionDTO.getPenalties()) ? BigDecimal.ZERO
|
||||
: loanTransactionDTO.getPenalties();
|
||||
|
||||
final BigDecimal principalPaid = Objects.isNull(loanTransactionDTO.getPrincipalPaid()) ? BigDecimal.ZERO
|
||||
: loanTransactionDTO.getPrincipalPaid();
|
||||
final BigDecimal feePaid = Objects.isNull(loanTransactionDTO.getFeePaid()) ? BigDecimal.ZERO : loanTransactionDTO.getFeePaid();
|
||||
final BigDecimal penaltyPaid = Objects.isNull(loanTransactionDTO.getPenaltyPaid()) ? BigDecimal.ZERO
|
||||
: loanTransactionDTO.getPenaltyPaid();
|
||||
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.FUND_SOURCE, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, amount, isReversal);
|
||||
|
||||
if (overpaidAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.OVERPAYMENT.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, overpaidAmount, isReversal);
|
||||
}
|
||||
|
||||
if (principalCredited.compareTo(principalPaid) > 0) {
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalCredited.subtract(principalPaid),
|
||||
isReversal);
|
||||
} else if (principalCredited.compareTo(principalPaid) < 0) {
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalPaid.subtract(principalCredited),
|
||||
isReversal);
|
||||
}
|
||||
|
||||
if (feeCredited.compareTo(feePaid) > 0) {
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.FEES_RECEIVABLE.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, feeCredited.subtract(feePaid), isReversal);
|
||||
} else if (feeCredited.compareTo(feePaid) < 0) {
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.FEES_RECEIVABLE.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, feePaid.subtract(feeCredited), isReversal);
|
||||
}
|
||||
|
||||
if (penaltyCredited.compareTo(penaltyPaid) > 0) {
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.PENALTIES_RECEIVABLE.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, penaltyCredited.subtract(penaltyPaid),
|
||||
isReversal);
|
||||
} else if (penaltyCredited.compareTo(penaltyPaid) < 0) {
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, AccrualAccountsForLoan.PENALTIES_RECEIVABLE.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, penaltyPaid.subtract(penaltyCredited),
|
||||
isReversal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user