From: erickson Date: Mon, 7 Aug 2006 20:20:17 +0000 (+0000) Subject: added checks for null due_dates and unlimited circ durations X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f026fd6b3c0f40c36359479af149df4079be47a9;p=Evergreen.git added checks for null due_dates and unlimited circ durations git-svn-id: svn://svn.open-ils.org/ILS/trunk@5347 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 2cf0ae7d9c..9b80360fd2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -1740,10 +1740,14 @@ sub _checked_out { # split the circs up into overdue and not-overdue circs my (@out,@overdue); for my $c (@$circs) { - my $due_dt = $parser->parse_datetime( clense_ISO8601( $c->due_date ) ); - my $due = $due_dt->epoch; - if ($due < DateTime->today->epoch) { - push @overdue, $c->id; + if( $c->due_date ) { + my $due_dt = $parser->parse_datetime( clense_ISO8601( $c->due_date ) ); + my $due = $due_dt->epoch; + if ($due < DateTime->today->epoch) { + push @overdue, $c->id; + } else { + push @out, $c->id; + } } else { push @out, $c->id; } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index 162fecb6d2..ece57b6ab8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -880,20 +880,28 @@ sub run_checkout_scripts { throw OpenSRF::EX::ERROR ("Circ Duration Script Died: $@"); my $duration = $result->{durationRule}; - #my $dur_level = $result->{durationLevel}; my $recurring = $result->{recurringFinesRule}; my $max_fine = $result->{maxFine}; - #my $rec_fines_level = $result->{recurringFinesLevel}; - ($duration, $evt) = $U->fetch_circ_duration_by_name($duration); - return $self->bail_on_events($evt) if $evt; - ($recurring, $evt) = $U->fetch_recurring_fine_by_name($recurring); - return $self->bail_on_events($evt) if $evt; - ($max_fine, $evt) = $U->fetch_max_fine_by_name($max_fine); - return $self->bail_on_events($evt) if $evt; + if( $duration ne OILS_UNLIMITED_CIRC_DURATION ) { + + ($duration, $evt) = $U->fetch_circ_duration_by_name($duration); + return $self->bail_on_events($evt) if $evt; + + ($recurring, $evt) = $U->fetch_recurring_fine_by_name($recurring); + return $self->bail_on_events($evt) if $evt; + + ($max_fine, $evt) = $U->fetch_max_fine_by_name($max_fine); + return $self->bail_on_events($evt) if $evt; + + } else { + + # The item circulates with an unlimited duration + $duration = undef; + $recurring = undef; + $max_fine = undef; + } - #$self->duration_level($dur_level); - #$self->recurring_fines_level($rec_fines_level); $self->duration_rule($duration); $self->recurring_fines_rule($recurring); $self->max_fine_rule($max_fine); @@ -909,41 +917,47 @@ sub build_checkout_circ_object { my $recurring = $self->recurring_fines_rule; my $copy = $self->copy; my $patron = $self->patron; - #my $dur_level = $self->duration_level; - #my $rec_level = $self->recurring_fines_level; - - my $dname = $duration->name; - my $mname = $max->name; - my $rname = $recurring->name; - - $logger->debug("circulator: building circulation ". - "with duration=$dname, maxfine=$mname, recurring=$rname"); - - #$circ->duration( $duration->shrt ) if ($dur_level == OILS_CIRC_DURATION_SHORT); - #$circ->duration( $duration->normal ) if ($dur_level == OILS_CIRC_DURATION_NORMAL); - #$circ->duration( $duration->extended ) if ($dur_level == OILS_CIRC_DURATION_EXTENDED); - - $circ->duration( $duration->shrt ) - if $copy->loan_duration == OILS_CIRC_DURATION_SHORT; - $circ->duration( $duration->normal ) - if $copy->loan_duration == OILS_CIRC_DURATION_NORMAL; - $circ->duration( $duration->extended ) - if $copy->loan_duration ==OILS_CIRC_DURATION_EXTENDED; - - $circ->recuring_fine( $recurring->low ) - if $copy->fine_level == OILS_REC_FINE_LEVEL_LOW; - $circ->recuring_fine( $recurring->normal ) - if $copy->fine_level == OILS_REC_FINE_LEVEL_NORMAL; - $circ->recuring_fine( $recurring->high ) - if $copy->fine_level == OILS_REC_FINE_LEVEL_HIGH; - - $circ->duration_rule( $duration->name ); - $circ->recuring_fine_rule( $recurring->name ); - $circ->max_fine_rule( $max->name ); - $circ->max_fine( $max->amount ); - - $circ->fine_interval($recurring->recurance_interval); - $circ->renewal_remaining( $duration->max_renewals ); + + if( $duration ) { + + my $dname = $duration->name; + my $mname = $max->name; + my $rname = $recurring->name; + + $logger->debug("circulator: building circulation ". + "with duration=$dname, maxfine=$mname, recurring=$rname"); + + $circ->duration( $duration->shrt ) + if $copy->loan_duration == OILS_CIRC_DURATION_SHORT; + $circ->duration( $duration->normal ) + if $copy->loan_duration == OILS_CIRC_DURATION_NORMAL; + $circ->duration( $duration->extended ) + if $copy->loan_duration == OILS_CIRC_DURATION_EXTENDED; + + $circ->recuring_fine( $recurring->low ) + if $copy->fine_level == OILS_REC_FINE_LEVEL_LOW; + $circ->recuring_fine( $recurring->normal ) + if $copy->fine_level == OILS_REC_FINE_LEVEL_NORMAL; + $circ->recuring_fine( $recurring->high ) + if $copy->fine_level == OILS_REC_FINE_LEVEL_HIGH; + + $circ->duration_rule( $duration->name ); + $circ->recuring_fine_rule( $recurring->name ); + $circ->max_fine_rule( $max->name ); + $circ->max_fine( $max->amount ); + + $circ->fine_interval($recurring->recurance_interval); + $circ->renewal_remaining( $duration->max_renewals ); + + } else { + + $logger->info("circulator: copy found with an unlimited circ duration"); + $circ->duration_rule(OILS_UNLIMITED_CIRC_DURATION); + $circ->recuring_fine_rule(OILS_UNLIMITED_CIRC_DURATION); + $circ->max_fine_rule(OILS_UNLIMITED_CIRC_DURATION); + $circ->renewal_remaining(0); + } + $circ->target_copy( $copy->id ); $circ->usr( $patron->id ); $circ->circ_lib( $self->circ_lib ); @@ -954,7 +968,6 @@ sub build_checkout_circ_object { $circ->circ_staff($self->editor->requestor->id); } - # if the user provided an overiding checkout time, # (e.g. the checkout really happened several hours ago), then # we apply that here. Does this need a perm?? @@ -963,7 +976,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) ); + $circ->due_date( $self->create_due_date($circ->duration) ) if $circ->duration; $self->circ($circ); } @@ -984,7 +997,7 @@ sub apply_modified_due_date { } else { # if the due_date lands on a day when the location is closed - return unless $copy; + return unless $copy and $circ->due_date; my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;