adamsaghy commented on code in PR #5780:
URL: https://github.com/apache/fineract/pull/5780#discussion_r3170501651
##########
fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccrualBasedAccountingProcessorForLoan.java:
##########
@@ -1715,8 +1717,21 @@ private void createJournalEntriesForLoanRepayments(final
LoanDTO loanDTO, final
if (MathUtil.isGreaterThanZero(feesAmount)) {
totalDebitAmount = totalDebitAmount.add(feesAmount);
if (isIncomeFromFee) {
- this.helper.createCreditJournalEntryForLoanCharges(office,
currencyCode, AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(),
- loanProductId, loanId, transactionId, transactionDate,
feesAmount, loanTransactionDTO.getFeePayments());
+ final List<ChargeTaxPaymentDTO> feeTaxPayments =
loanCommonAccountingHelper.filterTaxPayments(loanTransactionDTO, false);
+ final BigDecimal feeTaxTotal =
loanCommonAccountingHelper.sumTaxAmounts(feeTaxPayments);
+ if (feeTaxTotal.compareTo(BigDecimal.ZERO) > 0) {
+ final BigDecimal netFees =
feesAmount.subtract(feeTaxTotal);
+ this.helper.createCreditJournalEntryForLoanCharges(office,
currencyCode,
+
AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(), loanProductId, loanId,
transactionId, transactionDate,
+ netFees,
+
loanCommonAccountingHelper.computeNetChargePayments(loanTransactionDTO.getFeePayments(),
feeTaxPayments));
+
loanCommonAccountingHelper.createTaxLiabilityCreditEntries(office,
currencyCode, loanId, transactionId, transactionDate,
+ feeTaxPayments);
+ } else {
+ this.helper.createCreditJournalEntryForLoanCharges(office,
currencyCode,
+
AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(), loanProductId, loanId,
transactionId, transactionDate,
+ feesAmount, loanTransactionDTO.getFeePayments());
+ }
Review Comment:
You are recalculating tax payments over and over again...
You can SUM and fetch the appropriate tax entries for a particular charge in
1 sql query.
Would that be better than fetching all fee payment and all tax payments and
group and sum them over and over again? What do you think?
--
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]