From f0d09da3da911659b88f42a72a7f6286d623309f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 1 Nov 2018 11:08:51 +0000 Subject: [PATCH] Bug 21728: Use Koha::Account->add_debit in ChargeReserveFee --- C4/Reserves.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 78e8f6a360..95b4b853c4 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -566,13 +566,20 @@ sub GetOtherReserves { sub ChargeReserveFee { my ( $borrowernumber, $fee, $title ) = @_; - return if !$fee || $fee==0; # the last test is needed to include 0.00 - my $accquery = qq{ -INSERT INTO accountlines ( borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding ) VALUES (?, ?, NOW(), ?, ?, 'Res', ?) - }; - my $dbh = C4::Context->dbh; - my $nextacctno = &getnextacctno( $borrowernumber ); - $dbh->do( $accquery, undef, ( $borrowernumber, $nextacctno, $fee, "Reserve Charge - $title", $fee ) ); + return if !$fee || $fee == 0; # the last test is needed to include 0.00 + Koha::Account->new( { patron_id => $borrowernumber } )->add_debit( + { + amount => $fee, + description => "Reserve Charge - " . $title, + note => undef, + user_id => undef, + library_id => undef, + sip => undef, + invoice_type => undef, + type => 'reserve', + item_id => undef + } + ); } =head2 GetReserveFee -- 2.19.1