From e287f8ad1262dd38ab8ea4f8ad2e94ae28f74969 Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Thu, 5 Aug 2021 16:37:40 +0300 Subject: [PATCH] Bug 25711: move get_effective_expire_charge to Koha::CirculationRules Move get_effective_expire_reserves_charge as a new method in Koha::CirculationRules to retrieve the effective value of the rule. --- Koha/CirculationRules.pm | 26 ++++++++++++++++++++++++++ Koha/Hold.pm | 11 +++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 959eb14d76..fd9ec35329 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -579,6 +579,32 @@ sub get_effective_daysmode { } +=head3 get_effective_expire_reserves_charge + +Return the value for expire_reserves_charge defined in the circulation rules. +If not defined (or empty string), the value of the system preference ExpireReservesMaxPickUpDelayCharge is returned + +=cut + +sub get_effective_expire_reserves_charge { + my ( $class, $params ) = @_; + + my $itemtype = $params->{itemtype}; + my $branchcode = $params->{branchcode}; + my $categorycode = $params->{categorycode}; + + my $expire_reserves_charge_rule = $class->get_effective_rule( + { + itemtype => $itemtype, + branchcode => $branchcode, + categorycode => $categorycode, + rule_name => 'expire_reserves_charge', + } + ); + + return $expire_reserves_charge_rule ? $expire_reserves_charge_rule->rule_value : C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); + +} =head3 type diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 35ea687795..9d2c348b99 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -553,19 +553,14 @@ sub cancel { # and, if desired, charge a cancel fee if ( $params->{'charge_cancel_fee'} ) { - my $charge; my $item = $self->item; - my $branchcode = C4::Reserves::GetReservesControlBranch($item->unblessed, $self->borrower->unblessed); - - my $rule = Koha::CirculationRules->get_effective_rule( + my $charge = Koha::CirculationRules->get_effective_expire_reserves_charge( { + itemtype => $item->effective_itemtype, + branchcode => C4::Reserves::GetReservesControlBranch($item->unblessed, $self->borrower->unblessed), categorycode => $self->borrower->categorycode, - itemtype => $item->effective_itemtype, - branchcode => $branchcode, - rule_name => 'expire_reserves_charge', } ); - $charge = $rule ? $rule->rule_value : C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); my $account = Koha::Account->new( { patron_id => $self->borrowernumber } ); -- 2.31.1