Bug 42789: (QA follow-up) Log item deletion failures during EDI cancellation

This patch logs any object messages returned by cancel() to the EDI log,
including the itemnumber if available.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Kyle M Hall 2026-06-26 11:08:24 -04:00 committed by Pedro Amorim
parent 45a60d487c
commit 220b09c4e0
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 14 additions and 0 deletions

View File

@ -220,6 +220,20 @@ sub process_ordrsp {
my $order = Koha::Acquisition::Orders->find($ordernumber);
if ($order) {
$order->cancel( { reason => $reason } );
# cancel() records item deletion failures ( e.g. an item still has holds )
# as object messages instead of dying; log any such messages so they are
# not lost in the automated flow
for my $message ( @{ $order->object_messages } ) {
my $item = $message->payload->{item};
$logger->warn(
sprintf(
'EDI ORDRSP: order %s cancellation issue: %s%s',
$ordernumber, $message->message,
$item ? ' for itemnumber ' . $item->itemnumber : q{}
)
);
}
} else {
$logger->error("EDI ORDRSP: ordernumber $ordernumber not found, cannot process cancellation");
}