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);
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 );
$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??
# 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);
}
} 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;