From: Bill Erickson Date: Tue, 18 Aug 2015 18:34:16 +0000 (-0400) Subject: LP#1440114 PO stays open with active blanket charges X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b353b1a739f793a26632229d541ec247a12d51ab;p=working%2FEvergreen.git LP#1440114 PO stays open with active blanket charges When marking the final lineitem on a PO as received, a PO will remain open (on-order) if blanket charges which are still encumbered link to the PO. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index 4dec15d7bd..a15a28ee1e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -1164,8 +1164,8 @@ sub create_purchase_order { } # ---------------------------------------------------------------------------- -# if all of the lineitems for this PO are received, -# mark the PO as received +# if all of the lineitems for this PO are received and no +# blanket charges are still encumbered, mark the PO as received. # ---------------------------------------------------------------------------- sub check_purchase_order_received { my($mgr, $po_id) = @_; @@ -1178,6 +1178,21 @@ sub check_purchase_order_received { my $po = $mgr->editor->retrieve_acq_purchase_order($po_id); return $po if @$non_recv_li; + # avoid marking the PO as received if any blanket charges + # are still encumbered. + my $blankets = $mgr->editor->json_query({ + select => {acqpoi => ['id']}, + from => { + acqpoi => { + aiit => {filter => {blanket=>'t'}}, + acqfdeb => {filter => {encumbrance => 't'}} + } + }, + where => {'+acqpoi' => {purchase_order => $po_id}} + }); + + return $po if @$blankets; + $po->state('received'); return update_purchase_order($mgr, $po); }