https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440

--- Comment #8 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 210429
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210429&action=edit
Bug 35440: Only offer to refund what was paid and explain refund amount errors

The Issue refund modal worked out 'Amount paid' as amount minus
amountoutstanding. A discount lowers amountoutstanding just like a payment
does, so for a charge that was discounted and then paid the modal offered
the discounted part as refundable. Koha::Account::Line->reduce then (rightly)
refused with ParameterTooHigh ('Combined reduction ... is higher than
original amount') and, because the controller did not catch it, the user
got a generic Error 500.

Add Koha::Account::Line->refundable_amount (amount, less outstanding, less
discounts and refunds already applied; never negative) and use it for the
modal's default and maximum, and to decide whether to show Issue refund at
all.

Also catch ParameterTooHigh and AmountNotPositive in members/boraccount.pl
with the helper added for Bug 43993, so an amount that cannot be refunded or
paid out shows a Bootstrap alert and records nothing instead of a 500.

To test:
1. Add a charge of 5.00 to a patron
2. Apply a 1.00 discount to it, then pay the remaining 4.00
3. Click 'Issue refund' on the charge
   => Before: Amount paid and Returned to patron are 5.00, and confirming
      with Account credit gives Error 500
   => After: both are 4.00 and the refund works
4. On another charge of 5.00, apply a 1.00 discount without paying it
   => Before: an Issue refund button is shown
   => After: no Issue refund button is shown
5. On a paid charge, edit the Returned to patron amount to something
   higher than was paid (e.g. with the browser dev tools) and confirm
   => Before: Error 500
   => After: a warning alert and nothing is recorded
6. prove t/db_dependent/Koha/Account/Line.t

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to