return $sum;
}
+__PACKAGE__->register_method(
+ method => 'zeroize_transaction',
+ api_name => 'open-ils.circ.money.zeroize_transaction',
+ stream => 1,
+ authoritative => 1,
+ signature => {
+ desc => q/
+ Given a negative-balance transaction, juggles the void
+ payment(s) to produce a zero-balance transaction, without
+ affecting any of the billings or real patron payments.
+ /,
+ params => [
+ {desc => 'Authtoken', type => 'string'},
+ {desc => 'Array of transaction IDs', type => 'array'}
+ ],
+ return {
+ desc => q/A stream of transaction summaries, one for
+ each transaction updated. On error, the final item
+ in the stream will be an Event./
+ }
+ }
+);
+
+sub zeroize_transaction {
+ my ($self, $client, $auth, $xact_ids) = @_;
+ my $e = new_editor(xact => 1, authtoken => $auth);
+ return $e->event unless $e->checkauth;
+
+ # in case a bare ID is passed
+ $xact_ids = [$xact_ids] unless ref $xact_ids;
+
+ for my $xact_id (@$xact_ids) {
+ my $xact =
+ $e->retrieve_money_billable_transaction_summary([
+ $xact_id,
+ {flesh => 1, flesh_fields => {mbts => ['usr']}}
+ ]) or return $e->die_event;
+
+ # we are only concerned with negative-balance transactions
+ next if $xact->balance_owed >= 0;
+
+ return $e->die_event unless
+ $e->allowed('CREATE_PAYMENT', $xact->usr->home_ou);
+
+ # TODO: do the void payment juggling
+ #my $new_amount = $U->fpdiff($bill->amount(),$void->amount());
+ }
+
+ return;
+}
+
1;