Skip to content

Added pan() and gstin() generators to en_IN provider#2357

Open
RedZapdos123 wants to merge 1 commit intojoke2k:masterfrom
RedZapdos123:fix/en-in-pan-gstin-2356
Open

Added pan() and gstin() generators to en_IN provider#2357
RedZapdos123 wants to merge 1 commit intojoke2k:masterfrom
RedZapdos123:fix/en-in-pan-gstin-2356

Conversation

@RedZapdos123
Copy link
Copy Markdown

@RedZapdos123 RedZapdos123 commented Apr 3, 2026

What does this change:

Adds pan() and gstin() generators to the en_IN SSN provider.

  • pan() now generates values matching ^[A-Z]{5}[0-9]{4}[A-Z]$.
  • gstin() now generates values matching ^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z][0-9A-Z]Z[0-9A-Z]$.
  • GSTIN checksum is generated using a base-36 checksum routine over the first 14 characters.
  • Adds tests for PAN format, GSTIN format, GSTIN checksum validation, and deterministic output under seeding.

What was wrong:

en_IN had aadhaar_id(), but did not provide pan() or gstin(), which are common IDs needed in India focused invoicing/compliance workflows.

How this solves it:

  • Extends faker.providers.ssn.en_IN.Provider with pan() and gstin() methods.
  • Adds calculate_gstin_checksum() helper in en_IN provider for checksum correctness.
  • Extends TestEnIn in tests/providers/test_ssn.py with repeated generation checks (100 samples), checksum checks, and seeded reproducibility checks.
  • Runs make lint (which updates stubs) so faker/proxy.pyi contains the new public methods.

Solves #2356

AI Assistance Disclosure:

  • No AI tools were used in preparing this PR.
  • If AI tools were used, I have disclosed which ones, and fully reviewed and verified their output.

AI tool used: GitHub Copilot (GPT-5.3-Codex), used to draft and apply code/test changes and PR text. All generated code and tests were manually reviewed and validated locally.

Checklist:

  • I have read the documentation about CONTRIBUTING
  • I have read the documentation about Coding style
  • I have run make lint

The screenshot of the SSN provider test suite for validation (run inside WSL):

image

Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
@RedZapdos123 RedZapdos123 changed the title Add pan() and gstin() generators to en_IN provider Added pan() and gstin() generators to en_IN provider Apr 3, 2026
@RedZapdos123
Copy link
Copy Markdown
Author

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.

2 participants