From 1f61a73d7feaea19651d79e8baa7390a1621417b Mon Sep 17 00:00:00 2001 From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Mon, 26 Apr 2010 19:18:17 +0000 Subject: [PATCH] in acq, when an LID is canceled, make sure the encumbrance is removed as well git-svn-id: svn://svn.open-ils.org/ILS/trunk@16311 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm index 53c6d5ec76..52b0b3e137 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm @@ -2634,9 +2634,25 @@ sub cancel_lineitem_detail { # TODO who/what/where/how do we indicate this change for electronic orders? + my $debit_id = $lid->fund_debit; + $lid->clear_fund_debit; + # XXX LIDs don't have either an editor or a edit_time field. Should we # update these on the LI when we alter an LID? $mgr->editor->update_acq_lineitem_detail($lid) or return 0; + + if($debit_id) { + # item is cancelled. Remove the fund debit. + my $debit = $mgr->editor->retrieve_acq_fund_debit($lid->fund_debit); + if (!$U->is_true($debit->encumbrance)) { + $mgr->editor->rollback; + return OpenILS::Event->new('ACQ_NOT_CANCELABLE', + note => "Debit is marked as paid: $debit_id"); + } + $mgr->editor->delete_acq_fund_debit($debit) or return $mgr->editor->die_event; + $lid->clear_fund_debit; + } + return {"lid" => {$lid_id => {"cancel_reason" => $cancel_reason}}}; } -- 2.11.0