From 4a8fdaee6695c576966ddfa78262ae4f8da10651 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 3 Mar 2023 11:28:20 +0000 Subject: [PATCH] Bug 33028: (follow-up) Move monetary definition into hash This patch moves the defintion of monetary rule type into the rule kinds hash. Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 2b48a948cbe7f14526e4ea8836e5175e38ab9d20) Signed-off-by: Fridolin Somers --- Koha/CirculationRules.pm | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index d002937237..5f6d31c851 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -101,8 +101,9 @@ our $RULE_KINDS = { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, fine => { - scope => [ 'branchcode', 'categorycode', 'itemtype' ], - }, + scope => [ 'branchcode', 'categorycode', 'itemtype' ], + is_monetary => 1, + }, finedays => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, @@ -159,8 +160,9 @@ our $RULE_KINDS = { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, overduefinescap => { - scope => [ 'branchcode', 'categorycode', 'itemtype' ], - }, + scope => [ 'branchcode', 'categorycode', 'itemtype' ], + is_monetary => 1, + }, renewalperiod => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, @@ -376,6 +378,8 @@ sub set_rule { my $rule_value = $params->{rule_value}; 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; for my $v ( $branchcode, $categorycode, $itemtype ) { $v = undef if $v and $v eq '*'; @@ -389,12 +393,6 @@ sub set_rule { } )->next(); - if ( $rule - && ( $rule->rule_name eq 'overduefinescap' || $rule->rule_name eq 'fine' ) ) - { - $rule_value = Koha::Number::Price->new($rule_value)->unformat; - } - if ($rule) { if ( defined $rule_value ) { $rule->rule_value($rule_value); -- 2.39.5