Fix: Advanced Account Rule for Fees under Accrual Periodic type (Fineract-1031)

This commit is contained in:
BLasan
2021-05-28 22:52:08 +05:30
parent f87b66d4e1
commit bee14387f4
@@ -211,21 +211,29 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
} else { } else {
accountMap.put(account, interestAmount); accountMap.put(account, interestAmount);
} }
for (Map.Entry<GLAccount, BigDecimal> entry : accountMap.entrySet()) {
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, loanId, transactionId, transactionDate,
entry.getValue(), isReversal, entry.getKey());
}
} }
// handle fees payment of writeOff (and reversals) // handle fees payment of writeOff (and reversals)
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) { if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(feesAmount); totalDebitAmount = totalDebitAmount.add(feesAmount);
if (isIncomeFromFee) { if (isIncomeFromFee) {
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(), paymentTypeId); AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate,
if (accountMap.containsKey(account)) { feesAmount, isReversal, loanTransactionDTO.getFeePayments());
BigDecimal amount = accountMap.get(account).add(feesAmount); // GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
accountMap.put(account, amount); // AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(), paymentTypeId);
} else { // if (accountMap.containsKey(account)) {
accountMap.put(account, feesAmount); // BigDecimal amount = accountMap.get(account).add(feesAmount);
} // accountMap.put(account, amount);
// } else {
// accountMap.put(account, feesAmount);
// }
} else { } else {
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
AccrualAccountsForLoan.FEES_RECEIVABLE.getValue(), paymentTypeId); AccrualAccountsForLoan.FEES_RECEIVABLE.getValue(), paymentTypeId);
@@ -260,6 +268,11 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
accountMap.put(account, penaltiesAmount); accountMap.put(account, penaltiesAmount);
} }
} }
for (Map.Entry<GLAccount, BigDecimal> entry : accountMap.entrySet()) {
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, loanId, transactionId, transactionDate,
entry.getValue(), isReversal, entry.getKey());
}
} }
if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) { if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) {
@@ -272,11 +285,10 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
} else { } else {
accountMap.put(account, overPaymentAmount); accountMap.put(account, overPaymentAmount);
} }
} for (Map.Entry<GLAccount, BigDecimal> entry : accountMap.entrySet()) {
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, loanId, transactionId, transactionDate,
for (Map.Entry<GLAccount, BigDecimal> entry : accountMap.entrySet()) { entry.getValue(), isReversal, entry.getKey());
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, loanId, transactionId, transactionDate, }
entry.getValue(), isReversal, entry.getKey());
} }
/** /**