<<

NAME

C4::Accounts - Functions for dealing with Koha accounts

SYNOPSIS

use C4::Accounts;

DESCRIPTION

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.

FUNCTIONS

recordpayment

  &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

  &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.

getnextacctno

  $nextacct = &getnextacctno($borrowernumber);

Returns the next unused account number for the patron with the given borrower number.

fixaccounts (removed)

  &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

  &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.

fixcredit #### DEPRECATED

 $amountleft = &fixcredit($borrowernumber, $data, $barcode, $type, $user);

 This function is only used internally, not exported.

refund

#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

  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.

WriteOff

  WriteOff( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount, $branch );

Write off a fine for a patron. $borrowernumber is the patron's borrower number. $accountnum is the accountnumber 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.

SEE ALSO

DBI(3)

<<