From: Chris Sharp Date: Wed, 8 Nov 2017 19:08:43 +0000 (-0500) Subject: LP#1269574 - make EDI also cancel acq-created copies X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8365964d790070843308c171b9bf1d8b7aa9b965;p=evergreen%2Fpines.git LP#1269574 - make EDI also cancel acq-created copies Before this change, acquisitions EDI did not attempt to delete "real" copies attached to lineitem details. We check for copies and delete them. Signed-off-by: Chris Sharp --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm index 49feb96098..ac59562e60 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm @@ -17,6 +17,7 @@ use OpenILS::Utils::CStoreEditor q/new_editor/; use OpenILS::Utils::Fieldmapper; use OpenILS::Application::Acq::EDI::Translator; use OpenILS::Application::AppUtils; +use OpenILS::Application::Cat::AssetCommon; my $U = 'OpenILS::Application::AppUtils'; use OpenILS::Utils::EDIReader; @@ -879,6 +880,22 @@ sub cancel_lids { } } + # we also need to delete any real copies attached + my $copy = $e->retrieve_asset_copy([ + $lid->eg_copy_id, + {flesh => 1, flesh_fields => {acp => ['call_number']}} + ]); + if ($copy) { + $logger->info("EDI: deleting copy $copy->id and volume $copy->call_number for lid $lid->id"); + my $evt = OpenILS::Application::Cat::AssetCommon->delete_copy($e, 1, $copy->call_number, $copy, 1, 1); + if ($evt) { + $e->rollback; + $logger->error("EDI: failed to delete copies for lid $lid->id: $evt"); + } + } else { + $logger->debug("EDI: no copies or volumes to delete for lid $lid->id"); + } + $e->update_acq_lineitem_detail($lid); $cancel_count++; }