@mudraforge/statutory 2.8.1 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +8 -7
  3. package/SECURITY.md +2 -2
  4. package/calculators.d.ts +1 -0
  5. package/calculators.js +1 -0
  6. package/docs/CATALOG.md +258 -63
  7. package/docs/CORPUS_QUALITY.md +12 -7
  8. package/okf/corporate_ma_restructuring/loss_carryforward_sec79/circulars/cbdt_circular_09_2020_startup_loss_continuity.md +37 -0
  9. package/okf/corporate_ma_restructuring/loss_carryforward_sec79/forms/section_79_shareholding_continuity_schedule.json +51 -0
  10. package/okf/corporate_ma_restructuring/loss_carryforward_sec79/section.json +66 -0
  11. package/okf/direct_tax/corporate_tax_115baa_115jb/circulars/cbdt_circular_29_2019_concessional_tax_regime.md +35 -0
  12. package/okf/direct_tax/corporate_tax_115baa_115jb/forms/form_10ic_concessional_tax_election.json +31 -0
  13. package/okf/direct_tax/corporate_tax_115baa_115jb/section.json +72 -0
  14. package/okf/direct_tax/special_rates_non_filer_206ab/section.json +7 -6
  15. package/okf/indirect_tax_gst/export_services_lut_sec16/circulars/cbic_circular_161_2021_intermediary_clarification.md +37 -0
  16. package/okf/indirect_tax_gst/export_services_lut_sec16/forms/lut_form_gst_rfnd_11_declaration.json +58 -0
  17. package/okf/indirect_tax_gst/export_services_lut_sec16/section.json +66 -0
  18. package/okf/international_tax/foreign_exchange_indas_21_109/circulars/mca_indas_21_foreign_exchange_rates.md +39 -0
  19. package/okf/international_tax/foreign_exchange_indas_21_109/forms/indas_109_cash_flow_hedge_reserve_schedule.json +45 -0
  20. package/okf/international_tax/foreign_exchange_indas_21_109/section.json +63 -0
  21. package/okf/international_tax/transfer_pricing_alp_92c/circulars/cbdt_notification_86_2015_range_concept_rule_10ca.md +54 -0
  22. package/okf/international_tax/transfer_pricing_alp_92c/forms/form_3ceb_transfer_pricing_report.json +67 -0
  23. package/okf/international_tax/transfer_pricing_alp_92c/section.json +72 -0
  24. package/okf/manifest.json +33 -8
  25. package/package.json +31 -1
  26. package/src/calculators.js +780 -0
  27. package/src/index.js +145 -35
  28. package/types/index.d.ts +14 -0
package/src/index.js CHANGED
@@ -12,19 +12,31 @@ import fs from 'node:fs';
12
12
  import path from 'node:path';
13
13
  import os from 'node:os';
14
14
  import crypto from 'node:crypto';
15
+ import dns from 'node:dns';
15
16
  import { fileURLToPath } from 'node:url';
17
+ import {
18
+ roundToPaisa,
19
+ roundSection288B,
20
+ calculateCorporateTaxMatVsConcessional,
21
+ evaluatePlaceOfSupplyAndLut,
22
+ calculateTransferPricingAlp,
23
+ evaluateSection79LossContinuity,
24
+ revalueForeignExchangeIndAs109
25
+ } from './calculators.js';
16
26
 
17
27
  const __filename = fileURLToPath(import.meta.url);
18
28
  const __dirname = path.dirname(__filename);
19
29
  export const DEFAULT_LOCAL_OKF_DIR = path.resolve(__dirname, '..', 'okf');
20
30
  export const DEFAULT_BASE_URL = 'https://api.mudraforge.in';
21
- export const STATUTORY_CLIENT_VERSION = '2.8.1';
31
+ export const STATUTORY_CLIENT_VERSION = '2.9.0';
22
32
 
23
33
  /**
24
34
  * Pinned official release Merkle root digests.
25
35
  * Prevents unauthorized bundle substitution attacks even if an attacker controls the remote endpoint.
26
36
  */
27
37
  export const PINNED_RELEASE_ROOTS = new Set([
38
+ 'sha256-4bbe36c3db841b833dd2bebbd6c1c5ed735498e7b20d1221c323ceb211529fe0', // v2.9.0 Corporate Finance 5 Domains Merkle Root (29 Sections across 5 Domains)
39
+ 'sha256-3fb34bdcd34eec794b1f8e6abb2c0e0e87664746ec2f50ad2599c34bf57565b3', // v2.8.1 Finance Act, 2025 Section 206AB Sunset Root (24 Sections across 5 Domains)
28
40
  'sha256-239641de2bef05917673f693f9ba4d14bd5e137d64554fba5db87e426bc13e14', // v2.8.0 Deep Semantic Citation Merkle Root (24 Sections across 5 Domains)
29
41
  'sha256-6953ce79b63bb2a5809dc928178b4631f08448aa2dcde107dde10f84890bf5cb', // v2.7.0 Edge Sync Bundle Root (24 Sections across 5 Domains)
30
42
  'sha256-ce88c2255df1c30c15bfe184c8117336ebc302c2ac5ef25e96a6957402ae11ae', // v2.6.0 Verified Citation Merkle Root (24 Sections across 5 Domains - 100% Complete AP)
@@ -1514,17 +1526,24 @@ export class StatutoryClient {
1514
1526
  /**
1515
1527
  * @param {Object} [options]
1516
1528
  * @param {string} [options.apiKey] Enterprise API key (obtain from hello@mudraforge.in)
1517
- * @param {'PUBLIC_COMMONS_FREE' | 'ENTERPRISE_PAID'} [options.tier] Client subscription tier
1529
+ * @param {'PUBLIC_COMMONS_FREE' | 'ENTERPRISE_PAID'} [options.tier] Client-side telemetry tier hint. Note: Edge server authorizes and throttles strictly based on the Bearer token, ignoring client tier claims.
1518
1530
  * @param {string} [options.baseUrl] Custom edge base URL
1519
1531
  * @param {string} [options.okfDir] Path to local OKF directory
1520
1532
  * @param {boolean} [options.offlineFirst=true] Query local filesystem before hitting edge
1533
+ * @param {boolean} [options.preferIpv4=false] Opt-in preference for IPv4 DNS resolution (calls node:dns.setDefaultResultOrder('ipv4first')). Note: In Node.js this operates at process scope to resolve Windows IPv6 Anycast timeouts.
1521
1534
  */
1522
1535
  constructor(options = {}) {
1523
- this.apiKey = options.apiKey || process.env?.MUDRA_STATUTORY_API_KEY || null;
1536
+ this.apiKey = options.apiKey || (typeof process !== 'undefined' ? process.env?.MUDRA_STATUTORY_API_KEY : null) || null;
1524
1537
  this.tier = options.tier || (this.apiKey ? 'ENTERPRISE_PAID' : 'PUBLIC_COMMONS_FREE');
1525
- this.baseUrl = options.baseUrl || process.env?.MUDRA_STATUTORY_BASE_URL || DEFAULT_BASE_URL;
1538
+ this.baseUrl = options.baseUrl || (typeof process !== 'undefined' ? process.env?.MUDRA_STATUTORY_BASE_URL : null) || DEFAULT_BASE_URL;
1526
1539
  this.okfDir = options.okfDir || DEFAULT_LOCAL_OKF_DIR;
1527
1540
  this.offlineFirst = options.offlineFirst !== false;
1541
+ this.preferIpv4 = options.preferIpv4 === true || (typeof process !== 'undefined' && process.env?.MUDRA_STATUTORY_PREFER_IPV4 === '1');
1542
+ if (this.preferIpv4 && typeof dns?.setDefaultResultOrder === 'function') {
1543
+ try {
1544
+ dns.setDefaultResultOrder('ipv4first');
1545
+ } catch (_) {}
1546
+ }
1528
1547
  }
1529
1548
 
1530
1549
  /**
@@ -1594,18 +1613,38 @@ export class StatutoryClient {
1594
1613
  assertSecureEndpoint(this.baseUrl);
1595
1614
 
1596
1615
  const url = new URL('/api/v1/statutory/calculate', this.baseUrl);
1597
- const res = await fetch(url.toString(), {
1598
- method: 'POST',
1599
- headers: {
1600
- 'Content-Type': 'application/json',
1601
- 'Accept': 'application/json',
1602
- 'Authorization': `Bearer ${this.apiKey}`,
1603
- 'X-Mudra-Tier': this.tier,
1604
- 'User-Agent': `@mudraforge/statutory/${STATUTORY_CLIENT_VERSION} (${this.tier})`
1605
- },
1606
- body: JSON.stringify(payload),
1607
- signal: AbortSignal.timeout(options.timeoutMs || 20000)
1608
- });
1616
+ let res;
1617
+ try {
1618
+ res = await fetch(url.toString(), {
1619
+ method: 'POST',
1620
+ headers: {
1621
+ 'Content-Type': 'application/json',
1622
+ 'Accept': 'application/json',
1623
+ 'Authorization': `Bearer ${this.apiKey}`,
1624
+ 'X-Mudra-Tier': this.tier,
1625
+ 'User-Agent': `@mudraforge/statutory/${STATUTORY_CLIENT_VERSION} (${this.tier})`
1626
+ },
1627
+ body: JSON.stringify(payload),
1628
+ signal: AbortSignal.timeout(options.timeoutMs || 20000)
1629
+ });
1630
+ } catch (fetchErr) {
1631
+ const isTimeout = fetchErr.name === 'TimeoutError' ||
1632
+ fetchErr.code === 'UND_ERR_CONNECT_TIMEOUT' ||
1633
+ fetchErr.code === 'ETIMEDOUT' ||
1634
+ fetchErr.message?.includes('timeout') ||
1635
+ fetchErr.cause?.code === 'UND_ERR_CONNECT_TIMEOUT';
1636
+ if (isTimeout) {
1637
+ const timeoutErr = new Error(
1638
+ `[@mudraforge/statutory] Connection timeout reaching ${this.baseUrl}.\n` +
1639
+ `Diagnostic advice: On Windows environments, broken or unrouted IPv6 Anycast routing can cause connection timeouts to Cloudflare edge IPs.\n` +
1640
+ `To resolve, enable IPv4-first resolution on the client by passing { preferIpv4: true } to StatutoryClient or setting environment variable MUDRA_STATUTORY_PREFER_IPV4=1.`
1641
+ );
1642
+ timeoutErr.code = 'CONNECTION_TIMEOUT';
1643
+ timeoutErr.cause = fetchErr;
1644
+ throw timeoutErr;
1645
+ }
1646
+ throw fetchErr;
1647
+ }
1609
1648
 
1610
1649
  if (!res.ok) {
1611
1650
  const isJson = (res.headers.get('content-type') || '').toLowerCase().includes('application/json');
@@ -1676,6 +1715,41 @@ export class StatutoryClient {
1676
1715
  async doctor(options = {}) {
1677
1716
  return await runStatutoryDoctor(options);
1678
1717
  }
1718
+
1719
+ /**
1720
+ * Evaluate Corporate Tax: Normal MAT (Section 115JB) vs Concessional Regime (Section 115BAA).
1721
+ */
1722
+ calculateCorporateTaxMatVsConcessional(payload) {
1723
+ return calculateCorporateTaxMatVsConcessional(payload);
1724
+ }
1725
+
1726
+ /**
1727
+ * Evaluate Place of Supply (POS) & Zero-Rated Export of Services under LUT (IGST Sections 10, 12, 13, 16).
1728
+ */
1729
+ evaluatePlaceOfSupplyAndLut(payload) {
1730
+ return evaluatePlaceOfSupplyAndLut(payload);
1731
+ }
1732
+
1733
+ /**
1734
+ * Compute Transfer Pricing Arm's Length Price (ALP) under Section 92C & Rule 10CA.
1735
+ */
1736
+ calculateTransferPricingAlp(payload) {
1737
+ return calculateTransferPricingAlp(payload);
1738
+ }
1739
+
1740
+ /**
1741
+ * Evaluate Section 79 Loss Carry-Forward & Shareholding Continuity with unabsorbed depreciation protection.
1742
+ */
1743
+ evaluateSection79LossContinuity(payload) {
1744
+ return evaluateSection79LossContinuity(payload);
1745
+ }
1746
+
1747
+ /**
1748
+ * Revalue foreign exchange monetary items at closing spot rates under Ind AS 21 and Ind AS 109.
1749
+ */
1750
+ revalueForeignExchangeIndAs109(payload) {
1751
+ return revalueForeignExchangeIndAs109(payload);
1752
+ }
1679
1753
  }
1680
1754
 
1681
1755
  /**
@@ -2122,8 +2196,9 @@ export const STATUTORY_CROSSWALK_CATALOG = [
2122
2196
  aliases: ['195', 'sec195', 'section 195', '393(2)', 'foreign remittance tds', 'non resident tds']
2123
2197
  },
2124
2198
  {
2125
- id: 'CROSSWALK_206AB_397_3',
2199
+ id: 'CROSSWALK_206AB_SUNSET',
2126
2200
  domain: 'direct_tax',
2201
+ isOmittedSunset: true,
2127
2202
  predecessor: {
2128
2203
  act: 'Income-tax Act, 1961 (Act No. 43 of 1961)',
2129
2204
  sectionCode: '206AB',
@@ -2136,24 +2211,24 @@ export const STATUTORY_CROSSWALK_CATALOG = [
2136
2211
  returnForm: 'Form 26Q'
2137
2212
  },
2138
2213
  successor: {
2139
- act: 'Income-tax Act, 2025 (Act No. 1 of 2025)',
2140
- sectionCode: '397(3)',
2141
- statutorySection: 'Section 397(3)',
2142
- title: 'Higher withholding rates for non-filers of income-tax returns',
2143
- effectiveDate: '2026-04-01',
2144
- threshold: 'Aggregate TDS/TCS >= ₹50,000 in preceding FY and return not filed within due date',
2145
- standardRate: 'Higher of: 2x specified rate, 2x rates in force, or 5.0%',
2146
- penaltyRate: 'Higher rate applies automatically',
2147
- challan: 'Challan under Income-tax Act, 2025',
2148
- returnForm: 'Quarterly Statement of Tax Withholding (2025 Act Rules)'
2214
+ act: 'Finance Act, 2025 (Statutory Sunset & Omission)',
2215
+ sectionCode: '206AB [OMITTED]',
2216
+ statutorySection: 'Section 206AB Omitted',
2217
+ title: 'Formally omitted by Finance Act, 2025 effective 1 April 2025 (No higher rate for non-filers)',
2218
+ effectiveDate: '2025-04-01',
2219
+ threshold: 'N/A (Provision repealed; compliance check utility discontinued)',
2220
+ standardRate: '0.0%',
2221
+ penaltyRate: '0.0%',
2222
+ challan: 'N/A',
2223
+ returnForm: 'N/A'
2149
2224
  },
2150
- transitionCutoffDate: '2026-04-01',
2225
+ transitionCutoffDate: '2025-04-01',
2151
2226
  savingsAuthority: {
2152
- statute: 'Income-tax Act, 2025 Section 536 (Repeals and Savings)',
2153
- subsidiary: 'General Clauses Act, 1897 Section 6 (Effect of Repeal)',
2154
- legalPrinciple: 'Pre-April 1, 2026 non-filer verifications governed by Section 206AB compliance portal.'
2227
+ statute: 'Finance Act, 2025 Section 206AB Sunset Clause',
2228
+ subsidiary: 'General Clauses Act, 1897 Section 6',
2229
+ legalPrinciple: 'Deductions on or before 31 March 2025 remain assessable under Section 206AB. Deductions on or after 1 April 2025 attract ZERO non-filer penalty rate; standard statutory rates apply. Higher rates under Section 206AA for invalid/inoperative PAN remain independent and fully active at 20%.'
2155
2230
  },
2156
- aliases: ['206ab', 'sec206ab', 'section 206ab', '397(3)', 'non filer higher tds']
2231
+ aliases: ['206ab', 'sec206ab', 'section 206ab', 'non filer higher tds', '206ab sunset', 'non filer sunset']
2157
2232
  },
2158
2233
  {
2159
2234
  id: 'CROSSWALK_206C_1H_SUNSET',
@@ -2367,17 +2442,25 @@ export function crosswalkStatute(sectionCode, options = {}) {
2367
2442
  let isOmitted = Boolean(entry.isOmittedSunset);
2368
2443
 
2369
2444
  if (entry.isOmittedSunset) {
2370
- // e.g. 206C(1H)
2445
+ // e.g. 206C(1H), 206AB
2371
2446
  if (triggerDate < cutoff) {
2372
2447
  governingAct = entry.predecessor.act;
2373
2448
  applicableSection = entry.predecessor.statutorySection;
2374
2449
  temporalStatus = 'GOVERNED_BY_1961_ACT';
2375
- legalAnalysis = `Trigger event crystallized on ${triggerDate} (prior to 1 April 2025 sunset). Governed by ${entry.predecessor.statutorySection} of the ${entry.predecessor.act}. Seller was obligated to collect 0.1% TCS on receipts exceeding ₹50 Lakhs unless buyer was liable and deducted TDS u/s 194Q.`;
2450
+ if (entry.predecessor.sectionCode === '206AB') {
2451
+ legalAnalysis = `Trigger event crystallized on ${triggerDate} (prior to 1 April 2025 sunset). Governed by Section 206AB of the Income-tax Act, 1961. Higher withholding rate (twice applicable rate or 5%) applied to non-filer specified persons.`;
2452
+ } else {
2453
+ legalAnalysis = `Trigger event crystallized on ${triggerDate} (prior to 1 April 2025 sunset). Governed by ${entry.predecessor.statutorySection} of the ${entry.predecessor.act}. Seller was obligated to collect 0.1% TCS on receipts exceeding ₹50 Lakhs unless buyer was liable and deducted TDS u/s 194Q.`;
2454
+ }
2376
2455
  } else {
2377
2456
  governingAct = entry.successor.act;
2378
2457
  applicableSection = entry.successor.statutorySection;
2379
2458
  temporalStatus = 'SUNSET_OMITTED';
2380
- legalAnalysis = `Section 206C(1H) was formally omitted by the Finance Act, 2025 w.e.f. 1 April 2025 to eliminate double-compliance overlap. No seller TCS liability attaches to transactions on or after 1 April 2025. Tax withholding on sale of goods is governed exclusively by buyer TDS under Section 194Q / Section 393.`;
2459
+ if (entry.predecessor.sectionCode === '206AB') {
2460
+ legalAnalysis = `Section 206AB was formally omitted by the Finance Act, 2025 w.e.f. 1 April 2025. No non-filer punitive TDS rate applies on or after 1 April 2025; standard statutory TDS rates apply. Higher rates under Section 206AA for missing/inoperative PAN remain independent and fully active at 20%.`;
2461
+ } else {
2462
+ legalAnalysis = `Section 206C(1H) was formally omitted by the Finance Act, 2025 w.e.f. 1 April 2025 to eliminate double-compliance overlap. No seller TCS liability attaches to transactions on or after 1 April 2025. Tax withholding on sale of goods is governed exclusively by buyer TDS under Section 194Q / Section 393.`;
2463
+ }
2381
2464
  }
2382
2465
  } else {
2383
2466
  // Standard transition to 2025 Act
@@ -2489,6 +2572,21 @@ export const STATUTORY_AMENDMENTS_CHANGELOG = [
2489
2572
  statutoryImpact: 'Payers must verify non-filer status using the Compliance Check functionality on the Income Tax Portal.',
2490
2573
  aliases: ['206ab', 'non filer']
2491
2574
  },
2575
+ {
2576
+ id: 'DIFF-2025-04-01-206AB',
2577
+ sectionCode: '206AB',
2578
+ domain: 'direct_tax',
2579
+ title: 'Statutory Sunset & Omission of Section 206AB Higher Non-Filer TDS',
2580
+ effectiveDate: '2025-04-01',
2581
+ amendmentType: 'STATUTORY_OMISSION',
2582
+ statute: 'Finance Act, 2025',
2583
+ legalAuthority: 'Finance Act, 2025 (Section 206AB Sunset Clause)',
2584
+ previousValue: 'Higher TDS rate (higher of 2x specified rate, 2x rates in force, or 5%) for non-filers',
2585
+ amendedValue: 'OMITTED (Section 206AB repealed; standard TDS rates apply without non-filer penalty)',
2586
+ changeSummary: 'Finance Act, 2025 formally omitted Section 206AB and Section 206CCA effective 1 April 2025 to relieve deductors from non-filer compliance checks.',
2587
+ statutoryImpact: 'Tax deductors are no longer required to run portal compliance checks for specified persons; standard statutory rates apply. Higher rates under Section 206AA for invalid/inoperative PAN remain active.',
2588
+ aliases: ['206ab', 'non filer sunset', '206ab omitted']
2589
+ },
2492
2590
  {
2493
2591
  id: 'DIFF-2022-07-01-194R',
2494
2592
  sectionCode: '194R',
@@ -2646,4 +2744,16 @@ export function getStatutoryDiff(options = {}) {
2646
2744
  };
2647
2745
  }
2648
2746
 
2747
+ // ── Deterministic Zero-Dependency Statutory Calculators Export ──────────────
2748
+ export {
2749
+ roundToPaisa,
2750
+ roundSection288B,
2751
+ calculateCorporateTaxMatVsConcessional,
2752
+ evaluatePlaceOfSupplyAndLut,
2753
+ calculateTransferPricingAlp,
2754
+ evaluateSection79LossContinuity,
2755
+ revalueForeignExchangeIndAs109
2756
+ };
2757
+
2758
+
2649
2759
 
package/types/index.d.ts CHANGED
@@ -193,6 +193,11 @@ export declare class StatutoryClient {
193
193
  diff(options?: StatutoryDiffOptions): StatutoryDiffResult;
194
194
  verify(targetDir?: string): any;
195
195
  doctor(options?: any): Promise<any>;
196
+ calculateCorporateTaxMatVsConcessional(payload?: any): any;
197
+ evaluatePlaceOfSupplyAndLut(payload?: any): any;
198
+ calculateTransferPricingAlp(payload?: any): any;
199
+ evaluateSection79LossContinuity(payload?: any): any;
200
+ revalueForeignExchangeIndAs109(payload?: any): any;
196
201
  }
197
202
 
198
203
  export interface CrosswalkOptions {
@@ -315,3 +320,12 @@ export declare const PAN_ENTITY_TYPES: Record<string, { code: string; name: stri
315
320
  export declare function isValidGstinChecksum(gstin: string): boolean;
316
321
  export declare function decodeTaxIdentifier(rawId: string): TaxIdentifierResult;
317
322
 
323
+ export declare function roundToPaisa(amount: number | string): number;
324
+ export declare function roundSection288B(amount: number | string): number;
325
+ export declare function calculateCorporateTaxMatVsConcessional(payload?: any): any;
326
+ export declare function evaluatePlaceOfSupplyAndLut(payload?: any): any;
327
+ export declare function calculateTransferPricingAlp(payload?: any): any;
328
+ export declare function evaluateSection79LossContinuity(payload?: any): any;
329
+ export declare function revalueForeignExchangeIndAs109(payload?: any): any;
330
+
331
+