From 305f63cb721f975762bbcde1025f62bc5168cc67 Mon Sep 17 00:00:00 2001
From: Bill Erickson <berick@esilibrary.com>
Date: Fri, 4 May 2012 09:18:10 -0400
Subject: [PATCH] Check if transaction needs closing after adding billings

This addresses the issue where issuing refunds results in a negative
ballance and it is then impossible to close the transaction by creating
new billings.

https://bugs.launchpad.net/evergreen/+bug/758982

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
---
 Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
index b8cc5730b3..f8c276d28a 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
@@ -703,6 +703,10 @@ sub billing_items_create {
     $e->create_money_billing($billing) or return $e->die_event;
     my $evt = OpenILS::Utils::Penalty->calculate_penalties($e, $xact->usr, $U->xact_org($xact->id,$e));
     return $evt if $evt;
+
+    $evt = _check_open_xact($e, $xact->id, $xact);
+    return $evt if $evt;
+
     $e->commit;
 
     return $billing->id;
-- 
2.11.0