my $billids = $e->search_money_billing([$bill_search, {idlist=>1}]);
if ($billids && @$billids) {
- my $result = $class->real_void_bills($e->authtoken, $billids, $note);
+ my $result = $class->real_void_bills($e, $billids, $note);
if (ref($result)) {
return $result;
}
);
if ($bills && @$bills) {
- my $result = $class->real_void_bills($e->authtoken, $bills, $note);
+ my $result = $class->real_void_bills($e, $bills, $note);
if (ref($result)) {
return $result;
}
return undef;
}
-# ------------------------------------------------------------------
-# "Unvoids" a given bill. Basically, we create a new bill equal to
-# the amount voided on the original bill.
-#
-# Takes an authtoken, the bill object whose voids you want to undo, and
-# an optional note.
-#
-# Returns undef on success or an event on failure.
-# ------------------------------------------------------------------
-sub unvoid_bill {
- my ($class, $authtoken, $bill, $note) = @_;
-
- # Get and editor, check for a session, and check that we can void
- # bills. (If we can void bills, we can unvoid them, too.)
- my $e = new_editor (authtoken => $authtoken, xact => 1);
- return $e->die_event unless $e->checkauth;
- return $e->die_event unless $e->allowed('VOID_BILLING');
-
- my $voids = $e->search_money_void_payment(
- {
- billing => $bill->id()
- }
- );
-
- if ($voids && @$voids) {
- my $void_total = 0;
- map {$void_total += $_->amount()} @$voids;
- my $result = $class->create_bill($e, $void_total, $bill->btype(), $bill->billing_type(), $bill->xact(), $note);
- if ($result) {
- $e->rollback();
- return $result;
- }
- $e->commit;
- }
-
- return undef;
-}
-
sub reopen_xact {
my($class, $e, $xactid) = @_;
}
-# This subroutine actually handles voiding of bills. It takes an
-# authtoken, an arrayref of bill ids or bills, and an optional note.
+# This subroutine actually handles voiding of bills. It takes a
+# CStoreEditor, an arrayref of bill ids or bills, and an optional note.
sub real_void_bills {
- my ($class, $authtoken, $billids, $note) = @_;
+ my ($class, $e, $billids, $note) = @_;
- # Get an editor and see if we have permission to void bills.
- my $e = new_editor( authtoken => $authtoken, xact => 1 );
+ # Get with the editor to see if we have permission to void bills.
return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('VOID_BILLING');
# made it impossible to void an already voided bill, so
# we're doing the same.
if ($amount_to_void <= 0) {
- $e->rollback;
return OpenILS::Event->new('BILL_ALREADY_VOIDED', payload => $bill);
}
OpenILS::Utils::Penalty->calculate_penalties($e, $user_id, $org_id);
}
}
- $e->commit;
+
return 1;
}