Bug 21756: Remove use of manualinvoice from Koha::Hold
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Sat, 15 Dec 2018 16:16:33 +0000 (16:16 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 13 Mar 2019 03:58:27 +0000 (03:58 +0000)
Known Side Effect: Prior to this patch hold cancellation fees
were not recorded in the FinesLog. After this patch, if the
FinesLog is enabled then the 'action' will be recorded as
`create_hold_expiration`.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Koha/Hold.pm

index a1ef5aa..3b3aba8 100644 (file)
@@ -365,7 +365,17 @@ sub cancel {
             # and, if desired, charge a cancel fee
             my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
             if ( $charge && $params->{'charge_cancel_fee'} ) {
-                C4::Accounts::manualinvoice($self->borrowernumber, $self->itemnumber, '', 'HE', $charge);
+                my $account =
+                  Koha::Account->new( { patron_id => $self->borrowernumber } );
+                $account->add_debit(
+                    {
+                        amount  => $charge,
+                        user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0,
+                        library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
+                        type    => 'hold_expired',
+                        item_id => $self->itemnumber
+                    }
+                );
             }
 
             C4::Log::logaction( 'HOLDS', 'CANCEL', $self->reserve_id, Dumper($self->unblessed) )
@@ -400,8 +410,8 @@ sub _type {
 =head1 AUTHORS
 
 Kyle M Hall <kyle@bywatersolutions.com>
-
 Jonathan Druart <jonathan.druart@bugs.koha-community.org>
+Martin Renvoize <martin.renvoize@ptfs-europe.com>
 
 =cut