LP#1257915 - Mark POs received when all lineitems are received or canceled.
authorChris Sharp <csharp@georgialibraries.org>
Wed, 5 Apr 2017 13:52:50 +0000 (09:52 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 1 May 2017 20:32:07 +0000 (16:32 -0400)
Previously, Evergreen only considered lineitems not in a "received" status
when deciding whether to consider a purchase order to be "received".  Now
items with cancel reasons that do not keep debits (e.g. not backordered)
are considered "done".

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 2a64bdf..58a6550 100644 (file)
@@ -1191,10 +1191,21 @@ sub create_purchase_order {
 sub check_purchase_order_received {
     my($mgr, $po_id) = @_;
 
-    my $non_recv_li = $mgr->editor->search_acq_lineitem(
-        {   purchase_order => $po_id,
-            state => {'!=' => 'received'}
-        }, {idlist=>1});
+       my $non_recv_li = $mgr->editor->json_query({
+               "select" =>{
+               "jub" =>["id"]
+       },
+       "from" =>{
+               "jub" => {"acqcr" => {"type" => "left"}}
+       },
+       "where" =>{
+               "+jub" => {"id" => $po_id},
+               "-or" => [
+               {"+jub" => {"state" => "received"}},
+               {"+acqcr" => {"keep_debits" =>"t"}}
+               ]
+       }
+       });
 
     my $po = $mgr->editor->retrieve_acq_purchase_order($po_id);
     return $po if @$non_recv_li;