EDI: ensure lineitem 'state' matches cancel state
authorBill Erickson <berick@esilibrary.com>
Tue, 4 Dec 2012 15:00:26 +0000 (10:00 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 14 Jan 2013 22:10:31 +0000 (17:10 -0500)
When cancelling a lineitem becuase all linked copies are cancelled,
ensure that the lineitem state is set to "cancelled".

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm

index dbabd25..09b6ce2 100644 (file)
@@ -543,7 +543,10 @@ sub process_parsed_msg {
             $lids_cancelled += $cancel_count;
 
             # if ALL the items have the same cancel_reason, the LI gets it too
-            $li->cancel_reason($eg_reason->id) if $qty_count == $lid_count;
+            if ($qty_count == $lid_count) {
+                $li->cancel_reason($eg_reason->id);
+                $li->state("cancelled");
+            }
                 
             $li->edit_time('now'); 
             unless ($e->update_acq_lineitem($li)) {
@@ -604,8 +607,11 @@ sub process_parsed_msg {
 
                     # All LIDs cancelled with same reason, apply 
                     # the same cancel reason to the lineitem 
-                    $li->cancel_reason($reason->id) if $remaining_lids == $order_qty;
-                        
+                    if ($remaining_lids == $order_qty) {
+                        $li->cancel_reason($reason->id);
+                        $li->state("cancelled");
+                    }
+
                     $li->edit_time('now'); 
                     unless ($e->update_acq_lineitem($li)) {
                         $logger->error("EDI: update_acq_lineitem failed " . $e->die_event);