More fixes as a result of testing. user/dyrcona/lp1198465-Conditional-Negative-Balances
authorJason Stephenson <jason@sigio.com>
Mon, 27 Jan 2014 17:38:31 +0000 (12:38 -0500)
committerJason Stephenson <jason@sigio.com>
Mon, 27 Jan 2014 17:38:31 +0000 (12:38 -0500)
Testing voiding of lost on claims returned turned up a problem with
double voiding the same bill when/if the claims returned copy is
later checked in.  The fix is to modify CircCommon::void_bills_of_type
so that it does not void already voided bills.

Also, the BILL_ALREADY_VOIDED event was not getting propagated to the
staff client, so we changed CircCommon::real_void_bills to add the
event to the editor.

Finally, there was a typo in the original event description in
ils_events.xml, so we altered that language to be simpler English.

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

index 21d59a7..5f34047 100644 (file)
@@ -78,7 +78,7 @@
                <desc xml:lang="en-US">The provided password is not correct</desc>
        </event>
        <event code='1211' textcode='BILL_ALREADY_VOIDED'>
-               <desc xml:lang="en-US">The selecte bill has already been voided</desc>
+               <desc xml:lang="en-US">The bill is already voided</desc>
        </event>
        <event code='1212' textcode='PATRON_EXCEEDS_OVERDUE_COUNT'>
                <desc xml:lang="en-US">The patron has too many overdue items</desc>
index 8acaf36..bf14556 100644 (file)
@@ -85,17 +85,16 @@ sub void_bills_of_type {
     # Make sure we have a session.
     return $e->die_event unless $e->checkauth;
 
-    my $bills = $e->search_money_billing(
-        {
-            xact => $circ->id,
-            btype => $btype
-        }
-    );
-
-    if ($bills && @$bills) {
-        my $result = $class->real_void_bills($e, $bills, $note);
-        if (ref($result)) {
-            return $result;
+    # Get a bill payment map.
+    my $bpmap = $class->bill_payment_map_for_xact($e, $circ);
+    if ($bpmap && @$bpmap) {
+        # Filter out the unvoided bills of the type we're looking for:
+        my @bills = map {$_->{bill}} grep { $_->{bill}->btype() == $btype && $_->{bill_amount} > $_->{void_amount} } @$bpmap;
+        if (@bills) {
+            my $result = $class->real_void_bills($e, \@bills, $note);
+            if (ref($result)) {
+                return $result;
+            }
         }
     }
 
@@ -579,7 +578,9 @@ sub real_void_bills {
             # made it impossible to void an already voided bill, so
             # we're doing the same.
             if ($amount_to_void <= 0) {
-                return OpenILS::Event->new('BILL_ALREADY_VOIDED', payload => $bill);
+                my $event = OpenILS::Event->new('BILL_ALREADY_VOIDED', payload => $bill);
+                $e->event($event);
+                return $event;
             }
 
             # If we're voiding a circulation-related bill we have