Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ru_RU SNILS generator #2150

Open
PetPython opened this issue Jan 15, 2025 · 2 comments · May be fixed by #2158
Open

Add ru_RU SNILS generator #2150

PetPython opened this issue Jan 15, 2025 · 2 comments · May be fixed by #2158

Comments

@PetPython
Copy link

PetPython commented Jan 15, 2025

Faker version: 33.3.1

Using faker for personal data generation, I discovered that there is no method to generate russian individual insurance account number (SNILS). Thus I would like to request and develop this feature. The algorithm is pretty simple: 9 random digits + 2 digits representing a checksum.

The checksum algorithm:

def calculate_snils_checksum(value: str) -> str:
    base_snils_length = 9
    check_sum = sum(int(value[i]) * (base_snils_length - i) for i in range(base_snils_length))

    if check_sum > 101:
        check_sum = check_sum % 101

    if check_sum < 100:
        check_sum = str(check_sum).zfill(2)
    else:
        check_sum = "00"

    return check_sum

, assuming you pass 9-digits-string as a value parameter.

@Pandede
Copy link
Contributor

Pandede commented Jan 21, 2025

Is that related to SSN (faker.providers.ssn)?

@PetPython
Copy link
Author

If I understand correctly, no. The Russian SNILS is not directly related to the SSN, since it serves different purpose and is unique to Russia’s social insurance system.

I thought it belongs more to faker.providers.company since there are already numbers like inn and ogrn for individuals.

@Pandede Pandede linked a pull request Jan 27, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants