From 45b050871e7ed882b553f211db97204f30634646 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 19 Jul 2023 11:51:54 -0300 Subject: [PATCH] Bug 33028: (follow-up) Lower the two digits requirement This patch makes the code not require two decimal digits, as the main intention here is to forbid (locale) formatted strings to reach the DB. The number of digits we support needs to be discussed on its own bug, and a centralized check implemented. This patch fixes tests: prove t/db_dependent/Circulation.t t/db_dependent/Circulation.t .. 1/67 Exception 'Koha::Exceptions::CirculationRule::NotDecimal' thrown 'The circulation rule expected a decimal value' with name => fine, value => 0.1 t/db_dependent/Circulation.t .. Dubious, test returned 11 (wstat 2816, 0xb00) Failed 53/67 subtests Signed-off-by: Tomas Cohen Arazi --- Koha/CirculationRules.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 8518aa6112..a9253b50b5 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -383,7 +383,7 @@ sub set_rule { $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; Koha::Exceptions::CirculationRule::NotDecimal->throw( name => $rule_name, value => $rule_value ) - if ( $is_monetary && defined($rule_value) && $rule_value !~ /^\d+(\.\d{2})?$/ ); + if ( $is_monetary && defined($rule_value) && $rule_value !~ /^\d+(\.\d+)?$/ ); for my $v ( $branchcode, $categorycode, $itemtype ) { $v = undef if $v and $v eq '*'; -- 2.39.5