When doing a re-bill, we were aborting too early when it rebilled to
exactly zero. Move the 'zero' check to the top of the loop, and
thereby make sure we check if the xact can be closed if we do any
adjustment, up or down.
To test:
- Run new billing test from previous commit, see it fail
- Apply patch
- Run tests again; all should pass
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
{flesh => 1, flesh_fields => {mbts => ['usr']}}
]) or return $e->die_event;
{flesh => 1, flesh_fields => {mbts => ['usr']}}
]) or return $e->die_event;
+ if ($xact->balance_owed == 0) {
+ # zero already, all done
+ next;
+ }
+
return $e->die_event unless
$e->allowed('ADJUST_BILLS', $xact->usr->home_ou);
return $e->die_event unless
$e->allowed('ADJUST_BILLS', $xact->usr->home_ou);
]) or return $e->die_event;
}
]) or return $e->die_event;
}
- my $billings = $e->search_money_billing([
- {
- xact => $xact_id,
- },
- {
- order_by => {mb => 'amount desc'},
- flesh => 1,
- flesh_fields => {mb => ['adjustments']},
- }
- ]);
-
- if ($xact->balance_owed == 0) {
- # if was zero, or we rebilled it to zero
- next;
- } else {
+ if ($xact->balance_owed > 0) {
# it's positive and needs to be adjusted
# it's positive and needs to be adjusted
+ # (it either started positive, or we rebilled it positive)
+ my $billings = $e->search_money_billing([
+ {
+ xact => $xact_id,
+ },
+ {
+ order_by => {mb => 'amount desc'},
+ flesh => 1,
+ flesh_fields => {mb => ['adjustments']},
+ }
+ ]);
+
my @billings_to_zero = grep { !$U->is_true($_->voided) or !_is_fully_adjusted($_) } @$billings;
$CC->adjust_bills_to_zero($e, \@billings_to_zero, "System: MANUAL ADJUSTMENT");
}
my @billings_to_zero = grep { !$U->is_true($_->voided) or !_is_fully_adjusted($_) } @$billings;
$CC->adjust_bills_to_zero($e, \@billings_to_zero, "System: MANUAL ADJUSTMENT");
}