hold CAP/FILL blocks : more event test collection repairs
authorBill Erickson <berick@esilibrary.com>
Thu, 21 Jun 2012 18:11:47 +0000 (14:11 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 24 Jul 2012 15:49:31 +0000 (11:49 -0400)
Further improving the logic which decides which patron permit events are
valid for a given set of circumstances.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index 8139155..262e0ba 100644 (file)
@@ -1104,23 +1104,26 @@ sub run_patron_permit_scripts {
             if ($self->is_noncat) {
                 # no_item result is OK during noncat checkout
                 @trimmed_results = grep { ($_->{fail_part} || '') ne 'no_item' } @$results;
+
             } else {
-                @trimmed_results = @$results;
-            }
 
-            if ($self->checkout_is_for_hold) {
-                # if this checkout will fulfill a hold, ignore CIRC blocks
-                # and rely instead on the (later-checked) FULFILL block
+                if ($self->checkout_is_for_hold) {
+                    # if this checkout will fulfill a hold, ignore CIRC blocks
+                    # and rely instead on the (later-checked) FULFILL block
 
-                my @pen_names = grep {$_} map {$_->{fail_part}} @$results;
-                my $fblock_pens = $self->editor->search_config_standing_penalty(
-                    {name => [@pen_names], block_list => {like => '%CIRC%'}});
+                    my @pen_names = grep {$_} map {$_->{fail_part}} @$results;
+                    my $fblock_pens = $self->editor->search_config_standing_penalty(
+                        {name => [@pen_names], block_list => {like => '%CIRC%'}});
+
+                    for my $res (@$results) {
+                        my $name = $res->{fail_part} || '';
+                        next if grep {$_->name eq $name} @$fblock_pens;
+                        push(@trimmed_results, $res);
+                    }
 
-                for my $res (@$results) {
-                    my $name = $res->{fail_part} || '';
-                    next if grep {$_->name eq $name} @$fblock_pens or 
-                        ($self->is_noncat and $name eq 'no_item');
-                    push(@trimmed_results, $res);
+                } else { 
+                    # not for hold or noncat
+                    @trimmed_results = @$results;
                 }
             }