Bug 22321: Update holds borrowernumber when ILL request borrowernumber changes
[koha-ffzg.git] / Koha / CurbsidePickup.pm
index e35b30e..cbbd163 100644 (file)
@@ -26,6 +26,7 @@ use base qw(Koha::Object);
 use C4::Circulation qw( CanBookBeIssued AddIssue );
 use C4::Members::Messaging qw( GetMessagingPreferences );
 use C4::Letters qw( GetPreparedLetter EnqueueLetter );
+use Koha::Calendar;
 use Koha::DateUtils qw( dt_from_string );
 use Koha::Patron;
 use Koha::Library;
@@ -55,10 +56,13 @@ sub new {
     Koha::Exceptions::CurbsidePickup::NotEnabled->throw
       unless $policy && $policy->enabled;
 
+    my $calendar = Koha::Calendar->new( branchcode => $params->{branchcode} );
+    Koha::Exceptions::CurbsidePickup::LibraryIsClosed->throw
+      if $calendar->is_holiday( $params->{scheduled_pickup_datetime} );
+
     if ( $policy->enable_waiting_holds_only ) {
         my $patron        = Koha::Patrons->find( $params->{borrowernumber} );
-        my $waiting_holds = $patron->holds->search(
-            { found => 'W', branchcode => $params->{branchcode} } );
+        my $waiting_holds = $patron->holds->waiting->search( { branchcode => $params->{branchcode} } );
 
         Koha::Exceptions::CurbsidePickup::NoWaitingHolds->throw
           unless $waiting_holds->count;
@@ -240,7 +244,7 @@ sub mark_as_delivered {
     my $holds           = $patron->holds;
     my $branchcode = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
     foreach my $hold ( $holds->as_list ) {
-        if ( $hold->found eq 'W' && $branchcode && $hold->branchcode eq $branchcode ) {
+        if ( $hold->is_waiting && $branchcode && $hold->branchcode eq $branchcode ) {
             my ( $issuingimpossible, $needsconfirmation ) =
               C4::Circulation::CanBookBeIssued( $patron, $hold->item->barcode );