@@ -, +, @@ --- misc/cronjobs/reconcile_balances.pl | 39 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) --- a/misc/cronjobs/reconcile_balances.pl +++ a/misc/cronjobs/reconcile_balances.pl @@ -89,31 +89,34 @@ my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search( } ); -my $patrons = Koha::Patrons->search({ borrowernumber => { -in => \@patron_ids } }); +if ( scalar @patron_ids ) { -while (my $patron = $patrons->next) { + my $patrons = Koha::Patrons->search({ borrowernumber => { -in => \@patron_ids } }); - my $account = $patron->account; - my $total_outstanding_credit = $account->outstanding_credits->total_outstanding; - my $total_outstanding_debit = $account->outstanding_debits->total_outstanding; + while (my $patron = $patrons->next) { - if ( $total_outstanding_credit < 0 - and $total_outstanding_debit > 0) { + my $account = $patron->account; + my $total_outstanding_credit = $account->outstanding_credits->total_outstanding; + my $total_outstanding_debit = $account->outstanding_debits->total_outstanding; - try { + if ( $total_outstanding_credit < 0 + and $total_outstanding_debit > 0) { - $account->reconcile_balance; + try { - print $patron->id . ": credit: $total_outstanding_credit " . - "debit: $total_outstanding_debit " . - "=> outstanding " . - "credit: " . $account->outstanding_credits->total_outstanding . - " debit: " . $account->outstanding_debits->total_outstanding . "\n" - if $verbose; + $account->reconcile_balance; + + print $patron->id . ": credit: $total_outstanding_credit " . + "debit: $total_outstanding_debit " . + "=> outstanding " . + "credit: " . $account->outstanding_credits->total_outstanding . + " debit: " . $account->outstanding_debits->total_outstanding . "\n" + if $verbose; + } + catch { + print "Problem with patron " . $patron->borrowernumber . ": $_"; + }; } - catch { - print "Problem with patron " . $patron->borrowernumber . ": $_"; - }; } } --