From d7ab10b4659ef22694aa2ab6946ec3bfda0e8c5e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 3 Jul 2023 13:45:28 +0100 Subject: [PATCH] Bug 33028: Throw exception if not passed a decimal number Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit d5b1041f43c2a6d8b82f6ee88c1ecf6aaaeb9cae) Signed-off-by: Fridolin Somers (cherry picked from commit 0bd5fb0bb64fb7eb6a23b719155b9da67d81e99e) Signed-off-by: Pedro Amorim --- Koha/CirculationRules.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index b06f8fd12c..38cd6a26b0 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -381,7 +381,8 @@ sub set_rule { my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; $rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank; my $is_monetary = defined $kind_info->{is_monetary} ? $kind_info->{is_monetary} : 0; - $rule_value = Koha::Number::Price->new($rule_value)->unformat if defined $rule_value && $is_monetary; + Koha::Exceptions::BadParameter->throw("set_rule expected decimal") + if ( $is_monetary && defined($rule_value) && $rule_value !~ /^\d+(\.\d{2})?$/ ); for my $v ( $branchcode, $categorycode, $itemtype ) { $v = undef if $v and $v eq '*'; -- 2.39.5