From 3da454727223fe1d283bf675e941f030194d9a7b Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 20 Apr 2020 16:13:35 +0000 Subject: [PATCH] Bug 8367: Add holds_pickup_period circulation rule So that pickup delay can have a different value per patron category, item type or branch. To test: 1) Update database, restart services 2) Set ReservesMaxPickUpDelay syspref (if not already set) 3) Edit your circulation rules and set a value under 'Holds pickup period (day) that is DIFFERENT from ReservesMaxPickUpDelay 4) Place a hold on a biblio 5) Check in an item from that biblio and confirm the hold as waiting 6) Confirm the expiration date is calculated using the 'Holds pickup period' value instead of the ReservesMaxPickUpDelay syspref 7) Revert the waiting status and delete the hold 8) Re-place the hold on the biblio 9) Create a holiday with a date that will overlap with the 'Holds pickup period' 10) Check in an item from that biblio and confirm the hold as waiting 11) Confirm the expiration date is calculated using the 'Holds pickup period' value AND considers the special holiday 12) Confirm tests pass t/db_dependent/Holds/WaitingReserves.t I've also added this to the TalkingTech_itiva_outbound.pl cronjob, I'm not sure how to test this. Please test properly if you can, otherwise maybe put some warns in and confirm the correct expiration date is calculated. Sponsored-by: Catalyst IT --- Koha/CirculationRules.pm | 3 + Koha/Hold.pm | 12 +++ admin/smart-rules.pl | 2 + .../bug_8367-add_holds_pickup_period_circrule.perl | 6 ++ installer/onboarding.pl | 1 + .../prog/en/modules/admin/smart-rules.tt | 7 +- .../thirdparty/TalkingTech_itiva_outbound.pl | 12 +++ t/db_dependent/Holds/WaitingReserves.t | 90 +++++++++++++++++++++- 8 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_8367-add_holds_pickup_period_circrule.perl diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 5042e6f55d3..cb84554b012 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -157,6 +157,9 @@ our $RULE_KINDS = { note => { # This is not really a rule. Maybe we will want to separate this later. scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, + holds_pickup_period => { + scope => [ 'branchcode', 'categorycode', 'itemtype' ], + }, # Not included (deprecated?): # * accountsent # * reservecharge diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 6896f5e94d1..bf1489842da 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -181,6 +181,18 @@ sub set_waiting { my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); my $expirationdate = $today->clone; + + my $rule = Koha::CirculationRules->get_effective_rule({ + categorycode => $self->borrower->categorycode, + itemtype => $self->item->effective_itemtype, + branchcode => $self->branchcode, + rule_name => 'holds_pickup_period', + }); + if ( defined($rule) and $rule->rule_value ne '' ){ + # circulation rule overrides ReservesMaxPickUpDelay + $max_pickup_delay = $rule->rule_value; + } + $expirationdate->add(days => $max_pickup_delay); if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 6bea920dd90..ccc6e6fc4e7 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -288,6 +288,7 @@ elsif ($op eq 'add') { my $overduefinescap = $input->param('overduefinescap') || ''; my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on'; my $note = $input->param('note'); + my $holds_pickup_period = strip_non_numeric($input->param('holds_pickup_period')); $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price"; my $rules = { @@ -320,6 +321,7 @@ elsif ($op eq 'add') { cap_fine_to_replacement_price => $cap_fine_to_replacement_price, article_requests => $article_requests, note => $note, + holds_pickup_period => $holds_pickup_period, }; Koha::CirculationRules->set_rules( diff --git a/installer/data/mysql/atomicupdate/bug_8367-add_holds_pickup_period_circrule.perl b/installer/data/mysql/atomicupdate/bug_8367-add_holds_pickup_period_circrule.perl new file mode 100644 index 00000000000..2f62aa436d6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_8367-add_holds_pickup_period_circrule.perl @@ -0,0 +1,6 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) VALUES (NULL, NULL, NULL, 'holds_pickup_period', NULL) }); + + NewVersion( $DBversion, 8367, "Add holds_pickup_period circulation rule" ); +} diff --git a/installer/onboarding.pl b/installer/onboarding.pl index 547df29e0da..d98b265a577 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -283,6 +283,7 @@ if ( $step == 5 ) { rentaldiscount => 0, reservesallowed => $reservesallowed, suspension_chargeperiod => undef, + holds_pickup_period => undef, } }; 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 5ae3bb94e1a..8de81cc7f6b 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 @@ -115,6 +115,7 @@ Holds per record (count) On shelf holds allowed OPAC item level holds + Holds pickup period (day) Article requests Rental discount (%) Actions @@ -153,10 +154,11 @@ [% SET holds_per_record = all_rules.$c.$i.holds_per_record %] [% SET onshelfholds = all_rules.$c.$i.onshelfholds %] [% SET opacitemholds = all_rules.$c.$i.opacitemholds %] + [% SET holds_pickup_period = all_rules.$c.$i.holds_pickup_period %] [% SET article_requests = all_rules.$c.$i.article_requests %] [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %] - [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests %] + [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests || holds_pickup_period %] [% IF show_rule %] [% SET row_count = row_count + 1 %] @@ -289,6 +291,7 @@ Don't allow [% END %] + [% holds_pickup_period | html %] [% IF article_requests == 'no' %] No @@ -395,6 +398,7 @@ +