SIP2 Checkout "no-code" failure fix
authorThomas Berezansky <tsbere@mvlc.org>
Fri, 26 Aug 2011 20:19:13 +0000 (16:19 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 27 Oct 2011 13:13:39 +0000 (09:13 -0400)
Instead of assuming that code exists on a response do more checks.

Specifically, a response code can be empty but not zero when there is no
defined event code for the failure code.

An easily tested case of this is standing penalties.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm

index bcfdc3b..ab8d17a 100644 (file)
@@ -91,27 +91,27 @@ sub do_checkout {
 
         syslog('LOG_DEBUG', "OILS: $method returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp));
 
-        if (@$resp > 1 || $U->event_code($$resp[0])) {
+        my $first_code = $U->event_code($$resp[0]);
+        if (@$resp > 1 || !defined $first_code || $first_code ne '0') {
             # We got one or more non-success events
             $self->screen_msg('');
             for my $r (@$resp) {
-                if ( my $code = $U->event_code($r) ) {
-                    my $txt = $r->{textcode};
-                    syslog('LOG_INFO', "OILS: $method failed with event $code : $txt");
-
-                    if ($override_events{$txt} && $method !~ /override$/) {
-                        # Found an event we've been configured to override.
-                        $override = 1;
-                    } elsif ($txt =~ /ITEM_(?:DEPOSIT|RENTAL)_FEE_REQUIRED/ && $self->fee_ack) {
-                        # Patron acknowledged the fee.
-                        $override = 1;
-                    } elsif ( $txt eq 'OPEN_CIRCULATION_EXISTS' ) {
-                        $self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS);
-                        return 0;
-                    } else {
-                        $self->screen_msg(OILS_SIP_MSG_CIRC_PERMIT_FAILED);
-                        return 0;
-                    }
+                my $code = $U->event_code($r);
+                my $txt = $r->{textcode};
+                syslog('LOG_INFO', "OILS: $method failed with event $code : $txt");
+
+                if ($override_events{$txt} && $method !~ /override$/) {
+                    # Found an event we've been configured to override.
+                    $override = 1;
+                } elsif ($txt =~ /ITEM_(?:DEPOSIT|RENTAL)_FEE_REQUIRED/ && $self->fee_ack) {
+                    # Patron acknowledged the fee.
+                    $override = 1;
+                } elsif ( $txt eq 'OPEN_CIRCULATION_EXISTS' ) {
+                    $self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS);
+                    return 0;
+                } else {
+                    $self->screen_msg(OILS_SIP_MSG_CIRC_PERMIT_FAILED);
+                    return 0;
                 }
             }
             # This looks potentially dangerous, but we shouldn't