From: Bill Erickson Date: Wed, 30 Sep 2015 14:12:53 +0000 (-0700) Subject: JBAS-886 day_phone capture improvements X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ecb255805656d6fe715218f97eea288acebb82c1;p=working%2FEvergreen.git JBAS-886 day_phone capture improvements Capture the day_phone value and don't treat invalid phones as an error condition preventing import of a student. If an invalid phone is encountered, treat it as unset. Signed-off-by: Bill Erickson --- diff --git a/KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl b/KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl index efec27020f..c692b5e787 100755 --- a/KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl +++ b/KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl @@ -359,13 +359,15 @@ sub translate_patron_fields { push(@errors, "Invalid dob") unless $phash->{dob} =~ m/^\d{4}-\d{2}-\d{2}$/; - if (my $dp = $phash->{day_phone}) { + # we cannot continue if errors have occured at this stage. + return @errors if @errors; - if ($dp =~ /^\(?\d{3}\)?-?\s*-?\s*$/) { - # if the day_phone only contains an area code, treat it as unset. - $dp = undef; + # day_phone is not required, but if it's set, + # it has to be in a format we can understand. + # If it's malformed, we treat it as unset. + if (my $dp = $phash->{day_phone}) { - } elsif ($dp =~ /^\(?(\d{3})\)?[- \.](\d{3})[- \.](\d{4})$/) { + if ($dp =~ /^\(?(\d{3})\)?[- \.](\d{3})[- \.](\d{4})$/) { # Supported phone formats: # XXX-YYY-ZZZZ / (XXX) YYY-ZZZZ / XXX.YYY.ZZZZ @@ -377,15 +379,11 @@ sub translate_patron_fields { $phash->{day_phone} = $dp; } else { - # Phone exists, is more than an area code, but is otherwise - # malformed. Kick it back for repairs. - push(@errors, "Invalid day_phone"); + # Phone exists, but is malformed. + $phash->{day_phone} = undef; } } - # we cannot continue if errors have occured at this stage. - return @errors if @errors; - # password uses the last 4 characters of the student ID, # unless a default password is set. $phash->{passwd} = $default_pass ? $default_pass : @@ -497,8 +495,6 @@ sub purge_patron { return 0; } - announce('DEBUG', "Purging user $bc with ID $user_id"); - eval { $db_handle->selectrow_array( "SELECT actor.usr_delete($user_id, NULL)"); @@ -541,8 +537,9 @@ sub prepare_patron_sql { family_name, expire_date, dob, + day_phone, email - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); SQL $create_addr_sth = $db_handle->prepare(<{family_name}, $phash->{expire_date}, $phash->{dob}, + $phash->{day_phone}, $phash->{email}, );