taskain7 commented on code in PR #3784:
URL: https://github.com/apache/fineract/pull/3784#discussion_r1517681299
##########
fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccrualBasedAccountingProcessorForLoan.java:
##########
@@ -451,33 +451,54 @@ private void createJournalEntriesForChargeback(LoanDTO
loanDTO, LoanTransactionD
}
if (principalCredited.compareTo(principalPaid) > 0) {
- helper.createDebitJournalEntryOrReversalForLoan(office,
currencyCode, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(),
- loanProductId, paymentTypeId, loanId, transactionId,
transactionDate, principalCredited.subtract(principalPaid),
- isReversal);
+ helper.createDebitJournalEntryOrReversalForLoan(office,
currencyCode, getPrincipalAccount(loanDTO), 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);
+ helper.createCreditJournalEntryOrReversalForLoan(office,
currencyCode, getPrincipalAccount(loanDTO), 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);
+ helper.createDebitJournalEntryOrReversalForLoan(office,
currencyCode, getFeeAccount(loanDTO), 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);
+ helper.createCreditJournalEntryOrReversalForLoan(office,
currencyCode, getFeeAccount(loanDTO), 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);
+ helper.createDebitJournalEntryOrReversalForLoan(office,
currencyCode, getPenaltyAccount(loanDTO), 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);
+ helper.createCreditJournalEntryOrReversalForLoan(office,
currencyCode, getPenaltyAccount(loanDTO), loanProductId, paymentTypeId,
+ loanId, transactionId, transactionDate,
penaltyPaid.subtract(penaltyCredited), isReversal);
}
+ }
+
+ private Integer getFeeAccount(LoanDTO loanDTO) {
+ Integer account = AccrualAccountsForLoan.FEES_RECEIVABLE.getValue();
+ if (loanDTO.isMarkedAsChargeOff()) {
+ account =
AccrualAccountsForLoan.INCOME_FROM_CHARGE_OFF_FEES.getValue();
+ }
+ return account;
+ }
+ private Integer getPenaltyAccount(LoanDTO loanDTO) {
+ Integer account =
AccrualAccountsForLoan.PENALTIES_RECEIVABLE.getValue();
+ if (loanDTO.isMarkedAsChargeOff()) {
+ account =
AccrualAccountsForLoan.INCOME_FROM_CHARGE_OFF_PENALTY.getValue();
+ }
+ return account;
+ }
+
+ private Integer getPrincipalAccount(LoanDTO loanDTO) {
+ Integer account = AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue();
+ if (loanDTO.isMarkedAsFraud()) {
Review Comment:
shouldn't it be `isMarkedAsFraud && isMarkedAsChargedOff` to use the
`CHARGE_OFF_FRAUD_EXPENSE ` account?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]