|
Lines 18-23
package Koha::Acquisition::Order;
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Carp qw( croak ); |
20 |
use Carp qw( croak ); |
|
|
21 |
use Try::Tiny; |
| 22 |
|
| 23 |
use C4::Biblio qw(DelBiblio); |
| 21 |
|
24 |
|
| 22 |
use Koha::Acquisition::Baskets; |
25 |
use Koha::Acquisition::Baskets; |
| 23 |
use Koha::Acquisition::Funds; |
26 |
use Koha::Acquisition::Funds; |
|
Lines 25-30
use Koha::Acquisition::Invoices;
Link Here
|
| 25 |
use Koha::Acquisition::Order::Claims; |
28 |
use Koha::Acquisition::Order::Claims; |
| 26 |
use Koha::Database; |
29 |
use Koha::Database; |
| 27 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
30 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
|
|
31 |
use Koha::Exceptions::Object; |
| 28 |
use Koha::Biblios; |
32 |
use Koha::Biblios; |
| 29 |
use Koha::Holds; |
33 |
use Koha::Holds; |
| 30 |
use Koha::Items; |
34 |
use Koha::Items; |
|
Lines 97-102
sub store {
Link Here
|
| 97 |
return $self; |
101 |
return $self; |
| 98 |
} |
102 |
} |
| 99 |
|
103 |
|
|
|
104 |
=head3 cancel |
| 105 |
|
| 106 |
$order->cancel({ [ reason => $reason ] }); |
| 107 |
|
| 108 |
This method marks an order as cancelled. As the order is cancelled, the (eventual) items |
| 109 |
attached to it are removed if possible. All happens inside a transaction which is rolled back |
| 110 |
if either fails. |
| 111 |
|
| 112 |
=cut |
| 113 |
|
| 114 |
sub cancel { |
| 115 |
my ($self, $params) = @_; |
| 116 |
|
| 117 |
my $reason = $params->{reason}; |
| 118 |
|
| 119 |
try { |
| 120 |
$self->_result->result_source->schema->txn_do( |
| 121 |
sub { |
| 122 |
# Delete the related items |
| 123 |
$self->items->safe_delete; |
| 124 |
|
| 125 |
# Update order status |
| 126 |
$self->set( |
| 127 |
{ |
| 128 |
cancellationreason => $reason, |
| 129 |
datecancellationprinted => \'NOW()', |
| 130 |
orderstatus => 'cancelled', |
| 131 |
} |
| 132 |
)->store; |
| 133 |
} |
| 134 |
); |
| 135 |
} |
| 136 |
catch { |
| 137 |
$_->rethrow; |
| 138 |
}; |
| 139 |
|
| 140 |
return $self; |
| 141 |
} |
| 142 |
|
| 100 |
=head3 add_item |
143 |
=head3 add_item |
| 101 |
|
144 |
|
| 102 |
$order->add_item( $itemnumber ); |
145 |
$order->add_item( $itemnumber ); |
| 103 |
- |
|
|