Piotr Wargulak created FINERACT-3006:
----------------------------------------

             Summary: A fee added to an overpaid progressive loan reads as 
paid, but no transaction pays it
                 Key: FINERACT-3006
                 URL: https://issues.apache.org/jira/browse/FINERACT-3006
             Project: Apache Fineract
          Issue Type: Bug
            Reporter: Piotr Wargulak
            Assignee: Piotr Wargulak


Adding a specified-due-date fee to an overpaid progressive loan 
(advanced-payment-allocation-strategy) can leave the loan both owing and owed: 
the fee is marked paid, no transaction pays it, and the overpayment stays the 
same.

Measured (one fee of 1.00, loan overpaid by 6 200.00, status 700):
 * the charge reads {{{}paid: true{}}}, {{amountPaid}} 1.00, outstanding 0.00, 
with a paid-by row on the old repayment;
 * that repayment is unchanged (its overpayment portion is still 6 200.00), no 
new transaction, no journal entry;
 * the loan stays Overpaid with {{totalOverpaid}} 6 200.00, while 
{{summary.totalOutstanding}} and the installment's fee outstanding read 1.00.

Trigger, from eight variants:
 * BUG: a non-penalty fee, due after the overpaying payment, in an installment 
whose own fee is already paid.
 * OK: a fee due before the overpaying payment (the repayment is replaced, 
overpaid 6 199.00, ledger consistent); a penalty on the same date; a fee in an 
installment that had no fee; an active (not overpaid) loan with prepaid 
installments; a fee due the day after a refund of the overpayment.
 * Refund of the overpayment and the fee due the same day: the loan reopens 
with 1.00 outstanding, but the charge still reads paid by the old repayment.

Steps to reproduce:
 # Progressive loan, no interest, an installment fee or specified-due-date fee 
in each installment.
 # Repay the whole loan plus an overpayment in one repayment (status 700 
Overpaid).
 # Add a 1.00 specified-due-date fee due after that repayment, in an 
installment whose fee the repayment paid.
 # Read the loan: the charge is paid, the repayment is unchanged, 
{{totalOverpaid}} is unchanged and {{totalOutstanding}} is 1.00.

Where it goes: 

{{LoanChargeWritePlatformServiceImpl}} (:255-279) sets {{overpaidReprocess}} 
and runs a full replay; 
{{AdvancedPaymentScheduleTransactionProcessor#processOverpaidTransactions}} 
then records the fee as paid, but the amount is not taken from the overpayment, 
so {{useOldTransactionIfApplicable}} keeps the old repayment and copies only 
the paid-by mapping.

Expected: 
the fee is paid from the overpayment (the repayment is replaced and the 
overpaid amount drops by 1.00), as it is for a fee due before the repayment.

Workaround: 
refund the overpayment first and date the fee after the refund.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to