]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Hold.pm
Revert "LP#1635737 Use new OpenSRF interval_to_seconds() context"
[working/Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / SIP / Transaction / Hold.pm
1 package OpenILS::SIP::Transaction::Hold;
2 use warnings; use strict;
3
4 use Sys::Syslog qw(syslog);
5 use OpenILS::SIP;
6 use OpenILS::SIP::Transaction;
7 use OpenILS::Application::AppUtils;
8 my $U = 'OpenILS::Application::AppUtils';
9
10 our @ISA = qw(OpenILS::SIP::Transaction);
11
12 my %fields = (
13     cancel_ok => 0,
14     hold => undef
15 );
16
17 sub new {
18     my $class = shift;;
19     my $self = $class->SUPER::new(@_);
20
21     $self->{_permitted}->{$_} = $fields{$_} for keys %fields;
22     @{$self}{keys %fields} = values %fields;
23
24     return bless $self, $class;
25 }
26
27 sub do_hold_cancel {
28     my $self = shift;
29     my $sip  = shift;
30
31     my $resp = $U->simplereq(
32         'open-ils.circ',
33         'open-ils.circ.hold.cancel', $self->{authtoken},
34         $self->hold->id, 7 # cancel via SIP
35     );
36
37     if( my $code = $U->event_code($resp) ) {
38         syslog('LOG_INFO', "OILS: Hold cancel failed with event $code : " . $resp->{textcode});
39         $self->cancel_ok(0);
40         $self->ok(0);
41         return $self;
42     }
43
44     syslog('LOG_INFO', "OILS: Hold cancellation succeeded for hold " . $self->hold->id);
45
46     $self->cancel_ok(1);
47     $self->ok(1);
48
49     $self->item($sip->find_item($self->hold->current_copy->barcode))
50         if $self->hold->current_copy;
51
52     return $self;
53 }
54
55 sub queue_position {
56     # cancelled holds have no queue position
57     return undef;
58 }
59
60 sub pickup_location {
61     # cancelled holds have no pickup location
62     return undef;
63 }
64
65 sub expiration_date {
66     # cancelled holds have no pickup location
67     return undef;
68 }
69
70
71
72
73 1;