Conversation
A GSTIN's 15th character is a check character computed over all 14 characters before it. Faker::Company.indian_gst_number computed it over the first 13 only, leaving out the fixed "Z" in position 14, so the generated numbers fail GSTIN validation.
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.
Motivation / Background
This Pull Request has been created because the numbers generated by
Faker::Company.indian_gst_numberdon't pass the GSTIN checksum. The 15th character is a check character computed over the 14 characters before it, but the generator only feeds it the state code, PAN and entity number (13 characters) and leaves out the fixedZin position 14.For example, the commonly cited real GSTIN
27AAPFU0939F1ZVvalidates with the standard algorithm (alternating weights 1/2, base 36, over the first 14 characters). Faker output like98EPAJT7470W1ZMgets a different check character from that algorithm (Nhere), so it fails any validator that checks the checksum.I found this while running Faker's checksum-carrying generators (IBAN, CPF/CNPJ, RUT, OIB, NIP, VIN, barcodes, ...) through independent validators. This was the only one with a wrong checksum.
Additional information
The fix adds
z_charto thecomputedblock's dependencies and includes it in the checksummed string. The new test recomputes the check character from the first 14 characters of a few generated numbers. It fails before the change and passes after.test_faker_company.rband RuboCop pass locally.#3327 also edits
indian_gst_number(the PAN digits and the test regex) but doesn't touch the checksum, so the two changes are independent.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]