Bug 41404: Use looks_like_a_number to verify if prefs are set

This check adds a check to ensure we have number, not just defined

To test:
1 - Apply only unit tests patch
2 - Run the tests
    prove -v t/db_dependent/Koha/Patron.t
3 - Apply this patch
4 - Run the tests
5 - They pass!

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 154f807f6b)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
This commit is contained in:
Nick Clemens 2025-12-08 18:34:36 +00:00 committed by Jacob O'Mara
parent 9b58889359
commit eb6cefae4e
No known key found for this signature in database
1 changed files with 5 additions and 2 deletions

View File

@ -22,6 +22,7 @@ use Modern::Perl;
use List::MoreUtils qw( any none uniq notall zip6);
use JSON qw( to_json );
use Scalar::Util qw(looks_like_number);
use Unicode::Normalize qw( NFKD );
use Try::Tiny;
use DateTime ();
@ -3519,7 +3520,7 @@ sub is_patron_inside_charge_limits {
my $guarantors_non_issues_charges = 0;
# Check the debt of this patrons guarantees
if ( defined $no_issues_charge_guarantees ) {
if ( defined $no_issues_charge_guarantees && looks_like_number($no_issues_charge_guarantees) ) {
my @guarantees = map { $_->guarantee } $patron->guarantee_relationships->as_list;
foreach my $g (@guarantees) {
$guarantees_non_issues_charges += $g->account->non_issues_charges;
@ -3527,7 +3528,9 @@ sub is_patron_inside_charge_limits {
}
# Check the debt of this patrons guarantors *and* the guarantees of those guarantors
if ( defined $no_issues_charge_guarantors_with_guarantees ) {
if ( defined $no_issues_charge_guarantors_with_guarantees
&& looks_like_number($no_issues_charge_guarantors_with_guarantees) )
{
$guarantors_non_issues_charges = $patron->relationships_debt(
{ include_guarantors => 1, only_this_guarantor => 0, include_this_patron => 1 } );
}