Add void_bills_of_type method to CircCommon.pm.
authorJason Stephenson <jason@sigio.com>
Sun, 6 Oct 2013 14:22:57 +0000 (10:22 -0400)
committerJason Stephenson <jason@sigio.com>
Thu, 7 Nov 2013 22:00:56 +0000 (17:00 -0500)
A handly little subroutine to void all bills of a given type on a
circulation transaction.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm

index 86b0103..a00a4a3 100644 (file)
@@ -68,6 +68,33 @@ sub void_overdues {
     return undef;
 }
 
+# ------------------------------------------------------------------
+# Void all bills of a given type on a circulation.
+#
+# Takes an editor, a circ object, the btype number for the bills you
+# want to void, and an optional note.
+#
+# Returns undef on success or the result from real_void_bills.
+# ------------------------------------------------------------------
+sub void_bills_of_type {
+    my ($class, $e, $circ, $btype, $note) = @_;
+
+    my $bills = $e->search_money_billing(
+        {
+            xact => $circ->id,
+            btype => $btype
+        }
+    );
+
+    if ($bills && @$bills) {
+        my $result = $class->real_void_bills($e->authtoken, $bills, $note);
+        if (ref($result)) {
+            return $result;
+        }
+    }
+
+    return undef;
+}
 
 sub reopen_xact {
     my($class, $e, $xactid) = @_;