[open-ils-commits] r16311 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 26 15:18:22 EDT 2010


Author: erickson
Date: 2010-04-26 15:18:17 -0400 (Mon, 26 Apr 2010)
New Revision: 16311

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
Log:
in acq, when an LID is canceled, make sure the encumbrance is removed as well

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm	2010-04-26 18:32:39 UTC (rev 16310)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm	2010-04-26 19:18:17 UTC (rev 16311)
@@ -2634,9 +2634,25 @@
 
     # 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}}};
 }
 



More information about the open-ils-commits mailing list