Skip to content

Commit

Permalink
Merge pull request #27 from sanjiva/master
Browse files Browse the repository at this point in the history
Fix NIC size test issue
  • Loading branch information
sanjiva authored Aug 4, 2020
2 parents 82ec873 + 3ad947c commit 8a463be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions backend/src/services/electors.bal
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions datagen/src/datagen/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function createData() returns table<DBElector> {
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,
Expand Down

0 comments on commit 8a463be

Please sign in to comment.