Personal Identification Number provider for Norway (NO)#1681
Conversation
PR Summary
|
548510f to
3cce058
Compare
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1681 +/- ##
============================================
- Coverage 92.28% 92.28% -0.01%
- Complexity 3393 3410 +17
============================================
Files 333 334 +1
Lines 6714 6752 +38
Branches 666 670 +4
============================================
+ Hits 6196 6231 +35
- Misses 354 355 +1
- Partials 164 166 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pokebadgerswithspoon
left a comment
There was a problem hiding this comment.
Dead code, please remove
src/test/java/net/datafaker/idnumbers/NorwegianIdNumberTest.java
Outdated
Show resolved
Hide resolved
src/test/java/net/datafaker/idnumbers/NorwegianIdNumberTest.java
Outdated
Show resolved
Hide resolved
3cce058 to
937218f
Compare
519052b to
5186174
Compare
| * <li>born 1854-1899: allocated from series 749-500</li> | ||
| * <li>born 1900-1999: allocated from series 499-000</li> | ||
| * <li>born 1940-1999: also allocated from series 999-900</li> | ||
| * <li>born 2000-2039: allocated from series 999-500</li> | ||
| * </ul> | ||
| * | ||
| * @see <a href="https://www.oecd.org/content/dam/oecd/en/topics/policy-issue-focus/aeoi/norway-tin.pdf">TIN Structure</a> | ||
| */ | ||
| private int generateSequenceNumber(BaseProviders faker, int year) { | ||
| if (year >= 1854 && year <= 1899) { | ||
| return faker.random().nextInt(50, 74); | ||
| } else if (year >= 1940 && year <= 1999) { | ||
| return faker.random().nextInt(90, 99); | ||
| } else if (year >= 1900 && year <= 1999) { | ||
| return faker.random().nextInt(0, 49); | ||
| } else if (year >= 2000 && year <= 2039) { | ||
| return faker.random().nextInt(50, 99); |
There was a problem hiding this comment.
can you elaborate why javadoc and the doc (https://www.oecd.org/content/dam/oecd/en/topics/policy-issue-focus/aeoi/norway-tin.pdf) says
The three digits comprising the individual number are allocated sequentially within the
specific date of birth. Individual digits are allocated as follows
and this method returns 1 or 2 digits?
There was a problem hiding this comment.
I agree that it's a bit tricky to track :(
The point is that the third digit depends on the gender.
E.g. for year 1888, we pick a random number between 50 and 74, and append one more digit (the third digit) to it (even for women and odd for men).
instead of having CENTURIES Map of Intervals, just use the old good "if-else" :)
5186174 to
5381f17
Compare
This PR allows to generate a random national ID number for Norway: