View | Details | Raw Unified | Return to bug 24266
Collapse All | Expand All

(-)a/misc/cronjobs/reconcile_balances.pl (-19 / +21 lines)
Lines 89-119 my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search( Link Here
89
        }
89
        }
90
    );
90
    );
91
91
92
my $patrons = Koha::Patrons->search({ borrowernumber => { -in => \@patron_ids } });
92
if ( scalar @patron_ids ) {
93
93
94
while (my $patron = $patrons->next) {
94
    my $patrons = Koha::Patrons->search({ borrowernumber => { -in => \@patron_ids } });
95
95
96
    my $account = $patron->account;
96
    while (my $patron = $patrons->next) {
97
    my $total_outstanding_credit = $account->outstanding_credits->total_outstanding;
98
    my $total_outstanding_debit  = $account->outstanding_debits->total_outstanding;
99
97
100
    if ( $total_outstanding_credit < 0
98
        my $account = $patron->account;
101
         and $total_outstanding_debit > 0) {
99
        my $total_outstanding_credit = $account->outstanding_credits->total_outstanding;
100
        my $total_outstanding_debit  = $account->outstanding_debits->total_outstanding;
102
101
103
        try {
102
        if ( $total_outstanding_credit < 0
103
            and $total_outstanding_debit > 0) {
104
104
105
            $account->reconcile_balance;
105
            try {
106
106
107
            print $patron->id . ": credit: $total_outstanding_credit " .
107
                $account->reconcile_balance;
108
                                  "debit: $total_outstanding_debit " .
108
109
                                  "=> outstanding " .
109
                print $patron->id . ": credit: $total_outstanding_credit " .
110
                                  "credit: " . $account->outstanding_credits->total_outstanding .
110
                                    "debit: $total_outstanding_debit " .
111
                                 " debit: " .  $account->outstanding_debits->total_outstanding . "\n"
111
                                    "=> outstanding " .
112
                if $verbose;
112
                                    "credit: " . $account->outstanding_credits->total_outstanding .
113
                                    " debit: " .  $account->outstanding_debits->total_outstanding . "\n"
114
                    if $verbose;
115
            }
116
            catch {
117
                print "Problem with patron " . $patron->borrowernumber . ": $_";
118
            };
113
        }
119
        }
114
        catch {
115
            print "Problem with patron " . $patron->borrowernumber . ": $_";
116
        };
117
    }
120
    }
118
}
121
}
119
122
120
- 

Return to bug 24266