From f023d2f4ae236c69abc0ff802bedf3712a4e8ee7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 1 Nov 2018 13:28:25 +0000 Subject: [PATCH] Bug 21721: Use Koha::Account->add_debit in AddRenewal --- C4/Circulation.pm | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 23d0b5fb5c..3e3b511408 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1409,7 +1409,8 @@ sub AddIssue { # If it costs to borrow this book, charge it to the patron's account. my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); if ( $charge > 0 ) { - AddIssuingCharge( $issue, $charge ); + my $description = "Rental"; + AddIssuingCharge( $issue, $charge, $description ); $item->{'charge'} = $charge; } @@ -2873,18 +2874,8 @@ sub AddRenewal { # Charge a new rental fee, if applicable? my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); if ( $charge > 0 ) { - my $accountno = C4::Accounts::getnextacctno( $borrowernumber ); - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - $sth = $dbh->prepare( - "INSERT INTO accountlines - (date, borrowernumber, accountno, amount, manager_id, - description,accounttype, amountoutstanding, itemnumber) - VALUES (now(),?,?,?,?,?,?,?,?)" - ); - $sth->execute( $borrowernumber, $accountno, $charge, $manager_id, - "Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}", - 'Rent', $charge, $itemnumber ); + my $description = "Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}"; + AddIssuingCharge($issue, $charge, $description); } # Send a renewal slip according to checkout alert preferencei @@ -3209,7 +3200,7 @@ sub _get_discount_from_rule { =cut sub AddIssuingCharge { - my ( $checkout, $charge ) = @_; + my ( $checkout, $charge, $description ) = @_; # FIXME What if checkout does not exist? @@ -3227,7 +3218,7 @@ sub AddIssuingCharge { amount => $charge, amountoutstanding => $charge, manager_id => $manager_id, - description => 'Rental', + description => $description, accounttype => 'Rent', date => \'NOW()', } -- 2.19.1