From: Ian Walls <ian.wa...@bywatersolutions.com>

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...@web.de>
---
 C4/Accounts.pm    |   18 ++++++------------
 C4/Circulation.pm |   21 +++++++++++----------
 2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/C4/Accounts.pm b/C4/Accounts.pm
index 3275099..5ae695f 100644
--- a/C4/Accounts.pm
+++ b/C4/Accounts.pm
@@ -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.
diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 179fe70..47068f9 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -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;
 }
 
-- 
1.7.4.1

_______________________________________________
Koha-patches mailing list
Koha-patches@lists.koha-community.org
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to