From 4b472cb269ddd85fc395a3e0d62583a9c1da9401 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 20 Aug 2013 09:33:49 -0400 Subject: [PATCH] LP#1206649 un-cancel received lineitems / copies Clear the cancel reason when a canceled lineitem is marked as received. With items, clear the cancel reason and re-generate fund debits if they were removed during cancelation (because the keep_debits flag in the cancel reason was set to false). Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../src/perlmods/lib/OpenILS/Application/Acq/Order.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 c8ca798f9e..eac934baca 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -601,6 +601,8 @@ sub receive_lineitem { return 0 unless $li->state eq 'on-order' or $li->state eq 'cancelled'; # sic + $li->clear_cancel_reason; # un-cancel on receive + my $lid_ids = $mgr->editor->search_acq_lineitem_detail( {lineitem => $li_id, recv_time => undef}, {idlist => 1}); @@ -728,6 +730,19 @@ sub receive_lineitem_detail { return 1 if $lid->recv_time; + # if the LID is marked as canceled, remove the cancel reason, + # and reinstate fund debits where deleted by cancelation. + if ($lid->cancel_reason) { + my $cr = $e->retrieve_acq_cancel_reason($lid->cancel_reason); + + if (!$U->is_true($cr->keep_debits)) { + # debits were removed during cancelation. + create_lineitem_detail_debit( + $mgr, $lid->lineitem, $lid) or return 0; + } + $lid->clear_cancel_reason; + } + $lid->receiver($e->requestor->id); $lid->recv_time('now'); $e->update_acq_lineitem_detail($lid) or return 0; -- 2.11.0