Adam Saghy created FINERACT-2930:
------------------------------------
Summary: Allow adjusting Payout Refund, Goodwill Credit, Charge
Adjustment and Merchant Issued Refund transactions
Key: FINERACT-2930
URL: https://issues.apache.org/jira/browse/FINERACT-2930
Project: Apache Fineract
Issue Type: Improvement
Affects Versions: 1.15.0
Reporter: Adam Saghy
Assignee: Adam Saghy
*Background*
The loan transaction adjust endpoint (POST
/loans/\{loanId}/transactions/\{transactionId} with a transactionAmountgreater
than 0) replaces an existing transaction with a new one that has a new amount
and/or date. The original is reversed and the loan's transactions are replayed.
Today this only works for Repayment, Waiver and a few other types.
These types can currently be reversed (amount = 0) but not adjusted:
||Transaction type||Current behaviour||
|Payout Refund|Blocked by LoanTransaction.isEditable()|
|Goodwill Credit|Blocked by LoanTransaction.isEditable()|
|Merchant Issued Refund|Blocked by LoanTransaction.isEditable()|
|Charge Adjustment|Not handled: the replacement is built as a plain
repayment-like transaction, so the link to the adjusted charge is lost|
To change the amount or date of one of these, users have to reverse it and
create a new one by hand. That takes two calls, loses the audit link between
the old and new transaction, and doesn't work like the other repayment-like
types.
*User story*
As a back-office user, I want to adjust the amount and/or date of a Payout
Refund, Goodwill Credit, Charge Adjustment or Merchant Issued Refund
transaction, so that I can correct it in one step, just as I can with a
Repayment.
*Scope*
# *Payout Refund:* allow adjustment only if the loan product does *not* have
automatic Interest Refund enabled for PAYOUT_REFUND (it isn't in
supportedInterestRefundTypes).
# *Merchant Issued Refund:* allow adjustment only if the loan product does
*not* have automatic Interest Refund enabled for MERCHANT_ISSUED_REFUND.
# *Goodwill Credit:* always allow adjustment.
# *Charge Adjustment:* allow adjustment, keeping the link to the original loan
charge.
*Acceptance criteria*
_General (all four types)_
* Adjusting with transactionAmount > 0 reverses the original transaction and
creates a new transaction *of the same type* with the new amount/date. Payment
details, external ID and note are handled the same way as for a Repayment
adjustment.
* Reversing (amount = 0) keeps working as it does today.
* The loan is replayed from the earlier of the original and new transaction
dates. The schedule, balances, allocations, accruals and loan status (e.g.
closed ↔ active, overpaid) are recalculated correctly.
* Journal entries are reversed for the original transaction and posted for the
new one, using the correct accounts for that transaction type.
* LoanAdjustTransactionBusinessEvent is raised with both the original and the
new transaction detail.
* Existing checks still apply: account transfer, written-off loan, foreclosed
loan, inactive client/group, holiday or non-working day, and transactions that
have a chargeback linked to them.
* LoanTransaction.isEditable() and the allowed-types error message in
LoanAdjustmentServiceImpl.adjustExistingTransaction are updated to match.
_Payout Refund / Merchant Issued Refund_
* If the product has automatic Interest Refund enabled for that type,
adjustment is still rejected with a clear error, e.g.
error.msg.loan.transaction.adjust.not.allowed.when.interest.refund.enabled.
Reversal behaviour doesn't change.
* If it isn't enabled, adjustment succeeds as described above, and no Interest
Refund transaction is created.
_Charge Adjustment_
* The new transaction stays linked to the same loan charge (LoanChargePaidBy /
charge relation).
* The new amount can't be more than the amount still available for adjustment
on that charge, counting the reversed original as available again. Going over
it is rejected with the existing "higher than the available charge amount for
adjustment" validation.
* The charge's paid/outstanding amounts and the charge adjustment accounting
(income/fee) are recalculated correctly.
_Goodwill Credit_
* The adjusted Goodwill Credit keeps its own allocation rules and accounting
(e.g. the goodwill credit expense account), not the Repayment ones.
*Out of scope*
* Adjusting Payout Refund or Merchant Issued Refund when automatic Interest
Refund is enabled. This needs the linked Interest Refund to be recalculated and
belongs in a follow-up.
* Adjusting Chargeback or Interest Refund transactions.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)