#
# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Carp qw(croak);
holdallowed => {
scope => [ 'branchcode', 'itemtype' ],
+ can_be_blank => 0,
},
hold_fulfillment_policy => {
scope => [ 'branchcode', 'itemtype' ],
+ can_be_blank => 0,
},
returnbranch => {
scope => [ 'branchcode', 'itemtype' ],
+ can_be_blank => 0,
},
article_requests => {
issuelength => {
scope => [ 'branchcode', 'categorycode', 'itemtype' ],
},
+ daysmode => {
+ scope => [ 'branchcode', 'categorycode', 'itemtype' ],
+ },
lengthunit => {
scope => [ 'branchcode', 'categorycode', 'itemtype' ],
},
my $itemtype = $params->{itemtype};
my $branchcode = $params->{branchcode};
- my @c = caller;
Koha::Exceptions::MissingParameter->throw(
- "Required parameter 'rule_name' missing" . "@c")
+ "Required parameter 'rule_name' missing")
unless $rule_name;
for my $v ( $branchcode, $categorycode, $itemtype ) {
my $itemtype = $params->{itemtype};
my $rule_name = $params->{rule_name};
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;
for my $v ( $branchcode, $categorycode, $itemtype ) {
$v = undef if $v and $v eq '*';
rule_name => 'onshelfholds',
}
);
- return $rule ? $rule->rule_value : undef;
+ return $rule ? $rule->rule_value : 0;
+}
+
+=head3 get_lostreturn_policy
+
+ my $refund = Koha::CirculationRules->get_lostreturn_policy( { return_branch => $return_branch, item => $item } );
+
+=cut
+
+sub get_lostreturn_policy {
+ my ( $class, $params ) = @_;
+
+ my $item = $params->{item};
+
+ my $behaviour = C4::Context->preference( 'RefundLostOnReturnControl' ) // 'CheckinLibrary';
+ my $behaviour_mapping = {
+ CheckinLibrary => $params->{'return_branch'} // $item->homebranch,
+ ItemHomeBranch => $item->homebranch,
+ ItemHoldingBranch => $item->holdingbranch
+ };
+
+ my $branch = $behaviour_mapping->{ $behaviour };
+
+ my $rule = Koha::CirculationRules->get_effective_rule(
+ {
+ branchcode => $branch,
+ rule_name => 'refund',
+ }
+ );
+
+ return $rule ? $rule->rule_value : 1;
}
=head3 article_requestable_rules
return $res;
}
+=head3 get_daysmode_effective_value
+
+Return the value for daysmode defined in the circulation rules.
+If not defined (or empty string), the value of the system preference useDaysMode is returned
+
+=cut
+
+sub get_effective_daysmode {
+ my ( $class, $params ) = @_;
+
+ my $categorycode = $params->{categorycode};
+ my $itemtype = $params->{itemtype};
+ my $branchcode = $params->{branchcode};
+
+ my $daysmode_rule = $class->get_effective_rule(
+ {
+ categorycode => $categorycode,
+ itemtype => $itemtype,
+ branchcode => $branchcode,
+ rule_name => 'daysmode',
+ }
+ );
+
+ return ( defined($daysmode_rule)
+ and $daysmode_rule->rule_value ne '' )
+ ? $daysmode_rule->rule_value
+ : C4::Context->preference('useDaysMode');
+
+}
+
=head3 type