From b224a95e9a977b8e5ad776bc27eeda95d207a90a Mon Sep 17 00:00:00 2001 From: Sanjiva Weerawarana Date: Tue, 4 Aug 2020 13:49:04 +0530 Subject: [PATCH] Fix NIC size --- backend/src/services/electors.bal | 4 ++-- datagen/src/datagen/main.bal | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/services/electors.bal b/backend/src/services/electors.bal index cfa9b49..dbecf50 100644 --- a/backend/src/services/electors.bal +++ b/backend/src/services/electors.bal @@ -66,13 +66,13 @@ function getVoterAge(string elector) returns @tainted int { } int current_year = 20; - int length_old_NIC = 9; + int length_old_NIC = 10; int length_new_NIC = 12; int yearOfBirth; int|error daysFromJan1; if nic.length() != length_old_NIC && nic.length() != length_new_NIC { - log:printError(string`Error: invalic NIC length: ${nic}`); + log:printError(string`Error: invalid NIC length: ${nic}`); return -1; } diff --git a/datagen/src/datagen/main.bal b/datagen/src/datagen/main.bal index fa1af90..75563c4 100644 --- a/datagen/src/datagen/main.bal +++ b/datagen/src/datagen/main.bal @@ -42,8 +42,8 @@ function createData() returns table { int yearOfBirth = checkpanic math:randomInRange(10, 93); // born from 1910 to 1992 (just for tests) int gender = checkpanic math:randomInRange(0,2); int dobdays = checkpanic math:randomInRange(1,366); - int seqNo = checkpanic math:randomInRange(1,1000); - string NIC = string`${yearOfBirth}${io:sprintf("%03d", gender == 0 ? dobdays : dobdays+500)}${io:sprintf("%03d",seqNo)}v`; + int seqNo = checkpanic math:randomInRange(1,10000); // technically 3 digit seq # + check digit but we don't worry + string NIC = string`${yearOfBirth}${io:sprintf("%03d", gender == 0 ? dobdays : dobdays+500)}${io:sprintf("%04d",seqNo)}v`; DBElector e = { YearOfRevision: "2019", DistrictID: 1,