<<

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, $user);

$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

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

 This function is only used internally, not exported.
 FIXME - Figure out what this function does, and write it down.

refund

# FIXME - Figure out what this function does, and write it down.

SEE ALSO

DBI(3)

<<