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

Validation issue for BG #31

Open
essamik opened this issue Mar 5, 2025 · 0 comments
Open

Validation issue for BG #31

essamik opened this issue Mar 5, 2025 · 0 comments

Comments

@essamik
Copy link

essamik commented Mar 5, 2025

Hi there,

I noticed an error on the checksum validation of BG VAT Numbers, take for example BG202320104. It works on the VIES VAT number validation
website:
Image

But on the library it fails when calling public static VatValidationResult IsValid(string vat)
Internally in BgVatValidator the checksum returns 9 instead of 11 or 10 and then it fails:

    private static VatValidationResult Validate9DigitVat(ReadOnlySpan<char> vatSpan)
    {
        var sum = vatSpan.Sum(MultipliersPhysicalPerson);

        var checkDigit = sum % 11;
        if (checkDigit == 10)
        {
            sum = 0;
            for (var index = 0; index < 8; index++)
            {
                sum += vatSpan[index].ToInt() * (index + 3);
            }
            checkDigit = sum % 11;
            if (checkDigit == 10)
            {
                checkDigit = 0;
            }
        }

Thanks

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

No branches or pull requests

1 participant