Foo Developer created FINERACT-2861:
---------------------------------------
Summary: Waiving interest under creocore-strategy posts double the
waived amount to the GL
Key: FINERACT-2861
URL: https://issues.apache.org/jira/browse/FINERACT-2861
Project: Apache Fineract
Issue Type: Bug
Components: Loan, Accounting
Reporter: Foo Developer
Assignee: Foo Developer
h3. Summary
With the {{creocore-strategy}} (and {{heavensfamily-strategy}}) repayment
strategy, waiving interest on a loan records the waiver transaction's interest
portion as *twice* the waived amount, so the accounting journal entries post
double the waived interest.
h3. Steps to reproduce
# Create a loan product with accounting enabled (cash or accrual) and
{{transactionProcessingStrategyCode}} = {{creocore-strategy}}.
# Create, approve and disburse a loan on it.
# Waive part of the interest of the first installment: {{POST
/fineract-provider/api/v1/loans/{loanId}/transactions?command=waiveinterest}}
with {{{"transactionDate": "<date>", "transactionAmount": 10, "locale": "en",
"dateFormat": "dd MMMM yyyy"}}}
# Read the transaction back ({{GET /loans/{loanId}/transactions/{txnId}}}) and
its journal entries ({{GET /journalentries?transactionId=L{txnId}}}).
h3. Expected
The waiver transaction has {{amount}} 10 and {{interestPortion}} 10, and the
journal entries post one pair of 10.
h3. Actual
{{amount}} is 10 but {{interestPortion}} is 20, and the journal entries post 20
on each side. The installment's waived interest and the repayment schedule are
correct; only the transaction's interest portion, and therefore the GL, is
doubled.
h3. Root cause
{{LoanTransaction.updateComponents(...)}} accumulates onto the portions already
set on the transaction. In
{{CreocoreLoanRepaymentScheduleTransactionProcessor.handleTransactionThatIsOnTimePaymentOfInstallment}}
it is called inside the {{isInterestWaiver()}} branch *and* again
unconditionally after the if/else chain, so the waived interest is added twice.
{{HeavensFamilyLoanRepaymentScheduleTransactionProcessor}} has the same double
call in two methods ({{handleTransactionThatIsPaymentInAdvanceOfInstallment}}
and {{handleTransactionThatIsOnTimePaymentOfInstallment}}; the late-payment
path delegates to the latter).
{{FineractStyleLoanRepaymentScheduleTransactionProcessor}} is correct: it calls
{{updateComponents}} once per branch with no trailing call.
h3. Proposed fix
Remove the redundant {{updateComponents(...)}} call from the interest-waiver
branch in the three methods, leaving the single trailing call. Unit tests for
both processors assert that a waiver of X leaves the transaction's interest
portion at X (they fail with 2X before the fix).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)