alberto-art3ch commented on code in PR #5780:
URL: https://github.com/apache/fineract/pull/5780#discussion_r3220126971
##########
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:
@adamsaghy If we consider that a we could have one or more Taxes on the
Charge, and the Loan Transaction could pay different Loan Charges, then we
could receive different taxes, and each Tax could credit different GL Account
linked, so this is why we are not saving in the DTO the full amount
Furthermore, although the operation seems redundant, I believe that doing it
in memory is cheaper and mathematically guarantees that the remaining gross
amount (`netFees = feesAmount.subtract(feeTaxTotal)`) perfectly matches the
individual parts of the liability entries, avoiding any rounding discrepancies
that could occur if the grand total and tax details were separate from the
previous stage.
--
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]