FINERACT-1596-Accounting-treatment-changes-goodwill-credit
This commit is contained in:
committed by
Adam Saghy
parent
8d636fab2b
commit
ceb22456ca
+14
-6
@@ -38,8 +38,9 @@ public final class AccountingConstants {
|
||||
|
||||
FUND_SOURCE(1), LOAN_PORTFOLIO(2), INTEREST_ON_LOANS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), LOSSES_WRITTEN_OFF(
|
||||
6), TRANSFERS_SUSPENSE(10), OVERPAYMENT(11), INCOME_FROM_RECOVERY(12), GOODWILL_CREDIT(13), INCOME_FROM_CHARGE_OFF_INTEREST(
|
||||
14), INCOME_FROM_CHARGE_OFF_FEES(
|
||||
15), CHARGE_OFF_EXPENSE(16), CHARGE_OFF_FRAUD_EXPENSE(17), INCOME_FROM_CHARGE_OFF_PENALTY(18);
|
||||
14), INCOME_FROM_CHARGE_OFF_FEES(15), CHARGE_OFF_EXPENSE(16), CHARGE_OFF_FRAUD_EXPENSE(
|
||||
17), INCOME_FROM_CHARGE_OFF_PENALTY(18), INCOME_FROM_GOODWILL_CREDIT_INTEREST(
|
||||
19), INCOME_FROM_GOODWILL_CREDIT_FEES(20), INCOME_FROM_GOODWILL_CREDIT_PENALTY(21);
|
||||
|
||||
private final Integer value;
|
||||
|
||||
@@ -78,8 +79,9 @@ public final class AccountingConstants {
|
||||
FUND_SOURCE(1), LOAN_PORTFOLIO(2), INTEREST_ON_LOANS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), //
|
||||
LOSSES_WRITTEN_OFF(6), INTEREST_RECEIVABLE(7), FEES_RECEIVABLE(8), PENALTIES_RECEIVABLE(9), //
|
||||
TRANSFERS_SUSPENSE(10), OVERPAYMENT(11), INCOME_FROM_RECOVERY(12), GOODWILL_CREDIT(13), INCOME_FROM_CHARGE_OFF_INTEREST(
|
||||
14), INCOME_FROM_CHARGE_OFF_FEES(
|
||||
15), CHARGE_OFF_EXPENSE(16), CHARGE_OFF_FRAUD_EXPENSE(17), INCOME_FROM_CHARGE_OFF_PENALTY(18);
|
||||
14), INCOME_FROM_CHARGE_OFF_FEES(15), CHARGE_OFF_EXPENSE(16), CHARGE_OFF_FRAUD_EXPENSE(17), INCOME_FROM_CHARGE_OFF_PENALTY(
|
||||
18), INCOME_FROM_GOODWILL_CREDIT_INTEREST(
|
||||
19), INCOME_FROM_GOODWILL_CREDIT_FEES(20), INCOME_FROM_GOODWILL_CREDIT_PENALTY(21);
|
||||
|
||||
private final Integer value;
|
||||
|
||||
@@ -134,7 +136,10 @@ public final class AccountingConstants {
|
||||
"incomeFromChargeOffFeesAccountId"), CHARGE_OFF_EXPENSE(
|
||||
"chargeOffExpenseAccountId"), CHARGE_OFF_FRAUD_EXPENSE(
|
||||
"chargeOffFraudExpenseAccountId"), INCOME_FROM_CHARGE_OFF_PENALTY(
|
||||
"incomeFromChargeOffPenaltyAccountId");
|
||||
"incomeFromChargeOffPenaltyAccountId"), INCOME_FROM_GOODWILL_CREDIT_INTEREST(
|
||||
"incomeFromGoodwillCreditInterestAccountId"), INCOME_FROM_GOODWILL_CREDIT_FEES(
|
||||
"incomeFromGoodwillCreditFeesAccountId"), INCOME_FROM_GOODWILL_CREDIT_PENALTY(
|
||||
"incomeFromGoodwillCreditPenaltyAccountId");
|
||||
|
||||
private final String value;
|
||||
|
||||
@@ -168,7 +173,10 @@ public final class AccountingConstants {
|
||||
"incomeFromChargeOffFeesAccount"), CHARGE_OFF_EXPENSE(
|
||||
"chargeOffExpenseAccount"), CHARGE_OFF_FRAUD_EXPENSE(
|
||||
"chargeOffFraudExpenseAccount"), INCOME_FROM_CHARGE_OFF_PENALTY(
|
||||
"incomeFromChargeOffPenaltyAccount");
|
||||
"incomeFromChargeOffPenaltyAccount"), INCOME_FROM_GOODWILL_CREDIT_INTEREST(
|
||||
"incomeFromGoodwillCreditInterestAccount"), INCOME_FROM_GOODWILL_CREDIT_FEES(
|
||||
"incomeFromGoodwillCreditFeesAccount"), INCOME_FROM_GOODWILL_CREDIT_PENALTY(
|
||||
"incomeFromGoodwillCreditPenaltyAccount");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
+58
-8
@@ -186,7 +186,9 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
} else {
|
||||
accountMapForCredit.put(accountCredit, transactionPartAmount);
|
||||
}
|
||||
Integer accountDebit = debitAccountType;
|
||||
Integer accountDebit = returnExistingDebitAccountInMapMatchingGLAccount(loanProductId, paymentTypeId, debitAccountType,
|
||||
accountMapForDebit);
|
||||
|
||||
if (accountMapForDebit.containsKey(accountDebit)) {
|
||||
BigDecimal amount = accountMapForDebit.get(accountDebit).add(transactionPartAmount);
|
||||
accountMapForDebit.put(accountDebit, amount);
|
||||
@@ -595,7 +597,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
} else if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateCreditDebitMaps(loanProductId, interestAmount, paymentTypeId,
|
||||
AccrualAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
AccrualAccountsForLoan.INCOME_FROM_CHARGE_OFF_INTEREST.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isRepayment()) {
|
||||
populateCreditDebitMaps(loanProductId, interestAmount, paymentTypeId,
|
||||
@@ -624,7 +626,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateCreditDebitMaps(loanProductId, feesAmount, paymentTypeId, AccrualAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
AccrualAccountsForLoan.GOODWILL_CREDIT.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isRepayment()) {
|
||||
populateCreditDebitMaps(loanProductId, feesAmount, paymentTypeId, AccrualAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
@@ -667,8 +669,8 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateCreditDebitMaps(loanProductId, penaltiesAmount, paymentTypeId,
|
||||
AccrualAccountsForLoan.INCOME_FROM_RECOVERY.getValue(), AccrualAccountsForLoan.GOODWILL_CREDIT.getValue(),
|
||||
accountMapForCredit, accountMapForDebit);
|
||||
AccrualAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isRepayment()) {
|
||||
populateCreditDebitMaps(loanProductId, penaltiesAmount, paymentTypeId,
|
||||
@@ -780,6 +782,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
BigDecimal totalDebitAmount = new BigDecimal(0);
|
||||
|
||||
Map<GLAccount, BigDecimal> accountMap = new LinkedHashMap<>();
|
||||
Map<Integer, BigDecimal> debitAccountMapForGoodwillCredit = new LinkedHashMap<>();
|
||||
|
||||
// handle principal payment or writeOff (and reversals)
|
||||
if (principalAmount != null && principalAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
@@ -787,6 +790,10 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
|
||||
AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(), paymentTypeId);
|
||||
accountMap.put(account, principalAmount);
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, principalAmount, AccrualAccountsForLoan.GOODWILL_CREDIT.getValue(),
|
||||
debitAccountMapForGoodwillCredit, paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
// handle interest payment of writeOff (and reversals)
|
||||
@@ -800,6 +807,11 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
} else {
|
||||
accountMap.put(account, interestAmount);
|
||||
}
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, interestAmount,
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(), debitAccountMapForGoodwillCredit,
|
||||
paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
// handle fees payment of writeOff (and reversals)
|
||||
@@ -821,6 +833,10 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
accountMap.put(account, feesAmount);
|
||||
}
|
||||
}
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, feesAmount, AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(),
|
||||
debitAccountMapForGoodwillCredit, paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
// handle penalties payment of writeOff (and reversals)
|
||||
@@ -845,6 +861,12 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
accountMap.put(account, penaltiesAmount);
|
||||
}
|
||||
}
|
||||
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, penaltiesAmount,
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(), debitAccountMapForGoodwillCredit,
|
||||
paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
if (overPaymentAmount != null && overPaymentAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
@@ -857,6 +879,10 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
} else {
|
||||
accountMap.put(account, overPaymentAmount);
|
||||
}
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, overPaymentAmount, AccrualAccountsForLoan.GOODWILL_CREDIT.getValue(),
|
||||
debitAccountMapForGoodwillCredit, paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<GLAccount, BigDecimal> entry : accountMap.entrySet()) {
|
||||
@@ -882,9 +908,12 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
transactionDate, totalDebitAmount, isReversal);
|
||||
} else {
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
|
||||
AccrualAccountsForLoan.GOODWILL_CREDIT.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
|
||||
transactionDate, totalDebitAmount, isReversal);
|
||||
// create debit entries
|
||||
for (Map.Entry<Integer, BigDecimal> debitEntry : debitAccountMapForGoodwillCredit.entrySet()) {
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, debitEntry.getKey().intValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, debitEntry.getValue(),
|
||||
isReversal);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
|
||||
@@ -907,6 +936,27 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
}
|
||||
}
|
||||
|
||||
private void populateDebitAccountEntry(Long loanProductId, BigDecimal transactionPartAmount, Integer debitAccountType,
|
||||
Map<Integer, BigDecimal> accountMapForDebit, Long paymentTypeId) {
|
||||
Integer accountDebit = returnExistingDebitAccountInMapMatchingGLAccount(loanProductId, paymentTypeId, debitAccountType,
|
||||
accountMapForDebit);
|
||||
if (accountMapForDebit.containsKey(accountDebit)) {
|
||||
BigDecimal amount = accountMapForDebit.get(accountDebit).add(transactionPartAmount);
|
||||
accountMapForDebit.put(accountDebit, amount);
|
||||
} else {
|
||||
accountMapForDebit.put(accountDebit, transactionPartAmount);
|
||||
}
|
||||
}
|
||||
|
||||
private Integer returnExistingDebitAccountInMapMatchingGLAccount(Long loanProductId, Long paymentTypeId, Integer accountType,
|
||||
Map<Integer, BigDecimal> accountMap) {
|
||||
GLAccount glAccount = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, accountType, paymentTypeId);
|
||||
Integer accountEntry = accountMap.entrySet().stream().filter(account -> this.helper
|
||||
.getLinkedGLAccountForLoanProduct(loanProductId, account.getKey(), paymentTypeId).getGlCode().equals(glAccount.getGlCode()))
|
||||
.map(Map.Entry::getKey).findFirst().orElse(accountType);
|
||||
return accountEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a single Debit to fund source and a single credit to "Income from Recovery"
|
||||
*
|
||||
|
||||
+55
-6
@@ -195,7 +195,8 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
} else {
|
||||
accountMapForCredit.put(accountCredit, transactionPartAmount);
|
||||
}
|
||||
Integer accountDebit = debitAccountType;
|
||||
Integer accountDebit = returnExistingDebitAccountInMapMatchingGLAccount(loanProductId, paymentTypeId, debitAccountType,
|
||||
accountMapForDebit);
|
||||
if (accountMapForDebit.containsKey(accountDebit)) {
|
||||
BigDecimal amount = accountMapForDebit.get(accountDebit).add(transactionPartAmount);
|
||||
accountMapForDebit.put(accountDebit, amount);
|
||||
@@ -204,6 +205,15 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
}
|
||||
}
|
||||
|
||||
private Integer returnExistingDebitAccountInMapMatchingGLAccount(Long loanProductId, Long paymentTypeId, Integer accountType,
|
||||
Map<Integer, BigDecimal> accountMap) {
|
||||
GLAccount glAccount = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, accountType, paymentTypeId);
|
||||
Integer accountEntry = accountMap.entrySet().stream().filter(account -> this.helper
|
||||
.getLinkedGLAccountForLoanProduct(loanProductId, account.getKey(), paymentTypeId).getGlCode().equals(glAccount.getGlCode()))
|
||||
.map(Map.Entry::getKey).findFirst().orElse(accountType);
|
||||
return accountEntry;
|
||||
}
|
||||
|
||||
private void createJournalEntriesForChargeAdjustment(LoanDTO loanDTO, LoanTransactionDTO loanTransactionDTO, Office office) {
|
||||
final boolean isMarkedAsChargeOff = loanDTO.isMarkedAsChargeOff();
|
||||
if (isMarkedAsChargeOff) {
|
||||
@@ -609,7 +619,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateCreditDebitMaps(loanProductId, interestAmount, paymentTypeId, CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
CashAccountsForLoan.INCOME_FROM_CHARGE_OFF_INTEREST.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
} else if (loanTransactionDTO.getTransactionType().isRepayment()) {
|
||||
populateCreditDebitMaps(loanProductId, interestAmount, paymentTypeId, CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
CashAccountsForLoan.FUND_SOURCE.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
@@ -636,7 +646,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateCreditDebitMaps(loanProductId, feesAmount, paymentTypeId, CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
CashAccountsForLoan.GOODWILL_CREDIT.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isRepayment()) {
|
||||
populateCreditDebitMaps(loanProductId, feesAmount, paymentTypeId, CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
@@ -664,7 +674,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateCreditDebitMaps(loanProductId, penaltiesAmount, paymentTypeId, CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
CashAccountsForLoan.GOODWILL_CREDIT.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(), accountMapForCredit, accountMapForDebit);
|
||||
|
||||
} else if (loanTransactionDTO.getTransactionType().isRepayment()) {
|
||||
populateCreditDebitMaps(loanProductId, penaltiesAmount, paymentTypeId, CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
|
||||
@@ -755,17 +765,27 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||
|
||||
BigDecimal totalDebitAmount = new BigDecimal(0);
|
||||
Map<Integer, BigDecimal> debitAccountMapForGoodwillCredit = new LinkedHashMap<>();
|
||||
|
||||
if (principalAmount != null && principalAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.LOAN_PORTFOLIO, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, principalAmount, CashAccountsForLoan.GOODWILL_CREDIT.getValue(),
|
||||
debitAccountMapForGoodwillCredit, paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
if (interestAmount != null && interestAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
totalDebitAmount = totalDebitAmount.add(interestAmount);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.INTEREST_ON_LOANS,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, interestAmount,
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(), debitAccountMapForGoodwillCredit,
|
||||
paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
if (feesAmount != null && feesAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
@@ -773,6 +793,10 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
CashAccountsForLoan.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount,
|
||||
isReversal, loanTransactionDTO.getFeePayments());
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, feesAmount, CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(),
|
||||
debitAccountMapForGoodwillCredit, paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
if (penaltiesAmount != null && penaltiesAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
@@ -780,12 +804,21 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate,
|
||||
penaltiesAmount, isReversal, loanTransactionDTO.getPenaltyPayments());
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, penaltiesAmount,
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(), debitAccountMapForGoodwillCredit,
|
||||
paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
if (overPaymentAmount != null && overPaymentAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
totalDebitAmount = totalDebitAmount.add(overPaymentAmount);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.OVERPAYMENT, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, overPaymentAmount, isReversal);
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
populateDebitAccountEntry(loanProductId, overPaymentAmount, CashAccountsForLoan.GOODWILL_CREDIT.getValue(),
|
||||
debitAccountMapForGoodwillCredit, paymentTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
/*** create a single debit entry (or reversal) for the entire amount **/
|
||||
@@ -797,8 +830,12 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
} else {
|
||||
if (loanTransactionDTO.getTransactionType().isGoodwillCredit()) {
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.GOODWILL_CREDIT.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
|
||||
// create debit entries
|
||||
for (Map.Entry<Integer, BigDecimal> debitEntry : debitAccountMapForGoodwillCredit.entrySet()) {
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, debitEntry.getKey().intValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, debitEntry.getValue(), isReversal);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.FUND_SOURCE.getValue(),
|
||||
@@ -818,6 +855,18 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
}
|
||||
}
|
||||
|
||||
private void populateDebitAccountEntry(Long loanProductId, BigDecimal transactionPartAmount, Integer debitAccountType,
|
||||
Map<Integer, BigDecimal> accountMapForDebit, Long paymentTypeId) {
|
||||
Integer accountDebit = returnExistingDebitAccountInMapMatchingGLAccount(loanProductId, paymentTypeId, debitAccountType,
|
||||
accountMapForDebit);
|
||||
if (accountMapForDebit.containsKey(accountDebit)) {
|
||||
BigDecimal amount = accountMapForDebit.get(accountDebit).add(transactionPartAmount);
|
||||
accountMapForDebit.put(accountDebit, amount);
|
||||
} else {
|
||||
accountMapForDebit.put(accountDebit, transactionPartAmount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a single Debit to fund source and a single credit to "Income from Recovery"
|
||||
*
|
||||
|
||||
+18
@@ -272,6 +272,15 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi
|
||||
mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(),
|
||||
loanProductId, CashAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(),
|
||||
CashAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY.toString(), changes);
|
||||
mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(),
|
||||
loanProductId, CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(),
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.toString(), changes);
|
||||
mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(),
|
||||
loanProductId, CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(),
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.toString(), changes);
|
||||
mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(),
|
||||
loanProductId, CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(),
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.toString(), changes);
|
||||
|
||||
// expenses
|
||||
mergeLoanToExpenseAccountMappingChanges(element, LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
||||
@@ -330,6 +339,15 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi
|
||||
mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(),
|
||||
loanProductId, AccrualAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(),
|
||||
AccrualAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY.toString(), changes);
|
||||
mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(),
|
||||
loanProductId, AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(),
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.toString(), changes);
|
||||
mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(),
|
||||
loanProductId, AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(),
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.toString(), changes);
|
||||
mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(),
|
||||
loanProductId, AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(),
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.toString(), changes);
|
||||
|
||||
// expenses
|
||||
mergeLoanToExpenseAccountMappingChanges(element, LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
||||
|
||||
+4
@@ -89,6 +89,10 @@ public class ProductToGLAccountMappingHelper {
|
||||
optionalProductToGLAccountMappingEntries.add("chargeOffAccountId");
|
||||
optionalProductToGLAccountMappingEntries.add("chargeOffFraudAccountId");
|
||||
optionalProductToGLAccountMappingEntries.add("incomeFromChargeOffPenaltyAccountId");
|
||||
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditInterestAccountId");
|
||||
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditFeesAccountId");
|
||||
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditPenaltyAccountId");
|
||||
|
||||
if (optionalProductToGLAccountMappingEntries.contains(paramName)) {
|
||||
saveProductToAccountMapping(element, paramName, productId, accountTypeId, expectedAccountType, portfolioProductType);
|
||||
} else {
|
||||
|
||||
+17
@@ -148,7 +148,16 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.CHARGE_OFF_FRAUD_EXPENSE.getValue(), gLAccountData);
|
||||
} else if (glAccountForLoan.equals(CashAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY)) {
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(), gLAccountData);
|
||||
} else if (glAccountForLoan.equals(CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST)) {
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(),
|
||||
gLAccountData);
|
||||
} else if (glAccountForLoan.equals(CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES)) {
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(), gLAccountData);
|
||||
} else if (glAccountForLoan.equals(CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY)) {
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(),
|
||||
gLAccountData);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (AccountingRuleType.ACCRUAL_UPFRONT.getValue().equals(accountingType)
|
||||
|| AccountingRuleType.ACCRUAL_PERIODIC.getValue().equals(accountingType)) {
|
||||
@@ -198,6 +207,14 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.CHARGE_OFF_FRAUD_EXPENSE.getValue(), gLAccountData);
|
||||
} else if (glAccountForLoan.equals(AccrualAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY)) {
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(), gLAccountData);
|
||||
} else if (glAccountForLoan.equals(AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST)) {
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(),
|
||||
gLAccountData);
|
||||
} else if (glAccountForLoan.equals(AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES)) {
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(), gLAccountData);
|
||||
} else if (glAccountForLoan.equals(AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY)) {
|
||||
accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(),
|
||||
gLAccountData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -95,6 +95,15 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(), loanProductId,
|
||||
CashAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY.getValue());
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(), loanProductId,
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue());
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(), loanProductId,
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue());
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(), loanProductId,
|
||||
CashAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue());
|
||||
|
||||
// expenses
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
@@ -164,6 +173,15 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(), loanProductId,
|
||||
AccrualAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY.getValue());
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(), loanProductId,
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue());
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(), loanProductId,
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue());
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(), loanProductId,
|
||||
AccrualAccountsForLoan.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue());
|
||||
|
||||
// expenses
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
|
||||
+35
-1
@@ -123,7 +123,11 @@ public final class LoanProductDataValidator {
|
||||
LoanProductAccountingParams.CHARGE_OFF_FRAUD_EXPENSE.getValue(), LoanProductAccountingParams.CHARGE_OFF_EXPENSE.getValue(),
|
||||
LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_FEES.getValue(),
|
||||
LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_INTEREST.getValue(),
|
||||
LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(), LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME,
|
||||
LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue(),
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(),
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(),
|
||||
LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(),
|
||||
LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME,
|
||||
LoanProductConstants.PRINCIPAL_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME,
|
||||
LoanProductConstants.INTEREST_RATE_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME,
|
||||
LoanProductConstants.NUMBER_OF_REPAYMENT_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME, LoanProductConstants.SHORT_NAME,
|
||||
@@ -658,6 +662,21 @@ public final class LoanProductDataValidator {
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue())
|
||||
.value(incomeFromChargeOffPenaltyAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||
|
||||
final Long incomeFromGoodwillCreditInterestAccountId = this.fromApiJsonHelper
|
||||
.extractLongNamed(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(), element);
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue())
|
||||
.value(incomeFromGoodwillCreditInterestAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||
|
||||
final Long incomeFromGoodwillCreditFeesAccountId = this.fromApiJsonHelper
|
||||
.extractLongNamed(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(), element);
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue())
|
||||
.value(incomeFromGoodwillCreditFeesAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||
|
||||
final Long incomeFromGoodwillCreditPenaltyAccountId = this.fromApiJsonHelper
|
||||
.extractLongNamed(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(), element);
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue())
|
||||
.value(incomeFromGoodwillCreditPenaltyAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||
|
||||
final Long chargeOffExpenseAccountId = this.fromApiJsonHelper
|
||||
.extractLongNamed(LoanProductAccountingParams.CHARGE_OFF_EXPENSE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.CHARGE_OFF_EXPENSE.getValue()).value(chargeOffExpenseAccountId)
|
||||
@@ -1528,6 +1547,21 @@ public final class LoanProductDataValidator {
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_PENALTY.getValue())
|
||||
.value(incomeFromChargeOffPenaltyAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||
|
||||
final Long incomeFromGoodwillCreditInterestAccountId = this.fromApiJsonHelper
|
||||
.extractLongNamed(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue(), element);
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_INTEREST.getValue())
|
||||
.value(incomeFromGoodwillCreditInterestAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||
|
||||
final Long incomeFromGoodwillCreditFeesAccountId = this.fromApiJsonHelper
|
||||
.extractLongNamed(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue(), element);
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_FEES.getValue())
|
||||
.value(incomeFromGoodwillCreditFeesAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||
|
||||
final Long incomeFromGoodwillCreditPenaltyAccountId = this.fromApiJsonHelper
|
||||
.extractLongNamed(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue(), element);
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_GOODWILL_CREDIT_PENALTY.getValue())
|
||||
.value(incomeFromGoodwillCreditPenaltyAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||
|
||||
final Long chargeOffExpenseAccountId = this.fromApiJsonHelper
|
||||
.extractLongNamed(LoanProductAccountingParams.CHARGE_OFF_EXPENSE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(LoanProductAccountingParams.CHARGE_OFF_EXPENSE.getValue()).value(chargeOffExpenseAccountId)
|
||||
|
||||
Reference in New Issue
Block a user