From e5a338d8ffb1b89541642150497ab8b79e1f5ae8 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 7 Nov 2025 16:26:05 +0000 Subject: [PATCH] Bug 40445: Add detailed error handling for cashup completion failures The cashup completion process in pos/register.pl was providing only a generic "Failed to complete cashup" message for all errors, making it difficult to diagnose issues during development and production use. This patch enhances error handling by: 1. Adding specific error messages for MissingParameter exceptions (displays the actual missing parameter name) 2. Adding specific error messages for AmountNotPositive exceptions (clarifies that amount must be positive and non-zero) 3. Displaying detailed error information for unhandled exceptions in the generic error case (aids debugging) These improvements provide clearer feedback to users and make it easier to troubleshoot cashup failures in both two-phase and legacy workflows. Test plan: 1. Attempt cashup operations that trigger various exceptions 2. Verify each exception type shows an appropriate, specific error message 3. Confirm the error details help identify the root cause --- .../intranet-tmpl/prog/en/modules/pos/register.tt | 15 ++++++++++++++- pos/register.pl | 8 +++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt index 2f012023fd1..53ec4dbda88 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -68,8 +68,21 @@
Failed to start cashup. Please try again.
[% END %] + [% IF ( error_cashup_missing_param ) %] +
Missing required parameter for cashup: [% error_message | html %]
+ [% END %] + + [% IF ( error_cashup_amount_invalid ) %] +
The cashup amount must be a positive number greater than zero.
+ [% END %] + [% IF ( error_cashup_complete ) %] -
Failed to complete cashup. Please try again.
+
+ Failed to complete cashup. Please try again. + [% IF error_details %] +
Error details: [% error_details | html %] + [% END %] +
[% END %] [% IF ( error_refund_permission ) %] diff --git a/pos/register.pl b/pos/register.pl index df1faf73def..41d62fff656 100755 --- a/pos/register.pl +++ b/pos/register.pl @@ -157,8 +157,14 @@ if ( !$registers->count ) { $template->param( error_no_cashup_start => 1 ); } elsif ( $@->isa('Koha::Exceptions::Object::DuplicateID') ) { $template->param( error_cashup_already_completed => 1 ); + } elsif ( $@->isa('Koha::Exceptions::MissingParameter') ) { + $template->param( error_cashup_missing_param => 1, error_message => $@ ); + } elsif ( $@->isa('Koha::Exceptions::Account::AmountNotPositive') ) { + $template->param( error_cashup_amount_invalid => 1 ); } else { - $template->param( error_cashup_complete => 1 ); + + # Log the actual exception for debugging + $template->param( error_cashup_complete => 1, error_details => "$@" ); } } else { -- 2.51.1