Bugzilla – Attachment 114532 Details for
Bug 8137
Checkout limit for all libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8137: Add default issuing rule for all branches.
Bug-8137-Add-default-issuing-rule-for-all-branches.patch (text/plain), 10.64 KB, created by
Andrew Fuerste-Henry
on 2020-12-18 17:01:28 UTC
(
hide
)
Description:
Bug 8137: Add default issuing rule for all branches.
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2020-12-18 17:01:28 UTC
Size:
10.64 KB
patch
obsolete
>From 006640ee428da756cda1705d165d95be092a4cec Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Fri, 7 Jul 2017 08:31:37 +0000 >Subject: [PATCH] Bug 8137: Add default issuing rule for all branches. > >This patch does the same that for 'Default checkout limit by patron >category'. > >test plan: > > - 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. > >Rebased: 2018-03-14, by: Alex Arnaud <alex.arnaud@biblibre.com> >Rebased: 2020-07-34, by: Arthur Suzuki <arthur.suzuki@biblibre.com> > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > 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(-) > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index df1314613e..e1f1e8fb36 100644 >--- a/Koha/CirculationRules.pm >+++ b/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, >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index 4abcf04c0d..b0ff861658 100755 >--- a/admin/smart-rules.pl >+++ b/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, > } > ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index c4ab140e30..10cce28901 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -96,6 +96,7 @@ > <th class="fixed_sort">Item type</th> > <th>Actions</th> > <th>Note</th> >+ [% UNLESS humanbranch %]<th>Has priority</th>[% END %] > <th>Current checkouts allowed</th> > <th>Current on-site checkouts allowed</th> > <th>Loan period</th> >@@ -199,6 +200,15 @@ > <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a> > [% ELSE %]<span> </span>[% END %] > </td> >+ [% UNLESS humanbranch %] >+ <td> >+ [% IF rule.has_priority %] >+ <input type="checkbox" checked="checked" disabled="disabled"/> >+ [% ELSE %] >+ <input type="checkbox" disabled="disabled"/> >+ [% END %] >+ </td> >+ [% END %] > <td> > [% IF maxissueqty.defined && maxissueqty != '' %] > [% maxissueqty | html %] >@@ -374,6 +384,11 @@ > <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button> > </td> > <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td> >+ [% UNLESS humanbranch %] >+ <td> >+ <input type="checkbox" name="has_priority" id="has_priority"/> >+ </td> >+ [% END %] > <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td> > <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td> > <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td> >@@ -473,6 +488,7 @@ > <th>Item type</th> > <th> </th> > <th>Note</th> >+ [% UNLESS humanbranch %]<th>Has priority</th>[% END %] > <th>Current checkouts allowed</th> > <th>Current on-site checkouts allowed</th> > <th>Loan period</th> >@@ -744,7 +760,11 @@ > </td> > [% UNLESS humanbranch %] > <td> >- <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/> >+ [% IF branch_cat_rule_loo.has_priority %] >+ <input type="checkbox" checked="checked" disabled/> >+ [% ELSE %] >+ <input type="checkbox" disabled/> >+ [% END %] > </td> > [% 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)) ) { >diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t >index afcb2867b7..ef7eda779d 100755 >--- a/t/db_dependent/Koha/IssuingRules.t >+++ b/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; > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8137
:
9705
|
9706
|
11079
|
64703
|
64704
|
64791
|
64891
|
72831
|
72832
|
107207
|
107208
|
107209
|
107459
|
111368
|
111369
|
111370
|
112640
|
113797
|
113882
|
114531
|
114532
|
114533
|
114534
|
116676
|
116677
|
116678
|
116679
|
116680
|
145476
|
145477
|
145478
|
145479
|
145480
|
152040
|
152041
|
152042
|
152043
|
152044
|
152045
|
156316
|
156317
|
156318
|
156319
|
156320
|
156321
|
156322
|
159712
|
162367
|
167208
|
167923
|
168119
|
169084
|
169696
|
169700
|
169727
|
169927
|
169928
|
170411
|
173605
|
173608
|
175837
|
175838
|
177464