Bug 42789: EDI ORDRSP cancellation should use Koha::Acquisition::Order->cancel()
The process_ordrsp() function was calling C4::Acquisition::ModOrder() directly when processing a supplier cancellation, which only updated the order status fields and left associated items and purchase suggestions untouched. Replace with Koha::Acquisition::Order->cancel(), which mirrors the behaviour of manual cancellation via the acquisitions UI: - Deletes on-order items via safe_delete() with error capture - Reverts any linked purchase suggestion from ORDERED back to ACCEPTED - Updates orderstatus, cancellationreason and datecancellationprinted The delete_biblio option is intentionally omitted (defaults to false) as silent biblio deletion is not appropriate for an automated EDI flow. ModOrder is retained for the non-cancellation branch which only needs to update suppliers_report. Sponsored-by: OpenFifth <https://openfifth.co.uk/> Signed-off-by: Sharon Dugdale <sharon.dugdale@cumberland.gov.uk> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
1031a1ba73
commit
6c55a4e7d4
15
Koha/EDI.pm
15
Koha/EDI.pm
|
|
@ -54,6 +54,7 @@ use Koha::Plugins; # Adds plugin dirs to @INC
|
|||
use Koha::Plugins::Handler;
|
||||
use Koha::Acquisition::Baskets;
|
||||
use Koha::Acquisition::Booksellers;
|
||||
use Koha::Acquisition::Orders;
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::Util::FrameworkPlugin qw( biblio_008 );
|
||||
|
||||
|
|
@ -216,14 +217,12 @@ sub process_ordrsp {
|
|||
my $action = $line->action_notification();
|
||||
if ( $action eq 'cancelled' ) {
|
||||
my $reason = $line->coded_orderline_text();
|
||||
ModOrder(
|
||||
{
|
||||
ordernumber => $ordernumber,
|
||||
cancellationreason => $reason,
|
||||
orderstatus => 'cancelled',
|
||||
datecancellationprinted => dt_from_string()->ymd(),
|
||||
}
|
||||
);
|
||||
my $order = Koha::Acquisition::Orders->find($ordernumber);
|
||||
if ($order) {
|
||||
$order->cancel( { reason => $reason } );
|
||||
} else {
|
||||
$logger->error("EDI ORDRSP: ordernumber $ordernumber not found, cannot process cancellation");
|
||||
}
|
||||
} else { # record order as due with possible further info
|
||||
|
||||
my $report = $line->coded_orderline_text();
|
||||
|
|
|
|||
Loading…
Reference in New Issue