Bug 18501: set the is_refunded flag as internal var
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 14 Aug 2020 08:48:00 +0000 (10:48 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 20 Aug 2020 10:31:59 +0000 (12:31 +0200)
After discussion with Martin we decided that it could be the correct way

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Circulation.pm
Koha/Item.pm

index fcd0cee..db01b57 100644 (file)
@@ -2014,14 +2014,13 @@ sub AddReturn {
 
     my $item_was_lost = $item->itemlost;
     my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
-    ModDateLastSeen( $item->itemnumber, $leave_item_lost ); # will unset itemlost if needed
+    my $updated_item = ModDateLastSeen( $item->itemnumber, $leave_item_lost ); # will unset itemlost if needed
 
     # fix up the accounts.....
     if ( $item_was_lost ) {
         $messages->{'WasLost'} = 1;
         unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
-            #my $refunded = Koha::Account::Lines->search{(itemnumber => $item->itemnumber, type => 'LOST_FOUND', # FIXME which other parameters to know it has been refunded?
-            $messages->{'LostItemFeeRefunded'} = 1;
+            $messages->{'LostItemFeeRefunded'} = $updated_item->{_refunded};
         }
     }
 
index 5e03e51..74f09ab 100644 (file)
@@ -871,6 +871,7 @@ sub _set_found_trigger {
         );
 
         $credit->apply( { debits => [$accountline] } );
+        $self->{_refunded} = 1;
     }
 
     # Update the account status