C4::Accounts - Functions for dealing with Koha accounts
use C4::Accounts;
The functions in this module deal with the monetary aspect of Koha, including looking up and modifying the amount of money owed by a patron.
$nextacct = &getnextacctno($borrowernumber);
Returns the next unused account number for the patron with the given borrower number.
&fixaccounts($accountlines_id, $borrowernumber, $accountnumber, $amount);
#' # FIXME - I don't understand what this function does. sub fixaccounts { my ( $accountlines_id, $borrowernumber, $accountno, $amount ) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( "SELECT * FROM accountlines WHERE accountlines_id=?" ); $sth->execute( $accountlines_id ); my $data = $sth->fetchrow_hashref;
# FIXME - Error-checking
my $diff = $amount - $data->{'amount'};
my $outstanding = $data->{'amountoutstanding'} + $diff;
$sth->finish;
$dbh->do(<<EOT);
UPDATE accountlines
SET amount = '$amount',
amountoutstanding = '$outstanding'
WHERE accountlines_id = $accountlines_id
EOT
# FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args.
}
&manualinvoice($borrowernumber, $itemnumber, $description, $type,
$amount, $note);
$borrowernumber is the patron's borrower number. $description is a description of the transaction. $type may be one of CS, CB, CW, CF, CL, N, L, or REF. $itemnumber is the item involved, if pertinent; otherwise, it should be the empty string.
purge_zero_balance_fees( $days );
Delete accountlines entries where amountoutstanding is 0 or NULL which are more than a given number of days old.
$days -- Zero balance fees older than $days days old will be deleted.
Warning: Because fines and payments are not linked in accountlines, it is possible for a fine to be deleted without the accompanying payment, or vise versa. This won't affect the account balance, but might be confusing to staff.
DBI(3)