Delete ILL copies as well as ILL call numbers
authorDan Scott <dscott@laurentian.ca>
Mon, 12 Nov 2012 17:58:42 +0000 (12:58 -0500)
committerDan Scott <dscott@laurentian.ca>
Tue, 7 May 2013 18:58:18 +0000 (14:58 -0400)
Evergreen 2.3 likes to show available copies in the holdings maintenance
window even if the parent call numbers are deleted. So, do what we
should have done before and delete the copies too.

Guard against deleting copies that have been renewed rather than having
their due dates extended.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/daily-scripts/delete_ill_books.pl

index f230433..28187e6 100644 (file)
@@ -58,6 +58,7 @@ sub delete_racer_callnumbers {
                        SELECT id 
                        FROM money.open_billable_xact_summary
                ) AND acn.deleted IS FALSE
+               AND ac.status NOT IN (1, 7);
 
 SELECT
 
@@ -84,8 +85,20 @@ SELECT
                        SELECT id 
                        FROM money.open_billable_xact_summary
                ) AND acn.deleted IS FALSE
+               AND ac.status NOT IN (1, 7);
 DELETE
 
+    my $delete_copies_stmt = <<DELETECOPIES;
+    UPDATE asset.copy
+      SET deleted = TRUE FROM asset.call_number acn
+      WHERE asset.copy.call_number = acn.id
+        AND acn.record IN (2237519,2239801,2239798,2239797,2239799,2239800,2247576)
+        AND acn.deleted IS TRUE
+        AND asset.copy.deleted IS FALSE
+        AND asset.copy.circ_lib = 103
+        AND asset.copy.status NOT IN (1, 7);
+DELETECOPIES
+
        my $results = $dbh->selectcol_arrayref($select_stmt);
        print localtime() . " - found " . scalar(@$results) . " RACER book call numbers to delete:\n";
        if (scalar(@$results)) {
@@ -94,6 +107,8 @@ DELETE
                }
                my $stmt = $dbh->prepare($delete_stmt);
                my $updates = $stmt->execute();
+               $stmt = $dbh->prepare($delete_copies_stmt);
+               $updates = $stmt->execute();
        }
 }