Skip to content
Snippets Groups Projects
Commit 22ef39c7 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-171: Having cutoff date for when to attempt suggestion

parent 3c0d3227
No related branches found
No related tags found
1 merge request!274GREG-171: Populating gender and birthdate with suggestions based on national ID
Pipeline #114712 failed
...@@ -240,11 +240,26 @@ export function isFemaleBasedOnNationalId(nationalId: string): boolean { ...@@ -240,11 +240,26 @@ export function isFemaleBasedOnNationalId(nationalId: string): boolean {
return parseInt(nationalId.charAt(8), 10) % 2 === 0 return parseInt(nationalId.charAt(8), 10) % 2 === 0
} }
/**
* The ID-number format is scheduled to change in the future:
* https://www.skatteetaten.no/deling/opplysninger/folkeregisteropplysninger/pid/
*
* Do not attempt a suggestion if we are at the time when the format will change.
*/
function shouldAttemptSuggestion(): boolean {
const currentYear = getYear(new Date())
// Keeping it simple, if this code is still running and should be revised.
// The new numbers are scheduled to appear in 2032
return currentYear <= 2031
}
export function extractGenderOrBlank(nationalId?: string): string { export function extractGenderOrBlank(nationalId?: string): string {
if ( if (
nationalId == null || nationalId == null ||
nationalId === '' || nationalId === '' ||
isValidFnr(nationalId) !== true isValidFnr(nationalId) !== true ||
!shouldAttemptSuggestion()
) { ) {
return '' return ''
} }
...@@ -300,7 +315,8 @@ export function extractBirthdateFromNationalId( ...@@ -300,7 +315,8 @@ export function extractBirthdateFromNationalId(
if ( if (
nationalId == null || nationalId == null ||
nationalId === '' || nationalId === '' ||
isValidFnr(nationalId) !== true isValidFnr(nationalId) !== true ||
!shouldAttemptSuggestion()
) { ) {
return null return null
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment