Repository navigation
fix(bg/vat): accept 9-digit numbers whatever their first digit - #172
Open
kallehauge wants to merge 3 commits into
Open
kallehauge wants to merge 3 commits into
kallehauge wants to merge 3 commits into
Conversation
validate() refused any number not starting with 0, 1, 2, 3 or 9 with InvalidFormat, before the check digit was looked at. python-stdnum's bg/vat has never had that rule, and registered numbers fall outside it: BG831137001 is valid in the EU VIES service and was rejected.
BG831642181 belongs to Vivacom Bulgaria, one of the country's largest telecom operators, and is valid in the EU VIES service. It starts with 8, so it shows the same rejection with a well-known company.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bg/vatrejects registered Bulgarian VAT numbers whose first digit is not0,1,2,3or9. Vivacom Bulgaria, one of the country's largest telecom operators, is an example:BG831642181is a valid, registered VAT number. Its check digit is correct; validation stops at the first-digit rule before the check digit is computed.The numbers in this PR were checked in the EU VIES service before it was opened.
The official format has no first-digit rule
BGfollowed by its unified identification code (ЕИК).python-stdnum agrees: its
validate()checks the length, that the number is all digits, and the check digit, and no version ofstdnum/bg/vat.pysince 2012 has had a first-digit rule. python-stdnum 2.2 accepts831642181. The first-digit rule has been inbg/vat.tssince the module was added, with no source given.Fix
This PR removes the rule. The check digit still applies to every number.
BG831642181InvalidFormatBG831642182(wrong check digit)InvalidFormatInvalidChecksumBG175074752Tested
src/bg/vat.spec.ts: 2 new cases; they fail before the change and pass after it.TZ=UTC npx jest --runInBandpasses, 200 suites / 1637 tests.npm run lintpasses.