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, $sip_paytype);
Record payment by a patron. $borrowernumber
is the patron's borrower number. $payment
is a floating-point number, giving the amount that was paid. $sip_paytype
is an optional flag to indicate this payment was made over a SIP2 interface, rather than the staff client. The value passed is the SIP2 payment type value (message 37, characters 21-22)
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($accountlines_id, $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($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.
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.
WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
Write off a fine for a patron. $borrowernumber
is the patron's borrower number. $accountline_id
is the accountline_id of the fee to write off. $itemnum
is the itemnumber of of item whose fine is being written off. $accounttype
is the account type of the fine being written off. $amount
is a floating-point number, giving the amount that is being written off. $branch
is the branchcode of the library where the writeoff occurred. $payment_note
is the note to attach to this payment
DBI(3)