);
# 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';