From 08899638bda74facecdde85610af1f5e37adb42a Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Mon, 23 Jul 2012 16:17:05 -0400 Subject: [PATCH] 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 --- Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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; } -- 2.11.0