LP 1198465: Account for overdues voided the old way
authorRemington Steed <rjs7@calvin.edu>
Wed, 18 Jun 2014 13:34:13 +0000 (09:34 -0400)
committerDan Wells <dbw2@calvin.edu>
Mon, 8 Dec 2014 14:38:35 +0000 (09:38 -0500)
The code for the particular case of "void"-overdues-for-lost is incomplete.
This is the one case in the new code where it now always adjusts rather
than voids, but the new restore code still needs to recognize cases where
the voiding happened under the old code.

Signed-off-by: Remington Steed <rjs7@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index b4b971b..caf2da1 100644 (file)
@@ -658,7 +658,7 @@ sub bill_payment_map_for_xact {
 
     # find all bills in order
     my $bill_search = [
-        {xact => $xact->id()},
+        { xact => $xact->id(), voided => 'f' },
         { order_by => { mb => { billing_ts => { direction => 'asc' } } } },
     ];
 
index 9739842..c842012 100644 (file)
@@ -4019,13 +4019,23 @@ sub checkin_handle_lost_or_lo_now_found_restore_od {
     if ($ods && @$ods) {
         my $void_amount = 0;
         my $void_max = $self->circ->max_fine();
+        # search for overdues voided the new way (aka "adjusted")
         my @billings = map {$_->id()} @$ods;
         my $voids = $self->editor->search_money_adjustment_payment(
             {
                 billing => \@billings
             }
         );
-        map {$void_amount += $_->amount()} @$voids;
+        if (@$voids) {
+            map {$void_amount += $_->amount()} @$voids;
+        } else {
+            # if no adjustments found, assume they were voided the old way (aka "voided")
+            for my $bill (@$ods) {
+                if( $U->is_true($bill->voided) ) {
+                    $void_amount += $bill->amount();
+                }
+            }
+        }
         $CC->create_bill(
             $self->editor,
             ($void_amount < $void_max ? $void_amount : $void_max),