[Bug 35440] New: Partial refund triggers a 500 error
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 Bug ID: 35440 Summary: Partial refund triggers a 500 error Change sponsored?: --- Product: Koha Version: 23.05 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Patrons Assignee: koha-bugs@lists.koha-community.org Reporter: esther.melander@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle.m.hall@gmail.com To recreate 1. Create a charge on a patron account of $150.00 2. Pay the charge as cash 3. Issue a refund, but only refund $5.00 as cash 4. See that it causes a 500 error I should be able to issue a partial refund and have it show correctly in the transaction table. Error statement: Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Amount to payout (5.00) is higher than amountoutstanding (0)' May be connected to bug 30027 and previously fixed bug 8770. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com --- Comment #1 from Kyle M Hall <kyle@bywatersolutions.com> --- If a Transaction type is chosen, the error does not occur. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 --- Comment #2 from Esther Melander <esther.melander@bywatersolutions.com> --- Partial refund appears to fail depending on Transaction type. For example, received a 500 error when selecting Cash or Check. But refund succeeded with Account Credit. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 --- Comment #3 from Esther Melander <esther.melander@bywatersolutions.com> --- Some additional insight on why this is happening. The library had a circulation rule to refund lost item charge (only if unpaid). To recreate 1. Set default refund policy to Refund lost item charge (only if unpaid) 2. Create a charge on a patron account of $150.00 3. Pay the charge as cash 4. Issue a refund, but only refund $5.00 as cash 5. See that it causes a 500 error In this case Koha is trying to refund something that has already been paid, which can't happen based on the circulation rule. Instead of a 500 error, there should be "can't refund" warning. As an extension of this bug, I can do a full refund, which also should not happen based on the circulation rule. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 --- Comment #4 from Kyle M Hall <kyle@bywatersolutions.com> --- Esther, I cannot recreate the error on master or 22.11 using your test plan and the default data in Koha Testing Docker. I was able to recreate by doing something a bit weirder through. 1. Create a charge on a patron account of $150.00 2. Pay the charge as cash 3. Issue a refund, but only refund $5.00 as cash 4. Void that refund 5. Issue refund on the "Credit has been voided" line Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Combined reduction (5 + -5) is higher than original amount (5)' at /usr/share/perl5/Exception/Class/Base.pm line 88 https://monosnap.com/file/HSdtsLVcOinrV54hX5GLr98K2akXdz -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 --- Comment #5 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- We also see this in 22.11.10 There were no partial refunds, but full refunds using the button in the transactions table: Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Combined reduction (2 + -2) is higher than original amount (2)' Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Combined reduction (3 + -3) is higher than original amount (3)' Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Combined reduction (3.00 + -3) is higher than original amount (3)' Which makes no mathematical sense to me actually? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 --- Comment #6 from Kyle M Hall <kyle@bywatersolutions.com> --- (In reply to Katrin Fischer from comment #5)
We also see this in 22.11.10
There were no partial refunds, but full refunds using the button in the transactions table:
Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Combined reduction (2 + -2) is higher than original amount (2)' Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Combined reduction (3 + -3) is higher than original amount (3)' Exception 'Koha::Exceptions::ParameterTooHigh' thrown 'Combined reduction (3.00 + -3) is higher than original amount (3)'
Which makes no mathematical sense to me actually?
The code uses absolute values which I think may be part of the issue. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 tech.aimee@salinapublic.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tech.aimee@salinapublic.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- We hit another way to get this 500 error on the refund modal while investigating a customer report, in case it helps whoever picks this up. Steps (UseCashRegisters on or off, it does not matter): 1. Add a charge of 5.00 to a patron 2. Apply a 1.00 discount to it (status becomes DISCOUNTED, 4.00 outstanding) 3. Pay the remaining 4.00 4. Click 'Issue refund' on the charge. The modal pre-fills 'Amount paid' and 'Returned to patron' with 5.00 5. Choose Account credit and Confirm => Error 500: Koha::Exceptions::ParameterTooHigh 'Combined reduction (5.00 + -1) is higher than original amount (5)' The modal works out 'Amount paid' as amount - amountoutstanding, which counts the 1.00 discount as if it had been paid. Koha::Account::Line->reduce then (correctly) refuses to reduce the charge by more than 4.00 in total, because the discount is also a reduction. So at least part of the error reported here is the modal offering a refund amount that reduce() cannot accept. The controller also does not catch the exception, so the user sees a bare 500 instead of an explanation. Reproduced on 25.11 (o5th build); the reduce() check and the modal calculation are the same in current main by code reading, but I have not run it there. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk Depends on| |43993 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43993 [Bug 43993] Refund/payout without a cash register gives an uncaught 500 error -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 --- Comment #8 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- 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 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35440 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org