From: Bill Erickson Date: Wed, 8 Jun 2011 19:44:37 +0000 (-0400) Subject: Extend hold shelf expire date beyond closed dates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=34906bd225de9752e12d4c85d54ebf3e45012b41;p=evergreen%2Fbjwebb.git Extend hold shelf expire date beyond closed dates If the shelf_expire_time on a hold would land on a closed date for the pickup library, push the expire time out to just beyond the close date range, similar to the circulation due date overlap logic. In the current iteration, the time component of the date is pushed out to the end of the day (23:59:59). If this is not generally the desired behavior, an org setting could be added to bypass this step so that the time matches "now" (i.e. capture time) instead. Signed-off-by: Bill Erickson Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index 02eebd545..1479c1f0b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -2913,12 +2913,29 @@ sub put_hold_on_shelf { my $shelf_expire = $U->ou_ancestor_setting_value( $self->circ_lib, 'circ.holds.default_shelf_expire_interval', $self->editor); - if($shelf_expire) { - my $seconds = OpenSRF::Utils->interval_to_seconds($shelf_expire); - my $expire_time = DateTime->now->add(seconds => $seconds); - $hold->shelf_expire_time($expire_time->strftime('%FT%T%z')); + return undef unless $shelf_expire; + + my $seconds = OpenSRF::Utils->interval_to_seconds($shelf_expire); + my $expire_time = DateTime->now->add(seconds => $seconds); + + # if the shelf expire time overlaps with a pickup lib's + # closed date, push it out to the first open date + my $dateinfo = $U->storagereq( + 'open-ils.storage.actor.org_unit.closed_date.overlap', + $hold->pickup_lib, $expire_time); + + if($dateinfo) { + my $dt_parser = DateTime::Format::ISO8601->new; + $expire_time = $dt_parser->parse_datetime(cleanse_ISO8601($dateinfo->{end})); + + # TODO: enable/disable time bump via setting? + $expire_time->set(hour => '23', minute => '59', second => '59'); + + $logger->info("circulator: shelf_expire_time overlaps". + " with closed date, pushing expire time to $expire_time"); } + $hold->shelf_expire_time($expire_time->strftime('%FT%T%z')); return undef; }