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

BE Vat Numbers should have a modulo 97 check and start wit 1 or 0 #2037

Closed
JorisSpruyt opened this issue May 1, 2024 · 3 comments · Fixed by #2038
Closed

BE Vat Numbers should have a modulo 97 check and start wit 1 or 0 #2037

JorisSpruyt opened this issue May 1, 2024 · 3 comments · Fixed by #2038

Comments

@JorisSpruyt
Copy link
Contributor

  • Faker version: 25
  • OS: OS. X Monterery

VAT Numbers generated in Belgium (currently set-up in the provider ssn for locale nl_BE should start with 1 or 0 and have a controle number with a module 97 check.

Refer to https://en.wikipedia.org/wiki/VAT_identification_number

Steps to reproduce

  1. Generate vat_id wit locale nl_BE

Expected behavior

Vat numbers should be starting with BE0 or BE1 and have a module 97 check as the last two numbers

@JorisSpruyt
Copy link
Contributor Author

JorisSpruyt commented May 1, 2024

Suggested re-write:

`
def vat_id(self) -> str:

    vat_id_random_section = (
        '#######'
    )

    vat_id_possible_initial_numbers = (
        '0',
        '1'
    )
    """
    http://ec.europa.eu/taxation_customs/vies/faq.html#item_11
    https://en.wikipedia.org/wiki/VAT_identification_number
    :return: A random Belgian VAT ID starting with 0 or 1 and has a correct checksum with a modulo 97 check
    """
    generated_initial_number = self.random_element(vat_id_possible_initial_numbers)
    vat_without_check = self.bothify(generated_initial_number + vat_id_random_section)
    vat_as_int = int(vat_without_check)
    vat_check = 97 - (vat_as_int % 97)
    vat_check_str = f"{vat_check:0>2}"

    return "BE" + vat_without_check + vat_check_str

`

@stefan6419846
Copy link
Contributor

You are of course invited to propose a corresponding PR to fix this issue.

JorisSpruyt pushed a commit to JorisSpruyt/faker that referenced this issue May 1, 2024
Updated Vat generation in locale nl_BE to align with correct Belgian format
@JorisSpruyt
Copy link
Contributor Author

Thanks @stefan6419846 , I was not sure about the workflow on github but I think i was able to do it.
#2038
This issue should be closed as duplicate or something?

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