From 16cf05f74d9ff83fc56b49524e040b38e16af1a2 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 Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit daedce4f6ea7d7ae9d4f12cd54e94b0230683a92) Signed-off-by: Fridolin Somers (cherry picked from commit 093a97c67b5cc9ab0741f860a119e090b8a3360b) Signed-off-by: Pedro Amorim --- Koha/CirculationRules.pm | 7 ++++--- admin/smart-rules.pl | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index a9253b50b5..55f3db1283 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -162,8 +162,9 @@ our $RULE_KINDS = { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, overduefinescap => { - scope => [ 'branchcode', 'categorycode', 'itemtype' ], - is_monetary => 1, + scope => [ 'branchcode', 'categorycode', 'itemtype' ], + is_monetary => 1, + can_be_blank => 1, }, renewalperiod => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], @@ -383,7 +384,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+)?$/ ); + if ( $is_monetary && !$can_be_blank && defined($rule_value) && $rule_value !~ /^\d+(\.\d+)?$/ ); 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.39.5