@@ -, +, @@
- Create an issuing rule a patron category and itemtype. make it
has priority,
- create more permissive issuing rules for all other branches,
- check that the priority rule is taken into account for this
category
and itemtype.
---
Koha/CirculationRules.pm | 7 +++++-
admin/smart-rules.pl | 4 +++
.../prog/en/modules/admin/smart-rules.tt | 27 +++++++++++++++++++-
t/db_dependent/Koha/IssuingRules.t | 29 +++++++++++++++++++++-
4 files changed, 64 insertions(+), 3 deletions(-)
--- a/Koha/CirculationRules.pm
+++ a/Koha/CirculationRules.pm
@@ -59,7 +59,9 @@ our $RULE_KINDS = {
max_holds => {
scope => [ 'branchcode', 'categorycode' ],
},
-
+ has_priority => {
+ scope => [ 'branchcode', 'categorycode' ],
+ },
holdallowed => {
scope => [ 'branchcode', 'itemtype' ],
can_be_blank => 0,
@@ -189,11 +191,13 @@ sub get_effective_rule {
$params->{categorycode} //= undef;
$params->{branchcode} //= undef;
$params->{itemtype} //= undef;
+ $params->{has_priority} //= undef;
my $rule_name = $params->{rule_name};
my $categorycode = $params->{categorycode};
my $itemtype = $params->{itemtype};
my $branchcode = $params->{branchcode};
+ my $has_priority = $params->{has_priority};
Koha::Exceptions::MissingParameter->throw(
"Required parameter 'rule_name' missing")
@@ -212,6 +216,7 @@ sub get_effective_rule {
$search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
$search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef;
$search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef;
+ $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef;
my $rule = $self->search(
$search_params,
--- a/admin/smart-rules.pl
+++ a/admin/smart-rules.pl
@@ -251,6 +251,7 @@ elsif ($op eq 'add') {
my $br = $branch; # branch
my $bor = $input->param('categorycode'); # borrower category
my $itemtype = $input->param('itemtype'); # item type
+ my $has_priority = $input->param('has_priority') ? 1 : 0;
my $fine = $input->param('fine');
my $finedays = $input->param('finedays');
my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
@@ -292,10 +293,12 @@ elsif ($op eq 'add') {
my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
$debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
+
my $rules = {
maxissueqty => $maxissueqty,
maxonsiteissueqty => $maxonsiteissueqty,
rentaldiscount => $rentaldiscount,
+ has_priority => $has_priority,
fine => $fine,
finedays => $finedays,
maxsuspensiondays => $maxsuspensiondays,
@@ -332,6 +335,7 @@ elsif ($op eq 'add') {
categorycode => $bor eq '*' ? undef : $bor,
itemtype => $itemtype eq '*' ? undef : $itemtype,
branchcode => $br eq '*' ? undef : $br,
+ has_priority => $has_priority,
rules => $rules,
}
);
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
@@ -96,6 +96,7 @@
Item type |
Actions |
Note |
+ [% UNLESS humanbranch %]Has priority | [% END %]
Current checkouts allowed |
Current on-site checkouts allowed |
Loan period |
@@ -199,6 +200,15 @@
View note
[% ELSE %] [% END %]
+ [% UNLESS humanbranch %]
+
+ [% IF rule.has_priority %]
+
+ [% ELSE %]
+
+ [% END %]
+ |
+ [% END %]
[% IF maxissueqty.defined && maxissueqty != '' %]
[% maxissueqty | html %]
@@ -374,6 +384,11 @@
|
|
+ [% UNLESS humanbranch %]
+
+
+ |
+ [% END %]
|
|
|
@@ -473,6 +488,7 @@
Item type |
|
Note |
+ [% UNLESS humanbranch %]Has priority | [% END %]
Current checkouts allowed |
Current on-site checkouts allowed |
Loan period |
@@ -744,7 +760,11 @@
[% UNLESS humanbranch %]
-
+ [% IF branch_cat_rule_loo.has_priority %]
+
+ [% ELSE %]
+
+ [% END %]
|
[% END %]
@@ -1118,6 +1138,10 @@
var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
$('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
+ } else if ( i == 3 ) {
+ var has_priority = $(this).find("input[type='checkbox']");
+ $('#has_priority').prop('checked', has_priority.is(':checked') );
+ //$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
} else {
$(current_column).find("input[type='text']").val(itm);
// select the corresponding option
@@ -1146,6 +1170,7 @@
// - "Holds allowed (total)"
// - "Holds allowed (daily)"
// - "Holds per record (count)"
+ // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
// The value is "Unlimited" (or an equivalent translated string)
// an it should be set to an empty string
if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
--- a/t/db_dependent/Koha/IssuingRules.t
+++ a/t/db_dependent/Koha/IssuingRules.t
@@ -36,12 +36,39 @@ $schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
subtest 'get_effective_issuing_rule' => sub {
- plan tests => 2;
+ plan tests => 3;
my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'};
my $branchcode = $builder->build({ source => 'Branch' })->{'branchcode'};
+ subtest 'Priority rule' => sub {
+ plan tests => 3;
+
+ Koha::IssuingRules->delete;
+
+ ok(Koha::IssuingRule->new({
+ branchcode => $branchcode,
+ categorycode => $categorycode,
+ itemtype => $itemtype,
+ })->store, "Given I added an issuing rule branchcode => $branchcode,'
+ .' categorycode => $categorycode, itemtype => $itemtype,");
+
+ ok(Koha::IssuingRule->new({
+ branchcode => '*',
+ categorycode => $categorycode,
+ itemtype => $itemtype,
+ has_priority => 1,
+ })->store, "Add a priority rule.");
+
+ my $rule = Koha::IssuingRules->get_effective_issuing_rule({
+ branchcode => $branchcode,
+ categorycode => $categorycode,
+ itemtype => $itemtype,
+ });
+ is($rule->has_priority, 1, 'Priority rule should be returned');
+ };
+
subtest 'Call with undefined values' => sub {
plan tests => 5;
--