From: Bill Erickson Date: Thu, 21 May 2015 21:57:28 +0000 (-0400) Subject: LP#1453974 copy details reports aged circ X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3ea6b2f99b6712250c2442bf33ff1db7c562baa3;p=working%2FEvergreen.git LP#1453974 copy details reports aged circ If an aged circulation is linked to a copy which is newer than the most recent standard circulation on the copy, return the aged circ as additional data ('aged_circ') in the copy details API call. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index adf6af2cc9..3879cd5da3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -1094,12 +1094,50 @@ sub copy_details { ] )->[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, };