=head2 recordpayment
- &recordpayment($borrowernumber, $payment);
+ &recordpayment($borrowernumber, $payment, $sip_paytype);
Record payment by a patron. C<$borrowernumber> is the patron's
borrower number. C<$payment> is a floating-point number, giving the
-amount that was paid.
+amount that was paid. C<$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
sub recordpayment {
#here we update the account lines
- my ( $borrowernumber, $data ) = @_;
+ my ( $borrowernumber, $data, $sip_paytype ) = @_;
my $dbh = C4::Context->dbh;
my $newamtos = 0;
my $accdata = "";
my $usth = $dbh->prepare(
"INSERT INTO accountlines
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id)
- VALUES (?,?,now(),?,'','Pay',?,?)"
+ VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)"
);
- $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $manager_id );
+
+ my $payment_description = "Payment, thanks";
+ $payment_description .= " (via SIP2)" if defined $sip_paytype;
+ my $paytype = "Pay";
+ $paytype .= "-$sip_paytype" if defined $sip_paytype;
+ $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $payment_description, $paytype, 0 - $amountleft, $manager_id );
+ $usth->finish;
UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno );
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare(
"SELECT * FROM accountlines,borrowers
- WHERE amount < 0 AND accounttype <> 'Pay' AND accountlines.borrowernumber = borrowers.borrowernumber
+ WHERE amount < 0 AND accounttype not like 'Pay%' AND accountlines.borrowernumber = borrowers.borrowernumber
AND timestamp >=TIMESTAMP(?) AND timestamp < TIMESTAMP(?)"
);