Lines 61-66
sub get {
Link Here
|
61 |
status => 200, |
61 |
status => 200, |
62 |
openapi => { |
62 |
openapi => { |
63 |
balance => $account->balance, |
63 |
balance => $account->balance, |
|
|
64 |
borrowernumber => $patron->borrowernumber, |
64 |
outstanding_debits => { |
65 |
outstanding_debits => { |
65 |
total => $debits->total_outstanding, |
66 |
total => $debits->total_outstanding, |
66 |
lines => $debits->to_api |
67 |
lines => $debits->to_api |
Lines 295-298
sub add_debit {
Link Here
|
295 |
}; |
296 |
}; |
296 |
} |
297 |
} |
297 |
|
298 |
|
|
|
299 |
=head3 get_patron_balances |
300 |
|
301 |
=cut |
302 |
|
303 |
sub get_patron_balances { |
304 |
my $c = shift->openapi->valid_input or return; |
305 |
|
306 |
return try { |
307 |
my @patrons_with_outstanding_balances; |
308 |
my $patrons_rs = Koha::Patrons->search()->as_list; |
309 |
|
310 |
foreach my $patron ( @{ $patrons_rs } ) { |
311 |
my $account = $patron->account; |
312 |
my $balance = $account->balance; |
313 |
my $debits = $account->outstanding_debits; |
314 |
my $credits = $account->outstanding_credits; |
315 |
my $total_debits = $debits->total_outstanding; |
316 |
my $total_credits = $credits->total_outstanding; |
317 |
|
318 |
if($total_debits != 0 || $total_credits != 0) { |
319 |
my $patron_account_detail = { |
320 |
borrowernumber => $patron->borrowernumber, |
321 |
balance => $balance, |
322 |
outstanding_debits => { |
323 |
total => $total_debits, |
324 |
lines => $debits->to_api |
325 |
}, |
326 |
outstanding_credits => { |
327 |
total => $total_credits, |
328 |
lines => $credits->to_api |
329 |
} |
330 |
}; |
331 |
push @patrons_with_outstanding_balances, $patron_account_detail; |
332 |
} |
333 |
} |
334 |
|
335 |
return $c->render( |
336 |
status => 200, |
337 |
openapi => \@patrons_with_outstanding_balances |
338 |
); |
339 |
|
340 |
} |
341 |
catch { |
342 |
$c->unhandled_exception($_); |
343 |
}; |
344 |
} |
345 |
|
298 |
1; |
346 |
1; |