Code comments and tweaks for lost processing
authorDan Wells <dbw2@calvin.edu>
Mon, 5 Dec 2011 16:44:41 +0000 (11:44 -0500)
committerDan Wells <dbw2@calvin.edu>
Tue, 6 Dec 2011 14:45:03 +0000 (09:45 -0500)
This commit is intended to do the following:

* Fix case where MISSING status is not retained for items
  being sent 'home' (as it was in previous versions)
* Be more explicit about when we unset the LOST status and when
  we do not in checkin_handle_lost()
* Prevent update of the copy in checkin_handle_lost() unless we
  actually change the status
* Restore log messages for special handling of LOST/MISSING
  checkins away from 'home'
* Provide additional code comments to clarify intended behavior

Note: Given the current restructure, MISSING item behavior is no
longer affected by 'lost_immediately_available' setting.  That
seemed more bug than feature, and can be implemented later
(perhaps as a separate setting) if required.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index c00d662..50ef6d6 100644 (file)
@@ -3297,11 +3297,17 @@ sub checkin_handle_circ {
     my $stat = $U->copy_status($self->copy->status)->id;
 
     if ($stat == OILS_COPY_STATUS_LOST) {
-
+        # we will now handle lost fines, but the copy will retain its 'lost'
+        # status if it needs to transit home unless lost_immediately_available
+        # is true
+        #
+        # if we decide to also delay fine handling until the item arrives home,
+        # we will need to call lost fine handling code both when checking items
+        # in and also when receiving transits
         $self->checkin_handle_lost($circ_lib);
-
+    } elsif ($circ_lib != $self->circ_lib and $stat == OILS_COPY_STATUS_MISSING) {
+        $logger->info("circulator: not updating copy status on checkin because copy is missing");
     } else {
-
         $self->copy->status($U->copy_status(OILS_COPY_STATUS_RESHELVING));
         $self->update_copy;
     }
@@ -3360,12 +3366,25 @@ sub checkin_handle_lost {
         $self->checkin_handle_lost_now_found_restore_od($circ_lib) if $restore_od && ! $self->void_overdues;
     }
 
-    my $immediately_available = $U->ou_ancestor_setting_value(
-        $circ_lib, OILS_SETTING_LOST_IMMEDIATELY_AVAILABLE, $self->editor) || 0;
+    if ($circ_lib != $self->circ_lib) {
+        # if the item is not home, check to see if we want to retain the lost
+        # status at this point in the process
+        my $immediately_available = $U->ou_ancestor_setting_value($circ_lib, OILS_SETTING_LOST_IMMEDIATELY_AVAILABLE, $self->editor) || 0;
 
-    $self->copy->status($U->copy_status(OILS_COPY_STATUS_RESHELVING)) if ($immediately_available);
-
-    $self->update_copy;
+        if ($immediately_available) {
+            # lost item status does not need to be retained, so give it a
+            # reshelving status as if it were a normal checkin
+            $self->copy->status($U->copy_status(OILS_COPY_STATUS_RESHELVING));
+            $self->update_copy;
+        } else {
+            $logger->info("circulator: not updating copy status on checkin because copy is lost");
+        }
+    } else {
+        # lost item is home and processed, treat like a normal checkin from
+        # this point on
+        $self->copy->status($U->copy_status(OILS_COPY_STATUS_RESHELVING));
+        $self->update_copy;
+    }
 }