JBAS-886 student importer max expire date
authorBill Erickson <berickxx@gmail.com>
Thu, 24 Sep 2015 14:37:59 +0000 (07:37 -0700)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Avoid expire dates far in the future on invalid DoB's by assuming no
students are younger than 2 years old for the purposes of calculating
the expire date.

Note, this does not affect the stored DoB.  We store whatever is sent.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl

index 9b1734f..8330b7e 100755 (executable)
@@ -280,6 +280,12 @@ sub set_expire_date {
     my $now_year = DateTime->now->year;
     my $expire_year = $now_year + (18 - ($now_year - $year));
 
+    # Invalid DoB's can lead to expire_date's far in the future.
+    # If a student's birth year puts them at less than 2 years old,
+    # modify the year to make them appear 2 years old for calculating 
+    # the expire year.  We retain the provided day and month.
+    $expire_year = ($now_year + 16) if ($expire_year - $now_year) > 16;
+
     # if dob occurs after july 1, expire date will occur the following year.
     $expire_year++ if ($mon > 7) or ($mon == 7 and $day > 1);