Skip to content

Include the "Z" in the Indian GST number check character - #3329

Open
kevin9327 wants to merge 1 commit into
faker-ruby:mainfrom
kevin9327:fix-indian-gst-checksum
Open

kevin9327 wants to merge 1 commit into
faker-ruby:mainfrom
kevin9327:fix-indian-gst-checksum

Conversation

@kevin9327

Copy link
Copy Markdown

Motivation / Background

This Pull Request has been created because the numbers generated by Faker::Company.indian_gst_number don'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 fixed Z in position 14.

For example, the commonly cited real GSTIN 27AAPFU0939F1ZV validates with the standard algorithm (alternating weights 1/2, base 36, over the first 14 characters). Faker output like 98EPAJT7470W1ZM gets a different check character from that algorithm (N here), 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_char to the computed block'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.rb and 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:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug, refactor something, or add a feature.
  • Tests and Rubocop are passing before submitting your proposed changes.

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.
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 this pull request may close these issues.

1 participant