LP#1257915 - Also check whether to mark the PO received when canceling.
authorChris Sharp <csharp@georgialibraries.org>
Fri, 7 Apr 2017 12:45:06 +0000 (08:45 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 1 May 2017 20:32:09 +0000 (16:32 -0400)
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm

index 58a6550..07aab00 100644 (file)
@@ -1199,9 +1199,9 @@ sub check_purchase_order_received {
                "jub" => {"acqcr" => {"type" => "left"}}
        },
        "where" =>{
-               "+jub" => {"id" => $po_id},
+               "+jub" => {"purchase_order" => $po_id},
                "-or" => [
-               {"+jub" => {"state" => "received"}},
+               {"+jub" => {"state" => {"!=" => "received"}}},
                {"+acqcr" => {"keep_debits" =>"t"}}
                ]
        }
@@ -3229,7 +3229,7 @@ sub cancel_lineitem {
             }
         }
     }
-
     update_lineitem($mgr, $li) or return 0;
     $result->{"li"} = {
         $li_id => {
@@ -3237,6 +3237,12 @@ sub cancel_lineitem {
             "cancel_reason" => $cancel_reason
         }
     };
+
+    # check to see if this cancelation should result in
+    # marking the purchase order "received"
+    my $po;
+    return 0 unless check_purchase_order_received($mgr, $li->purchase_order->id);
+
     return $result;
 }