Bug 22456: (QA follow-up) Consider cancellation requested as cancelled in OPAC
[koha.git] / Koha / Hold.pm
1 package Koha::Hold;
2
3 # Copyright ByWater Solutions 2014
4 # Copyright 2017 Koha Development team
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21 use Modern::Perl;
22
23 use List::MoreUtils qw( any );
24
25 use C4::Context;
26 use C4::Letters qw( GetPreparedLetter EnqueueLetter );
27 use C4::Log qw( logaction );
28
29 use Koha::AuthorisedValues;
30 use Koha::DateUtils qw( dt_from_string );
31 use Koha::Patrons;
32 use Koha::Biblios;
33 use Koha::Hold::CancellationRequests;
34 use Koha::Items;
35 use Koha::Libraries;
36 use Koha::Old::Holds;
37 use Koha::Calendar;
38 use Koha::Plugins;
39
40 use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
41
42 use Koha::Exceptions;
43 use Koha::Exceptions::Hold;
44
45 use base qw(Koha::Object);
46
47 =head1 NAME
48
49 Koha::Hold - Koha Hold object class
50
51 =head1 API
52
53 =head2 Class methods
54
55 =cut
56
57 =head3 age
58
59 returns the number of days since a hold was placed, optionally
60 using the calendar
61
62 my $age = $hold->age( $use_calendar );
63
64 =cut
65
66 sub age {
67     my ( $self, $use_calendar ) = @_;
68
69     my $today = dt_from_string;
70     my $age;
71
72     if ( $use_calendar ) {
73         my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
74         $age = $calendar->days_between( dt_from_string( $self->reservedate ), $today );
75     }
76     else {
77         $age = $today->delta_days( dt_from_string( $self->reservedate ) );
78     }
79
80     $age = $age->in_units( 'days' );
81
82     return $age;
83 }
84
85 =head3 suspend_hold
86
87 my $hold = $hold->suspend_hold( $suspend_until_dt );
88
89 =cut
90
91 sub suspend_hold {
92     my ( $self, $dt ) = @_;
93
94     my $date = $dt ? $dt->clone()->truncate( to => 'day' )->datetime : undef;
95
96     if ( $self->is_found ) {    # We can't suspend found holds
97         if ( $self->is_waiting ) {
98             Koha::Exceptions::Hold::CannotSuspendFound->throw( status => 'W' );
99         }
100         elsif ( $self->is_in_transit ) {
101             Koha::Exceptions::Hold::CannotSuspendFound->throw( status => 'T' );
102         }
103         elsif ( $self->is_in_processing ) {
104             Koha::Exceptions::Hold::CannotSuspendFound->throw( status => 'P' );
105         }
106         else {
107             Koha::Exceptions::Hold::CannotSuspendFound->throw(
108                       'Unhandled data exception on found hold (id='
109                     . $self->id
110                     . ', found='
111                     . $self->found
112                     . ')' );
113         }
114     }
115
116     $self->suspend(1);
117     $self->suspend_until($date);
118     $self->store();
119
120     Koha::Plugins->call(
121         'after_hold_action',
122         {
123             action  => 'suspend',
124             payload => { hold => $self->get_from_storage }
125         }
126     );
127
128     logaction( 'HOLDS', 'SUSPEND', $self->reserve_id, $self )
129         if C4::Context->preference('HoldsLog');
130
131     Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
132         {
133             biblio_ids => [ $self->biblionumber ]
134         }
135     ) if C4::Context->preference('RealTimeHoldsQueue');
136
137     return $self;
138 }
139
140 =head3 resume
141
142 my $hold = $hold->resume();
143
144 =cut
145
146 sub resume {
147     my ( $self ) = @_;
148
149     $self->suspend(0);
150     $self->suspend_until( undef );
151
152     $self->store();
153
154     Koha::Plugins->call(
155         'after_hold_action',
156         {
157             action  => 'resume',
158             payload => { hold => $self->get_from_storage }
159         }
160     );
161
162     logaction( 'HOLDS', 'RESUME', $self->reserve_id, $self )
163         if C4::Context->preference('HoldsLog');
164
165     Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
166         {
167             biblio_ids => [ $self->biblionumber ]
168         }
169     ) if C4::Context->preference('RealTimeHoldsQueue');
170
171     return $self;
172 }
173
174 =head3 delete
175
176 $hold->delete();
177
178 =cut
179
180 sub delete {
181     my ( $self ) = @_;
182
183     my $deleted = $self->SUPER::delete($self);
184
185     logaction( 'HOLDS', 'DELETE', $self->reserve_id, $self )
186         if C4::Context->preference('HoldsLog');
187
188     return $deleted;
189 }
190
191 =head3 set_transfer
192
193 =cut
194
195 sub set_transfer {
196     my ( $self ) = @_;
197
198     $self->priority(0);
199     $self->found('T');
200     $self->store();
201
202     return $self;
203 }
204
205 =head3 set_waiting
206
207 =cut
208
209 sub set_waiting {
210     my ( $self, $desk_id ) = @_;
211
212     $self->priority(0);
213
214     my $today = dt_from_string();
215
216     my $values = {
217         found => 'W',
218         ( !$self->waitingdate ? ( waitingdate => $today->ymd ) : () ),
219         desk_id => $desk_id,
220     };
221
222     my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
223     my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
224
225     my $new_expiration_date = $today->clone->add(days => $max_pickup_delay);
226
227     if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
228         my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
229         my $daysmode = Koha::CirculationRules->get_effective_daysmode(
230             {
231                 categorycode => $self->borrower->categorycode,
232                 itemtype     => $itemtype,
233                 branchcode   => $self->branchcode,
234             }
235         );
236         my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
237
238         $new_expiration_date = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
239     }
240
241     # If patron's requested expiration date is prior to the
242     # calculated one, we keep the patron's one.
243     if ( $self->patron_expiration_date ) {
244         my $requested_expiration = dt_from_string( $self->patron_expiration_date );
245
246         my $cmp =
247           $requested_expiration
248           ? DateTime->compare( $requested_expiration, $new_expiration_date )
249           : 0;
250
251         $new_expiration_date =
252           $cmp == -1 ? $requested_expiration : $new_expiration_date;
253     }
254
255     $values->{expirationdate} = $new_expiration_date->ymd;
256
257     $self->set($values)->store();
258
259     return $self;
260 }
261
262 =head3 is_pickup_location_valid
263
264     if ($hold->is_pickup_location_valid({ library_id => $library->id }) ) {
265         ...
266     }
267
268 Returns a I<boolean> representing if the passed pickup location is valid for the hold.
269 It throws a I<Koha::Exceptions::_MissingParameter> if the library_id parameter is not
270 passed.
271
272 =cut
273
274 sub is_pickup_location_valid {
275     my ( $self, $params ) = @_;
276
277     Koha::Exceptions::MissingParameter->throw('The library_id parameter is mandatory')
278         unless $params->{library_id};
279
280     my $pickup_locations;
281
282     if ( $self->itemnumber ) { # item-level
283         $pickup_locations = $self->item->pickup_locations({ patron => $self->patron });
284     }
285     else { # biblio-level
286         $pickup_locations = $self->biblio->pickup_locations({ patron => $self->patron });
287     }
288
289     return any { $_->branchcode eq $params->{library_id} } $pickup_locations->as_list;
290 }
291
292 =head3 set_pickup_location
293
294     $hold->set_pickup_location(
295         {
296             library_id => $library->id,
297           [ force   => 0|1 ]
298         }
299     );
300
301 Updates the hold pickup location. It throws a I<Koha::Exceptions::Hold::InvalidPickupLocation> if
302 the passed pickup location is not valid.
303
304 Note: It is up to the caller to verify if I<AllowHoldPolicyOverride> is set when setting the
305 B<force> parameter.
306
307 =cut
308
309 sub set_pickup_location {
310     my ( $self, $params ) = @_;
311
312     Koha::Exceptions::MissingParameter->throw('The library_id parameter is mandatory')
313         unless $params->{library_id};
314
315     if (
316         $params->{force}
317         || $self->is_pickup_location_valid(
318             { library_id => $params->{library_id} }
319         )
320       )
321     {
322         # all good, set the new pickup location
323         $self->branchcode( $params->{library_id} )->store;
324     }
325     else {
326         Koha::Exceptions::Hold::InvalidPickupLocation->throw;
327     }
328
329     return $self;
330 }
331
332 =head3 set_processing
333
334 $hold->set_processing;
335
336 Mark the hold as in processing.
337
338 =cut
339
340 sub set_processing {
341     my ( $self ) = @_;
342
343     $self->priority(0);
344     $self->found('P');
345     $self->store();
346
347     return $self;
348 }
349
350 =head3 is_found
351
352 Returns true if hold is waiting, in transit or in processing
353
354 =cut
355
356 sub is_found {
357     my ($self) = @_;
358
359     return 0 unless $self->found();
360     return 1 if $self->found() eq 'W';
361     return 1 if $self->found() eq 'T';
362     return 1 if $self->found() eq 'P';
363 }
364
365 =head3 is_waiting
366
367 Returns true if hold is a waiting hold
368
369 =cut
370
371 sub is_waiting {
372     my ($self) = @_;
373
374     my $found = $self->found;
375     return $found && $found eq 'W';
376 }
377
378 =head3 is_in_transit
379
380 Returns true if hold is a in_transit hold
381
382 =cut
383
384 sub is_in_transit {
385     my ($self) = @_;
386
387     return 0 unless $self->found();
388     return $self->found() eq 'T';
389 }
390
391 =head3 is_in_processing
392
393 Returns true if hold is a in_processing hold
394
395 =cut
396
397 sub is_in_processing {
398     my ($self) = @_;
399
400     return 0 unless $self->found();
401     return $self->found() eq 'P';
402 }
403
404 =head3 is_cancelable_from_opac
405
406 Returns true if hold is a cancelable hold
407
408 Holds may be only canceled if they are not found.
409
410 This is used from the OPAC.
411
412 =cut
413
414 sub is_cancelable_from_opac {
415     my ($self) = @_;
416
417     return 1 unless $self->is_found();
418     return 0; # if ->is_in_transit or if ->is_waiting or ->is_in_processing
419 }
420
421 =head3 cancellation_requestable_from_opac
422
423     if ( $hold->cancellation_requestable_from_opac ) { ... }
424
425 Returns a I<boolean> representing if a cancellation request can be placed on the hold
426 from the OPAC. It targets holds that cannot be cancelled from the OPAC (see the
427 B<is_cancelable_from_opac> method above), but for which circulation rules allow
428 requesting cancellation.
429
430 Throws a B<Koha::Exceptions::InvalidStatus> exception with the following I<invalid_status>
431 values:
432
433 =over 4
434
435 =item B<'hold_not_waiting'>: the hold is expected to be waiting and it is not.
436
437 =item B<'no_item_linked'>: the waiting hold doesn't have an item properly linked.
438
439 =back
440
441 =cut
442
443 sub cancellation_requestable_from_opac {
444     my ( $self ) = @_;
445
446     Koha::Exceptions::InvalidStatus->throw( invalid_status => 'hold_not_waiting' )
447       unless $self->is_waiting;
448
449     my $item = $self->item;
450
451     Koha::Exceptions::InvalidStatus->throw( invalid_status => 'no_item_linked' )
452       unless $item;
453
454     my $patron = $self->patron;
455
456     my $controlbranch = $patron->branchcode;
457
458     if ( C4::Context->preference('ReservesControlBranch') eq 'ItemHomeLibrary' ) {
459         $controlbranch = $item->homebranch;
460     }
461
462     return Koha::CirculationRules->get_effective_rule(
463         {
464             categorycode => $patron->categorycode,
465             itemtype     => $item->itype,
466             branchcode   => $controlbranch,
467             rule_name    => 'waiting_hold_cancellation',
468         }
469     )->rule_value ? 1 : 0;
470 }
471
472 =head3 is_at_destination
473
474 Returns true if hold is waiting
475 and the hold's pickup branch matches
476 the hold item's holding branch
477
478 =cut
479
480 sub is_at_destination {
481     my ($self) = @_;
482
483     return $self->is_waiting() && ( $self->branchcode() eq $self->item()->holdingbranch() );
484 }
485
486 =head3 biblio
487
488 Returns the related Koha::Biblio object for this hold
489
490 =cut
491
492 sub biblio {
493     my ($self) = @_;
494
495     $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() );
496
497     return $self->{_biblio};
498 }
499
500 =head3 patron
501
502 Returns the related Koha::Patron object for this hold
503
504 =cut
505
506 sub patron {
507     my ($self) = @_;
508
509     my $patron_rs = $self->_result->patron;
510     return Koha::Patron->_new_from_dbic($patron_rs);
511 }
512
513 =head3 item
514
515 Returns the related Koha::Item object for this Hold
516
517 =cut
518
519 sub item {
520     my ($self) = @_;
521
522     $self->{_item} ||= Koha::Items->find( $self->itemnumber() );
523
524     return $self->{_item};
525 }
526
527 =head3 branch
528
529 Returns the related Koha::Library object for this Hold
530
531 =cut
532
533 sub branch {
534     my ($self) = @_;
535
536     $self->{_branch} ||= Koha::Libraries->find( $self->branchcode() );
537
538     return $self->{_branch};
539 }
540
541 =head3 desk
542
543 Returns the related Koha::Desk object for this Hold
544
545 =cut
546
547 sub desk {
548     my $self = shift;
549     my $desk_rs = $self->_result->desk;
550     return unless $desk_rs;
551     return Koha::Desk->_new_from_dbic($desk_rs);
552 }
553
554 =head3 borrower
555
556 Returns the related Koha::Patron object for this Hold
557
558 =cut
559
560 # FIXME Should be renamed with ->patron
561 sub borrower {
562     my ($self) = @_;
563
564     $self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() );
565
566     return $self->{_borrower};
567 }
568
569 =head3 is_suspended
570
571 my $bool = $hold->is_suspended();
572
573 =cut
574
575 sub is_suspended {
576     my ( $self ) = @_;
577
578     return $self->suspend();
579 }
580
581 =head3 add_cancellation_request
582
583     my $cancellation_request = $hold->add_cancellation_request({ [ creation_date => $creation_date ] });
584
585 Adds a cancellation request to the hold. Returns the generated
586 I<Koha::Hold::CancellationRequest> object.
587
588 =cut
589
590 sub add_cancellation_request {
591     my ( $self, $params ) = @_;
592
593     my $request = Koha::Hold::CancellationRequest->new(
594         {   hold_id      => $self->id,
595             ( $params->{creation_date} ? ( creation_date => $params->{creation_date} ) : () ),
596         }
597     )->store;
598
599     $request->discard_changes;
600
601     return $request;
602 }
603
604 =head3 cancellation_requests
605
606     my $cancellation_requests = $hold->cancellation_requests;
607
608 Returns related a I<Koha::Hold::CancellationRequests> resultset.
609
610 =cut
611
612 sub cancellation_requests {
613     my ($self) = @_;
614
615     return Koha::Hold::CancellationRequests->search( { hold_id => $self->id } );
616 }
617
618 =head3 cancel
619
620 my $cancel_hold = $hold->cancel(
621     {
622         [ charge_cancel_fee   => 1||0, ]
623         [ cancellation_reason => $cancellation_reason, ]
624         [ skip_holds_queue    => 1||0 ]
625     }
626 );
627
628 Cancel a hold:
629 - The hold will be moved to the old_reserves table with a priority=0
630 - The priority of other holds will be updated
631 - The patron will be charge (see ExpireReservesMaxPickUpDelayCharge) if the charge_cancel_fee parameter is set
632 - The canceled hold will have the cancellation reason added to old_reserves.cancellation_reason if one is passed in
633 - a CANCEL HOLDS log will be done if the pref HoldsLog is on
634
635 =cut
636
637 sub cancel {
638     my ( $self, $params ) = @_;
639     $self->_result->result_source->schema->txn_do(
640         sub {
641             my $patron = $self->patron;
642
643             $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) );
644             $self->priority(0);
645             $self->cancellation_reason( $params->{cancellation_reason} );
646             $self->store();
647
648             if ( $params->{cancellation_reason} ) {
649                 my $letter = C4::Letters::GetPreparedLetter(
650                     module                 => 'reserves',
651                     letter_code            => 'HOLD_CANCELLATION',
652                     message_transport_type => 'email',
653                     branchcode             => $self->borrower->branchcode,
654                     lang                   => $self->borrower->lang,
655                     tables => {
656                         branches    => $self->borrower->branchcode,
657                         borrowers   => $self->borrowernumber,
658                         items       => $self->itemnumber,
659                         biblio      => $self->biblionumber,
660                         biblioitems => $self->biblionumber,
661                         reserves    => $self->unblessed,
662                     }
663                 );
664
665                 if ($letter) {
666                     C4::Letters::EnqueueLetter(
667                         {
668                             letter                   => $letter,
669                             borrowernumber         => $self->borrowernumber,
670                             message_transport_type => 'email',
671                         }
672                     );
673                 }
674             }
675
676             my $old_me = $self->_move_to_old;
677
678             Koha::Plugins->call(
679                 'after_hold_action',
680                 {
681                     action  => 'cancel',
682                     payload => { hold => $old_me->get_from_storage }
683                 }
684             );
685
686             # anonymize if required
687             $old_me->anonymize
688                 if $patron->privacy == 2;
689
690             $self->SUPER::delete(); # Do not add a DELETE log
691
692             # now fix the priority on the others....
693             C4::Reserves::_FixPriority({ biblionumber => $self->biblionumber });
694
695             # and, if desired, charge a cancel fee
696             my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
697             if ( $charge && $params->{'charge_cancel_fee'} ) {
698                 my $account =
699                   Koha::Account->new( { patron_id => $self->borrowernumber } );
700                 $account->add_debit(
701                     {
702                         amount     => $charge,
703                         user_id    => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
704                         interface  => C4::Context->interface,
705                         library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
706                         type       => 'RESERVE_EXPIRED',
707                         item_id    => $self->itemnumber
708                     }
709                 );
710             }
711
712             C4::Log::logaction( 'HOLDS', 'CANCEL', $self->reserve_id, $self )
713                 if C4::Context->preference('HoldsLog');
714
715             Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
716                 {
717                     biblio_ids => [ $old_me->biblionumber ]
718                 }
719             ) unless $params->{skip_holds_queue} or !C4::Context->preference('RealTimeHoldsQueue');
720         }
721     );
722     return $self;
723 }
724
725 =head3 fill
726
727     $hold->fill;
728
729 This method marks the hold as filled. It effectively moves it to old_reserves.
730
731 =cut
732
733 sub fill {
734     my ( $self ) = @_;
735     $self->_result->result_source->schema->txn_do(
736         sub {
737             my $patron = $self->patron;
738
739             $self->set(
740                 {
741                     found    => 'F',
742                     priority => 0,
743                 }
744             );
745
746             my $old_me = $self->_move_to_old;
747
748             Koha::Plugins->call(
749                 'after_hold_action',
750                 {
751                     action  => 'fill',
752                     payload => { hold => $old_me->get_from_storage }
753                 }
754             );
755
756             # anonymize if required
757             $old_me->anonymize
758                 if $patron->privacy == 2;
759
760             $self->SUPER::delete(); # Do not add a DELETE log
761
762             # now fix the priority on the others....
763             C4::Reserves::_FixPriority({ biblionumber => $self->biblionumber });
764
765             if ( C4::Context->preference('HoldFeeMode') eq 'any_time_is_collected' ) {
766                 my $fee = $patron->category->reservefee // 0;
767                 if ( $fee > 0 ) {
768                     $patron->account->add_debit(
769                         {
770                             amount       => $fee,
771                             description  => $self->biblio->title,
772                             user_id      => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
773                             library_id   => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
774                             interface    => C4::Context->interface,
775                             type         => 'RESERVE',
776                             item_id      => $self->itemnumber
777                         }
778                     );
779                 }
780             }
781
782             C4::Log::logaction( 'HOLDS', 'FILL', $self->id, $self )
783                 if C4::Context->preference('HoldsLog');
784
785             Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
786                 {
787                     biblio_ids => [ $old_me->biblionumber ]
788                 }
789             ) if C4::Context->preference('RealTimeHoldsQueue');
790         }
791     );
792     return $self;
793 }
794
795 =head3 store
796
797 Override base store method to set default
798 expirationdate for holds.
799
800 =cut
801
802 sub store {
803     my ($self) = @_;
804
805     Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode;
806
807     if ( !$self->in_storage ) {
808         if ( ! $self->expirationdate && $self->patron_expiration_date ) {
809             $self->expirationdate($self->patron_expiration_date);
810         }
811
812         if (
813             C4::Context->preference('DefaultHoldExpirationdate')
814                 && !$self->expirationdate
815           )
816         {
817             $self->_set_default_expirationdate;
818         }
819     }
820     else {
821
822         my %updated_columns = $self->_result->get_dirty_columns;
823         return $self->SUPER::store unless %updated_columns;
824
825         if ( exists $updated_columns{reservedate} ) {
826             if (
827                 C4::Context->preference('DefaultHoldExpirationdate')
828                 && ! exists $updated_columns{expirationdate}
829               )
830             {
831                 $self->_set_default_expirationdate;
832             }
833         }
834     }
835
836     $self = $self->SUPER::store;
837 }
838
839 sub _set_default_expirationdate {
840     my $self = shift;
841
842     my $period = C4::Context->preference('DefaultHoldExpirationdatePeriod') || 0;
843     my $timeunit =
844       C4::Context->preference('DefaultHoldExpirationdateUnitOfTime') || 'days';
845
846     $self->expirationdate(
847         dt_from_string( $self->reservedate )->add( $timeunit => $period ) );
848 }
849
850 =head3 _move_to_old
851
852 my $is_moved = $hold->_move_to_old;
853
854 Move a hold to the old_reserve table following the same pattern as Koha::Patron->move_to_deleted
855
856 =cut
857
858 sub _move_to_old {
859     my ($self) = @_;
860     my $hold_infos = $self->unblessed;
861     return Koha::Old::Hold->new( $hold_infos )->store;
862 }
863
864 =head3 to_api_mapping
865
866 This method returns the mapping for representing a Koha::Hold object
867 on the API.
868
869 =cut
870
871 sub to_api_mapping {
872     return {
873         reserve_id       => 'hold_id',
874         borrowernumber   => 'patron_id',
875         reservedate      => 'hold_date',
876         biblionumber     => 'biblio_id',
877         branchcode       => 'pickup_library_id',
878         notificationdate => undef,
879         reminderdate     => undef,
880         cancellationdate => 'cancellation_date',
881         reservenotes     => 'notes',
882         found            => 'status',
883         itemnumber       => 'item_id',
884         waitingdate      => 'waiting_date',
885         expirationdate   => 'expiration_date',
886         patron_expiration_date => undef,
887         lowestPriority   => 'lowest_priority',
888         suspend          => 'suspended',
889         suspend_until    => 'suspended_until',
890         itemtype         => 'item_type',
891         item_level_hold  => 'item_level',
892     };
893 }
894
895 =head2 Internal methods
896
897 =head3 _type
898
899 =cut
900
901 sub _type {
902     return 'Reserve';
903 }
904
905 =head1 AUTHORS
906
907 Kyle M Hall <kyle@bywatersolutions.com>
908 Jonathan Druart <jonathan.druart@bugs.koha-community.org>
909 Martin Renvoize <martin.renvoize@ptfs-europe.com>
910
911 =cut
912
913 1;