From: erickson Date: Wed, 6 Oct 2010 20:44:46 +0000 (+0000) Subject: added support for honoring the due date ceiling from the duration rule. AKA, end... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e2e70bce04a6043f389d14b19baa1fc10b5e847c;p=contrib%2FConifer.git added support for honoring the due date ceiling from the duration rule. AKA, end-of-semester due dates git-svn-id: svn://svn.open-ils.org/ILS/trunk@18213 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index 330df44421..66330c9425 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -1196,7 +1196,8 @@ sub get_circ_policy { max_fine_rule => $max_fine_rule->name, max_fine => $self->get_max_fine_amount($max_fine_rule), fine_interval => $recurring_fine_rule->recurrence_interval, - renewal_remaining => $duration_rule->max_renewals + renewal_remaining => $duration_rule->max_renewals, + duration_date_ceiling => $duration_rule->date_ceiling }; $policy->{duration} = $duration_rule->shrt @@ -1760,10 +1761,12 @@ sub build_checkout_circ_object { my $recurring = $self->recurring_fines_rule; my $copy = $self->copy; my $patron = $self->patron; + my $duration_date_ceiling; if( $duration ) { my $policy = $self->get_circ_policy($duration, $recurring, $max); + $duration_date_ceiling = $policy->{duration_date_ceiling}; my $dname = $duration->name; my $mname = $max->name; @@ -1816,7 +1819,7 @@ sub build_checkout_circ_object { # if a patron is renewing, 'requestor' will be the patron $circ->circ_staff($self->editor->requestor->id); - $circ->due_date( $self->create_due_date($circ->duration) ) if $circ->duration; + $circ->due_date( $self->create_due_date($circ->duration, $duration_date_ceiling) ) if $circ->duration; $self->circ($circ); } @@ -2016,7 +2019,7 @@ sub apply_modified_due_date { sub create_due_date { - my( $self, $duration ) = @_; + my( $self, $duration, $date_ceiling ) = @_; # if there is a raw time component (e.g. from postgres), # turn it into an interval that interval_to_seconds can parse @@ -2028,6 +2031,14 @@ sub create_due_date { # add the circ duration $due_date->add(seconds => OpenSRF::Utils->interval_to_seconds($duration)); + if($date_ceiling) { + my $cdate = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($date_ceiling)); + if ($cdate > DateTime->now and $cdate < $due_date) { + $logger->info("circulator: overriding due date with date ceiling: $date_ceiling"); + $due_date = $cdate; + } + } + # return ISO8601 time with timezone return $due_date->strftime('%FT%T%z'); }