my $return_date = DateTime->now(time_zone => 'local')->add(seconds => interval_to_seconds($return_interval))->iso8601();
+ # If we find a copy that matches our return date; this is a flag that we've
+ # already issued a recall notice
+ my $circs = [ action::circulation->search_where(
+ { target_copy => \@copy_ids, checkin_time => undef, due_date => { '=' => $return_date } },
+ { order_by => 'due_date ASC' }
+ )];
+ if (scalar(@$circs)) {
+ return;
+ }
+
# Iterate over the checked-out copies to find a copy with a
# loan period longer than the recall threshold:
- my $circs = [ action::circulation->search_where(
+ $circs = [ action::circulation->search_where(
{ target_copy => \@copy_ids, checkin_time => undef, duration => { '>' => $recall_threshold } },
{ order_by => 'due_date ASC' }
)];