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.
&recordpayment($borrowernumber, $payment);
Record payment by a patron. $borrowernumber
is the patron's borrower number. $payment
is a floating-point number, giving the amount that was paid.
Amounts owed are paid off oldest first. That is, if the patron has a $1 fine from Feb. 1, another $1 fine from Mar. 1, and makes a payment of $1.50, then the oldest fine will be paid off in full, and $0.50 will be credited to the next one.
&makepayment($borrowernumber, $acctnumber, $amount, $branchcode);
Records the fact that a patron has paid off the entire amount he or she owes.
$borrowernumber
is the patron's borrower number. $acctnumber
is the account that was credited. $amount
is the amount paid (this is only used to record the payment. It is assumed to be equal to the amount owed). $branchcode
is the code of the branch where payment was made.
$nextacct = &getnextacctno($borrowernumber);
Returns the next unused account number for the patron with the given borrower number.
&fixaccounts($borrowernumber, $accountnumber, $amount);
#' # FIXME - I don't understand what this function does. sub fixaccounts { my ( $borrowernumber, $accountno, $amount ) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?" ); $sth->execute( $borrowernumber, $accountno ); 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 borrowernumber = $borrowernumber AND accountno = $accountno 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.
$amountleft = &fixcredit($borrowernumber, $data, $barcode, $type, $user); This function is only used internally, not exported.
#FIXME : DEPRECATED SUB This subroutine tracks payments and/or credits against fines/charges using the accountoffsets table, which is not used consistently in Koha's fines management, and so is not used in 3.0
recordpayment_selectaccts($borrowernumber, $payment,$accts);
Record payment by a patron. $borrowernumber
is the patron's borrower number. $payment
is a floating-point number, giving the amount that was paid. $accts
is an array ref to a list of accountnos which the payment can be recorded against
Amounts owed are paid off oldest first. That is, if the patron has a $1 fine from Feb. 1, another $1 fine from Mar. 1, and makes a payment of $1.50, then the oldest fine will be paid off in full, and $0.50 will be credited to the next one.
DBI(3)