From dbe694aaad4bbfd1f7de07b0715c60fc3a28c5e4 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 8 Aug 2018 20:31:32 +1200 Subject: [PATCH] Bug 19532: Added ability to set Recall due date interval, and Recall pickup period to hours Previously you could only set a number of days a recalled item has to be returned (Recall due date interval (days)) and a number of days available for a recalled item to be picked up. For academic libraries which often loan high-demand items out by a certain number of hours being able to set the number of hours a borrower has to return a recalled item and for the recaller to pickup the waiting recall is important. This patch implement a check in C4::Overdue->CalcFine() if item is recalled. If the item has been recalled and is past the due date then use the recall_overdue_fine to calculate the appropriate fine to charge the patron, otherwise use the fines value in the issuingrules table Also implemented atomicupdate to change recalls waitingdate and expirationdate to datetime datatypes with associated template changes in the recalls reports to display the date and time of these recall values. Test plan: 1. Apply all other patches on bug 19532 (except this patch) 2. Set a fine charge interval period (if you do not have this field set in the circ rule then the fine will not be applied). 3. Set the 'Unit' of the circ rule to 'hours', 'Recall due date interval' = 1, recall overdue fune amount= 1, recall pickup period=1 4. Check out an item to borrower A and recall it in the OPAC by borrower B 5. In the database manually change the issues.date_due to 1 hour before the current time 6. From the Koha shell run './misc/cronjobs/fines.pl' 7. Notice the fine of 1 has been applied to the borrower for being 1 hour late in returning the recall 8. Return the item and confirm the recall. Manually change the waiting date to more than 1 hour before the current time and repeat step 6 running overdue_notices.pl 9. Notice the recall is overdue now Sponsored-By: Toi Ohomai Institute of Technology, New Zealand --- C4/Overdues.pm | 11 ++++++++++- .../bug_19532_-_alter_recalls_table_date_datatypes.sql | 3 +++ koha-tmpl/intranet-tmpl/prog/en/includes/recalls-reports.inc | 10 +++++----- koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt | 4 ++-- 4 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_19532_-_alter_recalls_table_date_datatypes.sql diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 1e67b7f..973a280 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -38,6 +38,7 @@ use Koha::Account::Lines; use Koha::Account::Offsets; use Koha::IssuingRules; use Koha::Libraries; +use Koha::Recalls; use vars qw(@ISA @EXPORT); @@ -255,7 +256,15 @@ sub CalcFine { # If chargeperiod_charge_at = 1, we charge a fine at the start of each charge period # if chargeperiod_charge_at = 0, we charge at the end of each charge period $charge_periods = $issuing_rule->chargeperiod_charge_at == 1 ? ceil($charge_periods) : floor($charge_periods); - $amount = $charge_periods * $issuing_rule->fine; + + # check if item has been recalled. + my $currentrecall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, status => 'R' }); + if (defined $currentrecall) { + $amount = $charge_periods * $issuing_rule->recall_overdue_fine; + } else { + $amount = $charge_periods * $issuing_rule->fine; + } + } # else { # a zero (or null) chargeperiod or negative units_minus_grace value means no charge. } $amount = $issuing_rule->overduefinescap if $issuing_rule->overduefinescap && $amount > $issuing_rule->overduefinescap; diff --git a/installer/data/mysql/atomicupdate/bug_19532_-_alter_recalls_table_date_datatypes.sql b/installer/data/mysql/atomicupdate/bug_19532_-_alter_recalls_table_date_datatypes.sql new file mode 100644 index 0000000..f4ce745 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_19532_-_alter_recalls_table_date_datatypes.sql @@ -0,0 +1,3 @@ +ALTER TABLE recalls MODIFY column waitingdate datetime; +ALTER TABLE recalls MODIFY column expirationdate datetime; + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls-reports.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls-reports.inc index fd683d0..7ba692d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls-reports.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls-reports.inc @@ -58,18 +58,18 @@ - [% IF recall.waitingdate %][% recall.waitingdate | $KohaDates %][% ELSE %]Not waiting[% END %] + [% IF recall.waitingdate %][% recall.waitingdate %][% ELSE %]Not waiting[% END %] [% IF ( recall.is_waiting ) %] [% IF ( recall.expirationdate ) %] - [% recall.expirationdate | $KohaDates %] + [% recall.expirationdate %] [% ELSE %] Never expires [% END %] [% ELSIF ( recall.has_expired && recall.expirationdate ) %] - [% recall.expirationdate | $KohaDates %] + [% recall.expirationdate %] [% ELSE %] - [% END %] @@ -97,9 +97,9 @@ [% IF ( recall.is_requested ) %] - Due to be returned by [% recall.checkout.date_due | $KohaDates %] + Due to be returned by [% recall.checkout.date_due %] [% ELSIF ( recall.is_waiting && recall.expirationdate ) %] - Pick up by [% recall.expirationdate | $KohaDates %] + Pick up by [% recall.expirationdate %] [% ELSE %] - [% END %] 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 7303a62..04343dc 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 @@ -95,9 +95,9 @@ Holds per record (count) On shelf holds allowed Item level holds - Recall due date interval (days) + Recall due date interval Recall overdue fine amount - Recall pickup period (days) + Recall pickup period Article requests Rental discount (%) Actions -- 2.1.4