[Bug 43994] New: Refund with missing or empty transaction type gives 500 or empty PAYOUT
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43994 Bug ID: 43994 Summary: Refund with missing or empty transaction type gives 500 or empty PAYOUT Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Fines and fees Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Target Milestone: --- On the patron Accounting tab, the 'Issue refund' modal posts refund_type to op=cud-refund in members/boraccount.pl. The controller never validates it: - If refund_type is missing, the controller calls ->payout() with an undefined payout_type, and the generic 'Error 500' page is shown (Koha::Exceptions::MissingParameter: The payout_type parameter is mandatory). - If refund_type is the empty string (the 'None selected' option, which can be submitted when neither UseCashRegisters nor RequirePaymentType is enabled, because the select is then not required), no error is raised at all. A PAYOUT accountline with payment_type = '' is silently created, so the refund appears to succeed while recording a bogus payout. Koha::Account::Line->payout should reject an empty payout_type with the existing Koha::Exceptions::Account::PaymentTypeRequired exception, and the controller should catch it, roll back the whole refund (including the REFUND credit created by reduce()), and show an alert asking for a transaction type. Test plan: 1. Make sure UseCashRegisters and RequirePaymentType are both disabled 2. Pay a charge on a patron's account, then click 'Issue refund' on it 3. Leave Transaction type on 'None selected' and click Confirm => Before the patch: a PAYOUT line with an empty payment type is created => After: the page reloads with a warning alert asking for a transaction type, and nothing is recorded (the charge is not marked refunded) 4. Choose Account credit and Confirm => The refund works 5. prove t/db_dependent/Koha/Account/Line.t Depends on the controller error handling added by the 'RegisterRequired' bug. -- 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=43994 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- 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 the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43994 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210426 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210426&action=edit Bug 43994: Reject refunds and payouts with a missing or empty transaction type The Issue refund modal posts refund_type to op=cud-refund in members/boraccount.pl, which never validated it: - With refund_type missing, ->payout() was called with an undefined payout_type and the user got a 500 (MissingParameter). - With refund_type empty (the 'None selected' option, which can be submitted when neither UseCashRegisters nor RequirePaymentType is on), no error was raised and a PAYOUT accountline with an empty payment_type was silently created. Koha::Account::Line->payout now throws the existing Koha::Exceptions::Account::PaymentTypeRequired for an empty payout_type. The controller treats a missing type as empty, the whole transaction (including the REFUND credit created by reduce()) is rolled back, and a Bootstrap alert asks for a transaction type. To test: 1. Make sure UseCashRegisters and RequirePaymentType are both disabled 2. Pay a charge on a patron's account, then click 'Issue refund' on it 3. Leave Transaction type on 'None selected' and click Confirm => Before: a PAYOUT line with an empty payment type is created => After: the page reloads with a warning alert asking for a transaction type, and nothing is recorded (the charge is not marked refunded) 4. Choose Account credit and Confirm => The refund works 5. 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. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43994 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- 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=43994 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210426|0 |1 is obsolete| | -- 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=43994 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210428 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210428&action=edit Bug 43994: Reject refunds and payouts with a missing or empty transaction type The Issue refund modal posts refund_type to op=cud-refund in members/boraccount.pl, which never validated it: - With refund_type missing, ->payout() was called with an undefined payout_type and the user got a 500 (MissingParameter). - With refund_type empty (the 'None selected' option, which can be submitted when neither UseCashRegisters nor RequirePaymentType is on), no error was raised and a PAYOUT accountline with an empty payment_type was silently created. Koha::Account::Line->payout now throws the existing Koha::Exceptions::Account::PaymentTypeRequired for an empty payout_type. The controller treats a missing type as empty, the whole transaction (including the REFUND credit created by reduce()) is rolled back, and a Bootstrap alert asks for a transaction type. To test: 1. Make sure UseCashRegisters and RequirePaymentType are both disabled 2. Pay a charge on a patron's account, then click 'Issue refund' on it 3. Leave Transaction type on 'None selected' and click Confirm => Before: a PAYOUT line with an empty payment type is created => After: the page reloads with a warning alert asking for a transaction type, and nothing is recorded (the charge is not marked refunded) 4. Choose Account credit and Confirm => The refund works 5. 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 the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43994 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 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org