From 6c0eb32a084c50efc7af16720820e355ceb8a4bf 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. Set a few different numbers for different branches as well. 4) Place a hold on a biblio from the staff client. 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 on the OPAC. Notice that when you change the pick up location, the number of days in the pickup message below the dropdown changes based on the circ rules. 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 13) Test Talking Tech: 13a) Enable TalkingTechItivaPhoneNotification 13b) Go to Tools -> Notices & slips. Add content to the HOLD phone (itiva) notice. 13c) In your terminal, run perl /path/to/koha/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl -o ~/itiva.tmp -w 0 --type=RESERVE Sponsored-by: Catalyst IT Signed-off-by: Emmi Takkinen Signed-off-by: Nick Clemens Signed-off-by: Kelly Signed-off-by: Katrin Fischer Signed-off-by: Kelly Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- Koha/CirculationRules.pm | 3 + Koha/Hold.pm | 11 +++ admin/smart-rules.pl | 77 +++++++++---------- ...8367-add_holds_pickup_period_circrule.perl | 6 ++ installer/onboarding.pl | 1 + .../prog/en/modules/admin/smart-rules.tt | 7 +- .../bootstrap/en/modules/opac-reserve.tt | 20 +++++ .../thirdparty/TalkingTech_itiva_outbound.pl | 11 +++ opac/opac-reserve.pl | 15 ++++ t/db_dependent/Holds/WaitingReserves.t | 68 +++++++++++++++- 10 files changed, 178 insertions(+), 41 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 6f76053ae7..1d07476875 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -213,6 +213,9 @@ our $RULE_KINDS = { recall_shelf_time => { 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 1a1a859bca..b13892dc6c 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -233,6 +233,17 @@ sub set_waiting { my $new_expiration_date = dt_from_string($self->waitingdate)->clone->add( days => $max_pickup_delay ); + 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; + } + if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; my $daysmode = Koha::CirculationRules->get_effective_daysmode( diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 499d7e8e5a..49ae398613 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -298,47 +298,46 @@ elsif ($op eq 'add') { my $recall_due_date_interval = $input->param('recall_due_date_interval'); my $recall_overdue_fine = $input->param('recall_overdue_fine'); my $recall_shelf_time = $input->param('recall_shelf_time'); + my $holds_pickup_period = strip_non_numeric($input->param('holds_pickup_period')); my $rules = { - maxissueqty => $maxissueqty, - maxonsiteissueqty => $maxonsiteissueqty, - rentaldiscount => $rentaldiscount, - fine => $fine, - finedays => $finedays, - maxsuspensiondays => $maxsuspensiondays, - suspension_chargeperiod => $suspension_chargeperiod, - firstremind => $firstremind, - chargeperiod => $chargeperiod, - chargeperiod_charge_at => $chargeperiod_charge_at, - issuelength => $issuelength, - daysmode => $daysmode, - lengthunit => $lengthunit, - hardduedate => $hardduedate, - hardduedatecompare => $hardduedatecompare, - renewalsallowed => $renewalsallowed, - unseen_renewals_allowed => $unseen_renewals_allowed, - renewalperiod => $renewalperiod, - norenewalbefore => $norenewalbefore, - noautorenewalbefore => $noautorenewalbefore, - auto_renew => $auto_renew, - no_auto_renewal_after => $no_auto_renewal_after, - no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit, - reservesallowed => $reservesallowed, - holds_per_record => $holds_per_record, - holds_per_day => $holds_per_day, - onshelfholds => $onshelfholds, - opacitemholds => $opacitemholds, - overduefinescap => $overduefinescap, - cap_fine_to_replacement_price => $cap_fine_to_replacement_price, - article_requests => $article_requests, - note => $note, - decreaseloanholds => $decreaseloanholds, - recalls_allowed => $recalls_allowed, - recalls_per_record => $recalls_per_record, - on_shelf_recalls => $on_shelf_recalls, - recall_due_date_interval => $recall_due_date_interval, - recall_overdue_fine => $recall_overdue_fine, - recall_shelf_time => $recall_shelf_time, + maxissueqty => $maxissueqty, + maxonsiteissueqty => $maxonsiteissueqty, + rentaldiscount => $rentaldiscount, + fine => $fine, + finedays => $finedays, + maxsuspensiondays => $maxsuspensiondays, + suspension_chargeperiod => $suspension_chargeperiod, + firstremind => $firstremind, + chargeperiod => $chargeperiod, + chargeperiod_charge_at => $chargeperiod_charge_at, + issuelength => $issuelength, + daysmode => $daysmode, + lengthunit => $lengthunit, + hardduedate => $hardduedate, + hardduedatecompare => $hardduedatecompare, + renewalsallowed => $renewalsallowed, + unseen_renewals_allowed => $unseen_renewals_allowed, + renewalperiod => $renewalperiod, + norenewalbefore => $norenewalbefore, + noautorenewalbefore => $noautorenewalbefore, + auto_renew => $auto_renew, + no_auto_renewal_after => $no_auto_renewal_after, + no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit, + onshelfholds => $onshelfholds, + opacitemholds => $opacitemholds, + overduefinescap => $overduefinescap, + cap_fine_to_replacement_price => $cap_fine_to_replacement_price, + article_requests => $article_requests, + note => $note, + decreaseloanholds => $decreaseloanholds, + recalls_allowed => $recalls_allowed, + recalls_per_record => $recalls_per_record, + on_shelf_recalls => $on_shelf_recalls, + recall_due_date_interval => $recall_due_date_interval, + recall_overdue_fine => $recall_overdue_fine, + recall_shelf_time => $recall_shelf_time, + 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 0000000000..2f62aa436d --- /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 d429f01c36..306e891d35 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -287,6 +287,7 @@ if ( $step == 5 ) { recall_due_date_interval => undef, recall_overdue_fine => undef, recall_shelf_time => 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 a5fa1e63c5..65937015f4 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 @@ -146,6 +146,7 @@ Holds per record (count) On shelf holds allowed OPAC item level holds + Holds pickup period (day) [% IF Koha.Preference('ArticleRequests') %] Article requests [% END %] @@ -206,8 +207,9 @@ [% SET recall_due_date_interval = all_rules.$c.$i.recall_due_date_interval %] [% SET recall_overdue_fine = all_rules.$c.$i.recall_overdue_fine %] [% SET recall_shelf_time = all_rules.$c.$i.recall_shelf_time %] + [% SET holds_pickup_period = all_rules.$c.$i.holds_pickup_period %] - [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || noautorenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || recalls_allowed || recalls_per_record || on_shelf_recalls || recall_due_date_interval || recall_overdue_fine || recall_shelf_time %] + [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || noautorenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || recalls_allowed || recalls_per_record || on_shelf_recalls || recall_due_date_interval || recall_overdue_fine || recall_shelf_time || holds_pickup_period %] [% IF show_rule %] [% SET row_count = row_count + 1 %] @@ -370,6 +372,7 @@ Don't allow [% END %] + [% holds_pickup_period | html %] [% IF Koha.Preference('ArticleRequests') %] [% IF article_requests == 'no' %] @@ -519,6 +522,7 @@ + [% IF Koha.Preference('ArticleRequests') %]