LP#1427309 Fix Crash in Collections User Balance Summary
authorJason Boyer <jboyer1@library.in.gov>
Mon, 2 Mar 2015 20:06:33 +0000 (15:06 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 29 Apr 2015 15:17:53 +0000 (11:17 -0400)
Previously a patron in collections that paid off all
transactions would cause a crash and stop processing
any balance summary file that they are supposed to
appear in. Now user balance summaries can be created
in full even if some users have a 0 balance.

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Collections.pm

index 750468c..e3fb511 100644 (file)
@@ -862,16 +862,19 @@ sub user_balance_summary {
         );
 
         # get the sum owed an all transactions
-        my $balance = $e->json_query({
-            select => {mbts => [
-                {   column => 'balance_owed',
-                    transform => 'sum',
-                    aggregate => 1
-                }
-            ]},
-            from => 'mbts',
-            where => {id => [@$circ_ids, @$groc_ids, @$res_ids]}
-        })->[0];
+        my $balance = undef;
+        if (@{[@$circ_ids, @$groc_ids, @$res_ids]}) {
+            $balance = $e->json_query({
+                select => {mbts => [
+                    {   column => 'balance_owed',
+                        transform => 'sum',
+                        aggregate => 1
+                    }
+                ]},
+                from => 'mbts',
+                where => {id => [@$circ_ids, @$groc_ids, @$res_ids]}
+            })->[0];
+        }
 
         $balance = $balance ? $balance->{balance_owed} : '0';