From ccc04446c96a4c5e63ec4d95b238cdaa056fe00e Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Fri, 4 Nov 2016 13:49:50 -0400 Subject: [PATCH] LP#978095 - Mark lineitem received when lineitem details are received or canceled. Signed-off-by: Chris Sharp --- .../perlmods/lib/OpenILS/Application/Acq/Order.pm | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) 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 3eae8602e3..295ebda177 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -601,9 +601,32 @@ sub describe_affected_po { sub check_lineitem_received { my($mgr, $li_id) = @_; - - my $non_recv = $mgr->editor->search_acq_lineitem_detail( - {recv_time => undef, lineitem => $li_id}, {idlist=>1}); + # we account for cancel_reasons with keep_debits = false + # here to make sure the lineitem gets marked "received" + # when, say, all but one are received and the last is + # canceled + my $non_recv = $mgr->editor->json_query({ + select => {acqlid => ['id']}, + from => { + jub => { + acqlid => { + join => { + acqcr => { + type => 'left' + } + } + } + } + }, + where => { + '-or' => [ + {'+acqlid' => {cancel_reason => undef}}, + {'+acqcr' => {keep_debits => 't'}} + ], + '+jub' => {id => $li_id} + }, + limit => 1 + }); return 1 if @$non_recv; -- 2.11.0