Back to ER Diagrams
Tax Configuration Logic

Tax Configuration Logic

Indian GST tax configuration, computation, and compliance engine for procurement transactions -- covering tax rates, grouping, exemptions, TDS, HSN/SAC mapping, and reverse charge mechanism.

3 Tables
GST Framework
Auto-Computation

1. Overview

The Tax Configuration module manages Indian GST tax configuration, computation, and compliance for all procurement transactions within ProKure. It handles automatic tax determination based on HSN/SAC codes, inter-state vs intra-state classification via GSTIN analysis, TDS deduction rules, exemption certificate management, and reverse charge mechanism applicability.

Key Capabilities

  • Automatic CGST/SGST vs IGST determination based on GSTIN state codes
  • HSN/SAC code to tax rate auto-mapping for goods and services
  • TDS computation with lower deduction certificate support
  • Exemption management for SEZ, Government, Diplomatic, MSME, and Export entities
  • Reverse charge mechanism auto-flagging for unregistered vendors
  • Financial year rate versioning with effective date ranges

2. Database Schema

config.tax_rates (master.taxes)

Master table of all tax rates including GST components, cess, and TDS sections. tax_type: GST | CGST | SGST | IGST | CESS | TDS. Rate is DECIMAL(5,2). Uses effective_from / effective_until for date-range versioning.

id (PK)
tax_code
tax_name
tax_type
rate
hsn_sac_code
effective_from
effective_until
is_active
created_at

config.tax_groups

Logical groupings of individual tax rates applied together (e.g. CGST 9% + SGST 9% = GST 18% intra-state). tax_ids is a UUID[] array referencing config.tax_rates. is_inter_state flags inter-state (IGST) vs intra-state (CGST+SGST).

id (PK)
group_name
group_code
description
tax_ids (UUID[])
is_inter_state
is_default
created_at

config.tax_exemptions

Exemption certificates for entities qualifying for zero-rated or reduced-rate taxation. exemption_type: SEZ | GOVERNMENT | DIPLOMATIC | MSME | EXPORT. entity_type: VENDOR | CUSTOMER | PRODUCT. exempted_taxes is JSONB. status: ACTIVE | EXPIRED | REVOKED.

id (PK)
exemption_type
entity_id
entity_type
certificate_number
valid_from
valid_until
exempted_taxes (JSONB)
approved_by (FK)
status
created_at

3. Indian Tax Structure (GST Framework)

Under the Indian GST regime, the applicable tax type depends on whether the transaction is intra-state or inter-state. This is determined by comparing the state codes embedded in the supplier GSTIN and buyer GSTIN (first two digits).

GST Tax Slabs

0%
Essential Goods
5%
Basic Necessities
12%
Standard Goods
18%
Most Services
28%
Luxury / Demerit
+Cess
Specific Goods

Intra-State vs Inter-State Determination

ScenarioConditionApplicable TaxExample
Intra-StateSupplier state code = Buyer state codeCGST + SGST (split equally)27AAACR5055K1Z5 to 27BBBCR1234K1Z8 (both MH = 27)
Inter-StateSupplier state code != Buyer state codeIGST (full rate)29AAACR5055K1Z5 (KA) to 27BBBCR1234K1Z8 (MH)

State Determination Decision Tree

  [Transaction Initiated]
           |
           v
  +-------------------------------+
  | Extract state codes from      |
  | supplier_gstin (first 2 dig)  |
  | buyer_gstin    (first 2 dig)  |
  +-------------------------------+
           |
           v
  +-------------------------------+
  | supplier_state = buyer_state? |
  +-------+--------------+-------+
          |              |
         YES             NO
          |              |
          v              v
  +-----------+    +-----------+
  |INTRA-STATE|    |INTER-STATE|
  | CGST = R/2|    | IGST = R  |
  | SGST = R/2|    |           |
  +-----------+    +-----------+
          |              |
          v              v
  +-------------------------------+
  | Apply Cess if applicable      |
  | (lookup by HSN code)          |
  +-------------------------------+
           |
           v
  [Tax amounts computed]

4. HSN/SAC Code Mapping

Every product or service is mapped to an HSN code (goods, 4-8 digits) or SAC code (services, 6 digits starting with 99). The system uses this code to automatically determine the applicable tax rate.

-- Auto-determine tax rate from product HSN code
SELECT tr.tax_code, tr.tax_name, tr.tax_type, tr.rate
FROM   config.tax_rates tr
WHERE  tr.hsn_sac_code = product.hsn_code
  AND  tr.is_active = TRUE
  AND  tr.effective_from <= CURRENT_DATE
  AND  (tr.effective_until IS NULL
       OR tr.effective_until >= CURRENT_DATE)
ORDER BY tr.effective_from DESC
LIMIT 1;

-- Service SAC code lookup (same pattern)
SELECT tr.tax_code, tr.rate
FROM   config.tax_rates tr
WHERE  tr.hsn_sac_code = service.sac_code
  AND  tr.is_active = TRUE
  AND  tr.effective_from <= invoice_date
  AND  (tr.effective_until IS NULL
       OR tr.effective_until >= invoice_date);

Fallback Behaviour

  • If no matching HSN/SAC code is found, the default tax group for the product category is applied
  • Products without an HSN code raise an alert; tax must be set manually with finance manager approval (BR-TAX-001)

5. TDS Integration

Tax Deducted at Source (TDS) is deducted from vendor payments based on transaction nature and vendor type. ProKure auto-computes TDS using columns on logistics.vendor_invoices (tds_section, tds_rate, tds_certificate_number).

TDS SectionNature of PaymentRate (Ind / Co)Threshold
194CContractors / Sub-contractors1% / 2%Single: 30K / Aggregate: 1L p.a.
194JProfessional / Technical fees10% / 10%30,000 p.a.
194QPurchase of goods0.1% / 0.1%50,00,000 p.a.
-- TDS computation logic
tds_amount = invoice_amount * tds_rate / 100

-- Lower deduction certificate handling
IF vendor.has_lower_tds_certificate = TRUE
   AND certificate.valid_until >= CURRENT_DATE
THEN
   effective_tds_rate = certificate.reduced_rate
ELSE
   effective_tds_rate = standard_tds_rate_for_section
END IF

-- Net payable to vendor
net_payable = invoice_amount - tds_amount

TDS Compliance Notes

  • TDS is deducted at credit to vendor account or at payment, whichever is earlier
  • Lower deduction certificates must be validated against TRACES portal before applying reduced rates
  • Aggregate threshold tracking is maintained per vendor per financial year

6. Tax Computation Logic

1

Determine Transaction Type

Compare supplier GSTIN state code (first 2 digits) with buyer GSTIN to classify as intra-state or inter-state.

2

Resolve Tax Rate per Line Item

Look up HSN/SAC code in config.tax_rates; select appropriate tax group (CGST+SGST or IGST) from config.tax_groups.

3

Check Exemptions

Query config.tax_exemptions for the vendor/product. If valid and active, apply zero-rate or reduced rate.

4

Compute Line-Level Tax and Aggregate

tax_amount = taxable_amount * rate / 100 per component. Sum all line-item taxes by component. Round to 2 decimal places per GST guidelines; add round-off adjustment line if needed.

-- Line-item tax computation
SELECT
    li.id AS line_item_id, li.taxable_amount, tr.tax_type, tr.rate,
    ROUND(li.taxable_amount * tr.rate / 100, 2) AS tax_amount
FROM   invoice_line_items li
JOIN   config.tax_groups  tg ON tg.id = li.tax_group_id
JOIN   config.tax_rates   tr ON tr.id = ANY(tg.tax_ids)
WHERE  li.invoice_id = :invoice_id AND tr.is_active = TRUE;

-- Invoice-level aggregation by tax type
SELECT
    tr.tax_type,
    SUM(ROUND(li.taxable_amount * tr.rate / 100, 2)) AS total_tax
FROM   invoice_line_items li
JOIN   config.tax_groups  tg ON tg.id = li.tax_group_id
JOIN   config.tax_rates   tr ON tr.id = ANY(tg.tax_ids)
WHERE  li.invoice_id = :invoice_id AND tr.is_active = TRUE
GROUP BY tr.tax_type;

-- Round-off adjustment: ROUND(total, 0) - total

7. Exemption Handling

TypeDescriptionTax TreatmentCertificate Required
SEZSpecial Economic Zone vendorsZero-rated supply; no GSTSEZ registration + LUT/Bond
GOVERNMENTGovernment entity purchasesSpecific exemptions per notificationGovernment order reference
DIPLOMATICDiplomatic missionsFull GST exemption on eligible goodsDiplomatic exemption certificate
MSMEMicro, Small, Medium EnterprisesComposition scheme / threshold exemptionsUdyam registration number
EXPORTExport transactionsZero-rated under LUT or IGST refundLUT filing / Export docs
-- Check if vendor has valid exemption
SELECT te.exemption_type, te.exempted_taxes, te.status
FROM   config.tax_exemptions te
WHERE  te.entity_id   = :vendor_id
  AND  te.entity_type = 'VENDOR'
  AND  te.status       = 'ACTIVE'
  AND  te.valid_from  <= CURRENT_DATE
  AND  te.valid_until >= CURRENT_DATE;

-- Valid: apply zero-rate for taxes in exempted_taxes JSONB
-- Expired: auto-update status to 'EXPIRED', apply standard rates

Expiry Tracking

  • A daily scheduled job flags exemptions expiring within 30 days
  • Notifications are sent to the vendor and finance team for certificate renewal
  • Expired certificates automatically revert the entity to standard taxation

8. Reverse Charge Mechanism (RCM)

Under RCM, the recipient (buyer) is liable to pay GST instead of the supplier. This applies to purchases from unregistered vendors and specific notified services under Section 9(3) of the CGST Act.

ScenarioConditionRCM Action
Unregistered vendorSupplier has no valid GSTINBuyer pays GST under RCM on full invoice value
Notified servicesServices under Section 9(3) CGST ActBuyer self-assesses and pays GST
Import of servicesServices from outside IndiaIGST payable by recipient under RCM
  [Vendor Invoice Received]
           |
           v
  +-------------------------------+
  | Vendor has valid GSTIN?       |
  +-------+--------------+-------+
         YES             NO ---------> [Flag as RCM; buyer pays GST]
          |
          v
  +-------------------------------+
  | Service under notified RCM    |
  | category (Sec 9(3))?          |
  +-------+--------------+-------+
         YES             NO
          |              |
          v              v
  +--------------+  +--------------+
  | Apply RCM    |  | Standard     |
  | (buyer pays  |  | treatment    |
  | despite GSTN)|  | (vendor pays)|
  +--------------+  +--------------+

Accounting Treatment under RCM

  • Buyer records GST liability (output tax) and claims ITC simultaneously; net cash impact is zero if fully claimable
  • RCM invoices are self-invoiced by buyer and reported in GSTR-3B
  • RCM liability must be paid in cash (cannot offset against ITC balance)

9. Financial Year Handling

Tax rates can change via GST Council notifications mid-year. The effective_from and effective_until columns on config.tax_rates enable accurate historical lookups and seamless rate transitions.

-- Mid-year rate change (e.g., GST on HSN 8471 from 18% to 12%)
-- Step 1: Close old rate record
UPDATE config.tax_rates
SET    effective_until = '2025-10-31'
WHERE  hsn_sac_code = '8471' AND rate = 18.00 AND effective_until IS NULL;

-- Step 2: Insert new rate record
INSERT INTO config.tax_rates (tax_code, tax_name, tax_type, rate, hsn_sac_code, effective_from, is_active)
VALUES ('GST12_8471', 'GST 12% - Computers', 'GST', 12.00, '8471', '2025-11-01', TRUE);

-- Historical lookup for a past invoice
SELECT tr.rate FROM config.tax_rates tr
WHERE  tr.hsn_sac_code = '8471'
  AND  tr.effective_from <= :invoice_date
  AND  (tr.effective_until IS NULL OR tr.effective_until >= :invoice_date)
  AND  tr.is_active = TRUE
ORDER BY tr.effective_from DESC LIMIT 1;

Key Principles

  • Old rate records are never deleted -- they are closed by setting effective_until
  • Invoice tax is always computed using the rate effective on the invoice date, not the current date
  • Credit notes and debit notes reference the original invoice date for rate lookup
  • Annual rate review is triggered at the start of each financial year (April 1)

10. Business Rules

Rule IDRule DescriptionEnforcement
BR-TAX-001 Tax is auto-applied based on HSN/SAC code. Manual override of the auto-determined rate requires Finance Manager approval. System blocks manual tax changes unless approved via workflow. Audit log records overrides with approver ID and justification.
BR-TAX-002 TDS deduction is mandatory for vendor payments exceeding the threshold for the applicable section (194C, 194J, 194Q). Aggregate thresholds tracked per vendor per FY. Payment processing blocked if TDS not computed. System auto-calculates TDS at invoice approval stage.
BR-TAX-003 Exemption certificates must be validated (status = ACTIVE, valid_until >= current date) before applying zero-rate taxation. System checks config.tax_exemptions at computation time. Expired or revoked certificates result in standard tax rates.
BR-TAX-004 Inter-state vs intra-state determination is automatic based on GSTIN first two digits. Manual classification is not permitted. GSTIN state code extraction is programmatic. Missing GSTIN flags transaction for manual finance review.

Compliance Considerations

  • GSTIN Validation: All GSTINs validated against GST portal API before acceptance
  • E-Invoice Mandate: Tax data transmitted to IRP for IRN generation above turnover threshold
  • Input Tax Credit: Accurate computation critical for ITC claims; GSTR-2A mismatches cause reversals
  • Audit Trail: Every computation, override, and exemption logged with timestamp and user ID

ProKure Database Documentation - Tax Configuration Logic v1.0

Part of the ProKure Procurement Management System