+C<$borrowernumber> specifies the borrower to look up.
+
+C<$dbh> is a DBI::db handle for the Koha database.
+
+C<$env> is ignored.
+
+=cut
+#'
+sub checkaccount {
+ #take borrower number
+ #check accounts and list amounts owing
+ my ($env,$bornumber,$dbh,$date)=@_;
+ my $select="SELECT SUM(amountoutstanding) AS total
+ FROM accountlines
+ WHERE borrowernumber = ?
+ AND amountoutstanding<>0";
+ my @bind = ($bornumber);
+ if ($date && $date ne ''){
+ $select.=" AND date < ?";
+ push(@bind,$date);
+ }
+ # print $select;
+ my $sth=$dbh->prepare($select);
+ $sth->execute(@bind);
+ my $data=$sth->fetchrow_hashref;
+ my $total = $data->{'total'} || 0;
+ $sth->finish;
+ # output(1,2,"borrower owes $total");
+ #if ($total > 0){
+ # # output(1,2,"borrower owes $total");
+ # if ($total > 5){
+ # reconcileaccount($env,$dbh,$bornumber,$total);
+ # }
+ #}
+ # pause();
+ return($total);