From: Jeff Godin Date: Mon, 23 Jul 2012 20:17:05 +0000 (-0400) Subject: Apply TADL-specific SIP patron barcode transforms X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=08899638bda74facecdde85610af1f5e37adb42a;p=evergreen%2Ftadl.git Apply TADL-specific SIP patron barcode transforms TADL has some SIP clients which are not capable of removing extra characters from some scanned patron barcodes. Thus, we handle that on the SIP server side. If no active card is found with the barcode provided in the SIP request, first see if it starts with an uppercase letter. If so, lowercase it, then determine if certain length requirements are met, and if so also truncate the value. Attempt to find an active card via the resulting value, and return the usual error if not found. Signed-off-by: Jeff Godin --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm index ac4f05c3b2..f07665b357 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm @@ -78,9 +78,24 @@ sub new { $$usr_flesh{flesh} += 1; $$usr_flesh{flesh_fields}{ac} = ['usr']; - my $card = $e->search_actor_card([{barcode => $patron_id}, $usr_flesh])->[0]; + my $card = $e->search_actor_card([{barcode => $patron_id, active => 't'}, $usr_flesh])->[0]; + + if(!$card) { + if ($patron_id =~ /^[A-Z].*/i) { + syslog("LOG_WARNING", "Trying lowercased/transformed value for barcode: $patron_id"); + my $bc = lc($patron_id); + my $bclen = length($bc); + if ($bclen == 25 || $bclen == 27) { + $bc = substr($bc, 0, 13); + } elsif ($bclen == 23) { + $bc = substr($bc, 0, 12); + } + $card = $e->search_actor_card([{barcode => $bc, active => 't'}, $usr_flesh])->[0]; + } + } + - if(!$card or !$U->is_true($card->active)) { + if(!$card) { syslog("LOG_WARNING", "No such patron barcode: $patron_id"); return undef; }