]
)->[0];
+ # The most recent circulation could be an aged circ.
+ # If so, pass it back to the caller to handle as desired.
+
+ my $aged_circ;
+
+ if ($circ and !$circ->checkin_time and !$circ->xact_finish and (
+ !$circ->stop_fines or
+ $circ->stop_fines eq OILS_STOP_FINES_MAX_FINES or
+ $circ->stop_fines eq OILS_STOP_FINES_LONGOVERDUE
+ )) {
+
+ # Skip the aged circ check if the copy is actively circulating.
+ # Saves one cstore call.
+
+ } else {
+
+ my %date_filter = $circ ?
+ (xact_start => {'>' => $circ->xact_start}) : ();
+
+ $aged_circ = $e->search_action_aged_circulation([
+ {target_copy => $copy_id, %date_filter},
+ {
+ flesh => 1,
+ flesh_fields => {
+ acirc => [
+ 'workstation',
+ 'checkin_workstation',
+ 'duration_rule',
+ 'max_fine_rule',
+ 'recurring_fine_rule'
+ ]
+ },
+ order_by => {circ => 'xact_start desc'},
+ limit => 1
+ }
+ ])->[0];
+ }
return {
- copy => $copy,
- hold => $hold,
+ copy => $copy,
+ hold => $hold,
transit => $transit,
- circ => $circ,
+ circ => $circ, # most recent non-aged circulation
+ aged_circ => $aged_circ, # most recent aged circ if newer than circ
volume => $vol,
mvr => $mvr,
};