- 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 => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0,
+ library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
+ sip => undef,
+ invoice_type => undef,
+ type => 'reserve',
+ item_id => undef
+ }
+ );