From 1c51477776415bb959c73f7387d3f65fde2ffae9 Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 1 Apr 2010 05:15:19 +0000 Subject: [PATCH] don't make the call to open-ils.cat if there are no real copies to delete. I'm assuming we want to be able to call this method against lineitems that might not even be associated with a purchase order, much less have copies, etc. Need to think about that permission check at the beginning which is using purchase order -> ordering agency as a context org From my open-ils.acq.lineitem.cancel branch git-svn-id: svn://svn.open-ils.org/ILS/trunk@16080 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Acq/Order.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm index 2cbf412c5..696e725e2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm @@ -2456,15 +2456,17 @@ sub cancel_lineitem { } # attempt to delete the gathered copies (this will also handle volume deletion, bib deletion, and attempt hold retargeting) - my $cat_service = OpenSRF::AppSession->create('open-ils.cat'); - $cat_service->connect; - my $cat_req = $cat_service->request('open-ils.cat.asset.copy.fleshed.batch.update', $mgr->editor->authtoken, $copies); - my $cat_result = $cat_req->recv; - $cat_service->disconnect; - if (!$cat_result or $cat_result->content != 1) { # failed to delete copies - return new OpenILS::Event( - "ACQ_NOT_CANCELABLE", "note" => "lineitem $li_id", "payload" => $cat_result - ); + if (scalar(@$copies)>0) { + my $cat_service = OpenSRF::AppSession->create('open-ils.cat'); + $cat_service->connect; + my $cat_req = $cat_service->request('open-ils.cat.asset.copy.fleshed.batch.update', $mgr->editor->authtoken, $copies); + my $cat_result = $cat_req->recv; + $cat_service->disconnect; + if (!$cat_result or $cat_result->content != 1) { # failed to delete copies + return new OpenILS::Event( + "ACQ_NOT_CANCELABLE", "note" => "lineitem $li_id", "payload" => $cat_result + ); + } } # TODO delete the associated fund debits? -- 2.11.0