Bugs 6634: manager_id not recorded for payments and rental charges

Manager_id, the borrowernumber of the staff person doing the action, was not recorded
for payments, rental charges, or rental charges on renewals.  This patch implements that.

This patch also adds the recording of itemnumber in a payment, by taking the itemnumber of
the account that it's paying off.  This addresses bug 2696, though it does not make any
change to the display logic of the Payments line in the staff client.

To test:
1.  Check out an item with an issuing charge
2.  Renew the item
3.  Pay one of the rental charges on the item
4.  Verify in koha.accountlines that each of the three above operations recorded your borrowernumber
in accountlines.manager_id

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit 18c491542b)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Ian Walls 2011-07-26 22:11:42 -04:00 committed by Chris Nighswonger
parent d3adb09b80
commit f1894dada9
2 changed files with 17 additions and 22 deletions

View File

@ -158,6 +158,8 @@ sub makepayment {
# from their card, and put a note on the item record
my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
my $dbh = C4::Context->dbh;
my $manager_id = 0;
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
# begin transaction
my $nextaccntno = getnextacctno($borrowernumber);
@ -175,21 +177,13 @@ sub makepayment {
AND accountno = ?");
$sth->execute($borrowernumber, $accountno);
# print $updquery;
# $dbh->do( "
# INSERT INTO accountoffsets
# (borrowernumber, accountno, offsetaccount,
# offsetamount)
# VALUES ($borrowernumber, $accountno, $nextaccntno, $newamtos)
# " );
# create new line
my $payment = 0 - $amount;
$sth = $dbh->prepare("INSERT INTO accountlines
(borrowernumber, accountno, date, amount,
description, accounttype, amountoutstanding)
VALUES (?,?,now(),?,?,'Pay',0)");
$sth->execute($borrowernumber, $nextaccntno, $payment, "Payment,thanks - $user");
(borrowernumber, accountno, date, amount,itemnumber,
description, accounttype, amountoutstanding, manager_id)
VALUES (?,?,now(),?,?,?,'Pay',0,?)");
$sth->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'},"Payment,thanks - $user", $manager_id);
# FIXME - The second argument to &UpdateStats is supposed to be the
# branch code.

View File

@ -2283,16 +2283,15 @@ sub AddRenewal {
if ( $charge > 0 ) {
my $accountno = getnextacctno( $borrowernumber );
my $item = GetBiblioFromItemNumber($itemnumber);
my $manager_id = 0;
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
$sth = $dbh->prepare(
"INSERT INTO accountlines
(date,
borrowernumber, accountno, amount,
description,
accounttype, amountoutstanding, itemnumber
)
VALUES (now(),?,?,?,?,?,?,?)"
(date, borrowernumber, accountno, amount, manager_id,
description,accounttype, amountoutstanding, itemnumber)
VALUES (now(),?,?,?,?,?,?,?,?)"
);
$sth->execute( $borrowernumber, $accountno, $charge,
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
"Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
'Rent', $charge, $itemnumber );
$sth->finish;
@ -2445,15 +2444,17 @@ sub AddIssuingCharge {
my ( $itemnumber, $borrowernumber, $charge ) = @_;
my $dbh = C4::Context->dbh;
my $nextaccntno = getnextacctno( $borrowernumber );
my $manager_id = 0;
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
my $query ="
INSERT INTO accountlines
(borrowernumber, itemnumber, accountno,
date, amount, description, accounttype,
amountoutstanding)
VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?)
amountoutstanding, manager_id)
VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?)
";
my $sth = $dbh->prepare($query);
$sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge );
$sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id );
$sth->finish;
}