Bug 39219

Summary: Error when issuing a refund on a partial payment from the transaction table
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: Fines and feesAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, katrin.fischer, kyle.m.hall, martin.renvoize
Version: MainKeywords: RM_priority
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 39219: Do not apply amountoutstanding when credit type is REFUND

Description Lucas Gass (lukeg) 2025-02-28 15:55:29 UTC
To recreate:

- Create a manual invoice: $10.00
- Pay using the pay button in the transactions table: $1.00
- Now issuing a refund explodes into:
Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Amount to payout (3.00) is higher than amountoutstanding (0)'
 at /usr/share/perl5/Exception/Class/Base.pm line 88
Comment 1 Lucas Gass (lukeg) 2025-02-28 16:21:33 UTC
To me the 'Issue refund' button feels like it is on the wrong accountline after recreating the steps here. 

-
Comment 2 Lucas Gass (lukeg) 2025-02-28 18:43:48 UTC
I think the apply() routine ( Koha/Account/Line.pm ) is incorrectly modifying the amountoutstanding when issuing refunds
Comment 3 Lucas Gass (lukeg) 2025-02-28 20:38:56 UTC
Created attachment 178872 [details] [review]
Bug 39219: Do not apply amountoutstanding when credit type is REFUND
Comment 4 Lucas Gass (lukeg) 2025-02-28 20:42:08 UTC
Leaving a patch here because it fixes the problem.

-Still needs an updated test to cover 
-Also with partial payments -> refunds the payment gets set to 'REFUNDED' so you can not issue further refunds of the payment. 

Test by making $100 manual credit, playing $10, and issuing $1 in refunds. I'm not sure how this is supposed to work becuase this bug seems to go back as far as at least 23.11
Comment 5 Lucas Gass (lukeg) 2025-02-28 21:02:07 UTC
(In reply to Lucas Gass (lukeg) from comment #1)
> To me the 'Issue refund' button feels like it is on the wrong accountline
> after recreating the steps here. 
> 
> -

I didn't finish my thought here. It feels like the 'Issue refund' button is on the wrong accountline.

-Add a manual invoice
-Partial pay it 
-The issue refund is now on the original invoice accountline 

Shouldn't it be on the partial pay accountline?