Bug Fix: Clear empty objects from original callnumber
authorBill Erickson <berick@esilibrary.com>
Mon, 20 Jun 2011 15:17:29 +0000 (11:17 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 20 Jun 2011 15:17:29 +0000 (11:17 -0400)
When updating the callnumber on a copy, make sure we fetch the original
callnumber to test for emptiness and cleanup, instead of trying to clean
up the newly assigned callnumber (which will never be "empty").

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm

index 047338c..11ecdfc 100644 (file)
@@ -200,7 +200,10 @@ sub update_copy {
 
        $logger->info("vol-update: updating copy ".$copy->id);
        my $orig_copy = $editor->retrieve_asset_copy($copy->id);
-       my $orig_vol  = $editor->retrieve_asset_call_number($copy->call_number);
+
+    # Call-number may have changed, find the original
+    my $orig_vol_id = $editor->json_query({select => {acp => ['call_number']}, from => 'acp', where => {id => $copy->id}});
+    my $orig_vol  = $editor->retrieve_asset_call_number($orig_vol_id->[0]->{call_number});
 
        $copy->editor($editor->requestor->id);
        $copy->edit_date('now');