Bug 18501: Auto refund if mark as found from cataloguing
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 10 Aug 2020 14:51:11 +0000 (16:51 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 20 Aug 2020 10:31:59 +0000 (12:31 +0200)
If an item is marked as found (ie. not itemlost) we need to refund the
patron.

Test plan:
Mark an item as lost to create a fee for the patron
Mark it as found from the cataloguing module and confirm that the patron
is refunded

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>

catalogue/updateitem.pl
cataloguing/additem.pl

index f8295a0..43f076c 100755 (executable)
@@ -68,6 +68,9 @@ elsif ( $op eq "set_public_note" ) { # i.e., itemnotes parameter passed from for
         $item->itemnotes($itemnotes);
     }
 } elsif ( $op eq "set_lost" && $itemlost ne $item_data_hashref->{'itemlost'}) {
+    $item->set_found
+        if !$itemlost && $item->itemlost && $item->itemlost ge '1';
+
     $item->itemlost($itemlost);
 } elsif ( $op eq "set_withdrawn" && $withdrawn ne $item_data_hashref->{'withdrawn'}) {
     $item->withdrawn($withdrawn);
index bbdedf6..9e15c43 100755 (executable)
@@ -749,8 +749,11 @@ if ($op eq "additem") {
         $itemnumber = q{};
         my $olditemlost = $item->itemlost;
         my $newitemlost = $newitem->{itemlost};
-        LostItem( $item->itemnumber, 'additem' )
-            if $newitemlost && $newitemlost ge '1' && !$olditemlost;
+        if ( $newitemlost && $newitemlost ge '1' && !$olditemlost ) {
+            LostItem( $item->itemnumber, 'additem' )
+        } elsif ( !$newitemlost && $olditemlost && $olditemlost ge '1' ) {
+            $item->set_found;
+        }
     }
     $nextop="additem";
 } elsif ($op eq "delinkitem"){