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=ae9f8cb239be42d3b3efb870ef449eda8a998fbd;p=evergreen%2Fpines.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 Signed-off-by: Kathy Lussier --- 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 69be3d71e5..d3a106ebe2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -1180,8 +1180,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) = @_; @@ -1194,6 +1194,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); }