From de40cb6bfbf2c41a1e287ec143c81576ed3edde8 Mon Sep 17 00:00:00 2001
From: James Fournie <jfournie@sitka.bclibraries.ca>
Date: Wed, 7 Dec 2011 11:27:45 -0800
Subject: [PATCH] Acq fix for LP#901378

Proratable invoice charges do not have a fund_debit, we need to check for
this before attempting to delete the charge.  If there's no fund_debit
we can generally assume that there's no corresponding debit to this charge
and skip trying to delete it.

Signed-off-by: James Fournie <jfournie@sitka.bclibraries.ca>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
---
 Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm
index 305bd077e3..9d59b6accc 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm
@@ -133,7 +133,7 @@ sub build_invoice_api {
                     my $debit = $e->retrieve_acq_fund_debit($item->fund_debit);
                     $debit->encumbrance('t');
                     $e->update_acq_fund_debit($debit) or return $e->die_event;
-                } else {
+                } elsif($item->fund_debit) {
                     $e->delete_acq_fund_debit($e->retrieve_acq_fund_debit($item->fund_debit))
                         or return $e->die_event;
                 }
-- 
2.11.0