Acq: (un)receive w/o assets should not attempt a copy update
authorBill Erickson <berick@esilibrary.com>
Fri, 23 Sep 2011 21:45:39 +0000 (17:45 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 15 Nov 2011 20:14:08 +0000 (15:14 -0500)
When receiveing a lineitem for a PO that was activated without assets,
avoid any attempts to update said non-existent assets.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm

index 8e478ca..1b1aff3 100644 (file)
@@ -523,13 +523,15 @@ sub receive_lineitem_detail {
     $lid->recv_time('now');
     $e->update_acq_lineitem_detail($lid) or return 0;
 
-    my $copy = $e->retrieve_asset_copy($lid->eg_copy_id) or return 0;
-    $copy->status(OILS_COPY_STATUS_IN_PROCESS);
-    $copy->edit_date('now');
-    $copy->editor($e->requestor->id);
-    $copy->creator($e->requestor->id) if $U->ou_ancestor_setting_value(
-        $e->requestor->ws_ou, 'acq.copy_creator_uses_receiver', $e);
-    $e->update_asset_copy($copy) or return 0;
+    if ($lid->eg_copy_id) {
+        my $copy = $e->retrieve_asset_copy($lid->eg_copy_id) or return 0;
+        $copy->status(OILS_COPY_STATUS_IN_PROCESS);
+        $copy->edit_date('now');
+        $copy->editor($e->requestor->id);
+        $copy->creator($e->requestor->id) if $U->ou_ancestor_setting_value(
+            $e->requestor->ws_ou, 'acq.copy_creator_uses_receiver', $e);
+        $e->update_asset_copy($copy) or return 0;
+    }
 
     $mgr->add_lid;
 
@@ -561,11 +563,13 @@ sub rollback_receive_lineitem_detail {
     $lid->clear_recv_time;
     $e->update_acq_lineitem_detail($lid) or return 0;
 
-    my $copy = $e->retrieve_asset_copy($lid->eg_copy_id) or return 0;
-    $copy->status(OILS_COPY_STATUS_ON_ORDER);
-    $copy->edit_date('now');
-    $copy->editor($e->requestor->id);
-    $e->update_asset_copy($copy) or return 0;
+    if ($lid->eg_copy_id) {
+        my $copy = $e->retrieve_asset_copy($lid->eg_copy_id) or return 0;
+        $copy->status(OILS_COPY_STATUS_ON_ORDER);
+        $copy->edit_date('now');
+        $copy->editor($e->requestor->id);
+        $e->update_asset_copy($copy) or return 0;
+    }
 
     $mgr->add_lid;
     return $lid;