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 <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
1f9e161b41
commit
2b48a948cb
1 changed files with 8 additions and 10 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue