feat: add rate-agnostic GST calculation utilities (#3)#5
Merged
Conversation
Adds a new pure, zero-dependency `gst.js` module with helper functions that most GST tools end up reimplementing: - calculateTax — tax + total at a given rate - calculateGSTBreakdown — CGST/SGST (intra) or IGST (inter) + cess - reverseCalculateTax — extract base + tax from inclusive total - getApplicableTaxType — IGST vs CGST_SGST from state codes - calculateInvoiceTotals — line-item invoice totals with round-off - groupItemsByTaxRate — GSTR-1 style grouping - applyRoundOffRules — 2-decimal half-up rounding All re-exported from index.js, fully typed in index.d.ts, documented in the README, and covered by 20 new tests (gst.js 100% coverage). The rate-lookup-from-HSN variant (calculateItemTax) is intentionally deferred — it depends on rate data being added to the dataset (#2). Refs #3 https://claude.ai/code/session_01V2bGsWhrzxeEpoV8BJyZMi
karthi-21
pushed a commit
that referenced
this pull request
Jun 3, 2026
Merged gst.js calculation utilities (from dev/PR #5) with all PR #6 features: GSTIN validation, SAC codes, export utils, CLI, advanced HSN lookups, and GST rate data. All 105 tests passing. https://claude.ai/code/session_01V2bGsWhrzxeEpoV8BJyZMi
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.
Summary
Implements the rate-agnostic portion of #3 — GST calculation/helper utilities that most developers end up writing themselves when building GST-compliant tools.
Adds a new pure, zero-dependency
gst.jsmodule:calculateTax(taxableAmount, rate)calculateGSTBreakdown(taxableAmount, gstRate, options?)reverseCalculateTax(grandTotal, rate)getApplicableTaxType(supplierState, placeOfSupply)IGSTvsCGST_SGSTfrom state codescalculateInvoiceTotals(items, isInterState)groupItemsByTaxRate(items)applyRoundOffRules(amount)All functions are re-exported from
index.js, fully typed inindex.d.ts, documented in the README, and covered by 20 new tests.What's intentionally deferred
calculateItemTax(item)from the issue — the variant that auto-looks-up the rate from an HSN code — depends on rate data being present in the dataset (#2). Once #2 lands, that becomes a thin wrapper overcalculateGSTBreakdown.Test plan
npm test→ 55 passing (35 existing + 20 new),gst.jsat 100% coverage2.1.0(additive, non-breaking)Refs #3
https://claude.ai/code/session_01V2bGsWhrzxeEpoV8BJyZMi
Generated by Claude Code