Bug 24159: Set days_mode according to circ rules in 3 other places
[srvgit] / Koha / Hold.pm
index e2308db..700c855 100644 (file)
@@ -5,18 +5,18 @@ package Koha::Hold;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
 
@@ -178,12 +178,21 @@ sub set_waiting {
 
     my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
     my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
-    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
 
     my $expirationdate = $today->clone;
     $expirationdate->add(days => $max_pickup_delay);
 
     if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
+        my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
+        my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value(
+            {
+                categorycode => $self->borrower->categorycode,
+                itemtype     => $itemtype,
+                branchcode   => $self->branchcode,
+            }
+        );
+        my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $useDaysMode_value );
+
         $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
     }
 
@@ -416,7 +425,7 @@ sub to_api_mapping {
         branchcode       => 'pickup_library_id',
         notificationdate => undef,
         reminderdate     => undef,
-        cancellationdate => 'cancelation_date',
+        cancellationdate => 'cancellation_date',
         reservenotes     => 'notes',
         found            => 'status',
         itemnumber       => 'item_id',