From d1398df470f5df1851b0c1a1dbb247d0deaafec7 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 14 Jul 2023 09:08:51 -0400 Subject: [PATCH] Bug 32271: (QA follow-up) Convert all positive numbers to monetary float and convert all 0 equivilents to blank value Signed-off-by: Katrin Fischer --- Koha/CirculationRules.pm | 3 ++- admin/smart-rules.pl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 38cd6a26b0..52a7643f0d 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -163,6 +163,7 @@ our $RULE_KINDS = { overduefinescap => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], is_monetary => 1, + can_be_blank => 1, }, renewalperiod => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], @@ -382,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::BadParameter->throw("set_rule expected decimal") - if ( $is_monetary && defined($rule_value) && $rule_value !~ /^\d+(\.\d{2})?$/ ); + if ( $is_monetary && !$can_be_blank && defined($rule_value) && $rule_value !~ /^\d+(\.\d{2})?$/ ); for my $v ( $branchcode, $categorycode, $itemtype ) { $v = undef if $v and $v eq '*'; diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index b74a0ceeab..d073bda5d5 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -284,7 +284,8 @@ elsif ($op eq 'add') { my $rentaldiscount = $input->param('rentaldiscount') || 0; my $opacitemholds = $input->param('opacitemholds') || 0; my $article_requests = $input->param('article_requests') || 'no'; - my $overduefinescap = $input->param('overduefinescap') || q{}; + my $overduefinescap = $input->param('overduefinescap') + && ( $input->param('overduefinescap') + 0 ) > 0 ? sprintf( "%.02f", $input->param('overduefinescap') ) : q{}; my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || q{}) eq 'on'; my $note = $input->param('note'); my $decreaseloanholds = $input->param('decreaseloanholds') || q{}; -- 2.30.2