From 34906bd225de9752e12d4c85d54ebf3e45012b41 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 8 Jun 2011 15:44:37 -0400 Subject: [PATCH] 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 --- .../lib/OpenILS/Application/Circ/Circulate.pm | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) 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 02eebd5456..1479c1f0b6 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; } -- 2.11.0