@mudraforge/statutory 2.11.0 → 2.12.1
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.
- package/CHANGELOG.md +155 -1
- package/CONTRIBUTING.md +2 -2
- package/README.md +1 -1
- package/SECURITY.md +2 -2
- package/SKILL.md +1 -1
- package/bin/cli.js +288 -27
- package/docs/ACCOUNTING_ASSURANCE_AUDIT_DOSSIER.md +276 -0
- package/docs/ARCHITECTURE.md +6 -6
- package/docs/CASE_01_FORM_TEXT.txt +48 -0
- package/docs/CATALOG.md +405 -39
- package/docs/CA_PILOT_BENCHMARK_CASES.md +282 -0
- package/docs/CORPUS_QUALITY.md +31 -22
- package/docs/DOMAIN_BREADTH_AND_DEPTH_COMPARISON.md +1 -1
- package/okf/corporate_ma_restructuring/business_combinations_indas_103/circulars/mca_notification_indas_103_business_combinations.md +41 -0
- package/okf/corporate_ma_restructuring/business_combinations_indas_103/forms/purchase_price_allocation_schedule.json +110 -0
- package/okf/corporate_ma_restructuring/business_combinations_indas_103/section.json +65 -0
- package/okf/corporate_ma_restructuring/impairment_of_assets_indas_36/circulars/mca_notification_indas_36_impairment.md +45 -0
- package/okf/corporate_ma_restructuring/impairment_of_assets_indas_36/forms/cgu_impairment_testing_register.json +53 -0
- package/okf/corporate_ma_restructuring/impairment_of_assets_indas_36/section.json +61 -0
- package/okf/corporate_ma_restructuring/share_based_payments_indas_102/circulars/icai_guidance_share_based_payments.md +37 -0
- package/okf/corporate_ma_restructuring/share_based_payments_indas_102/forms/esop_graded_vesting_amortization_schedule.json +49 -0
- package/okf/corporate_ma_restructuring/share_based_payments_indas_102/section.json +60 -0
- package/okf/direct_tax/income_taxes_deferred_tax_indas_12/circulars/mca_notification_indas_12_income_taxes.md +40 -0
- package/okf/direct_tax/income_taxes_deferred_tax_indas_12/forms/deferred_tax_asset_liability_reconciliation_schedule.json +46 -0
- package/okf/direct_tax/income_taxes_deferred_tax_indas_12/section.json +61 -0
- package/okf/direct_tax/tds_commission_194h/section.json +5 -4
- package/okf/direct_tax/tds_contractor_194c/section.json +3 -3
- package/okf/direct_tax/tds_ecommerce_194o/section.json +3 -3
- package/okf/direct_tax/tds_goods_194q/circulars/cbdt_circular_13_2021_guidelines.md +2 -2
- package/okf/direct_tax/tds_goods_194q/section.json +9 -3
- package/okf/direct_tax/tds_goods_393/section.json +6 -4
- package/okf/direct_tax/tds_individual_contract_194m/section.json +3 -3
- package/okf/direct_tax/tds_interest_194a/section.json +7 -4
- package/okf/direct_tax/tds_perquisites_194r/section.json +1 -1
- package/okf/direct_tax/tds_property_194ia/section.json +3 -3
- package/okf/direct_tax/tds_rent_194i/section.json +5 -4
- package/okf/direct_tax/tds_rent_individual_194ib/section.json +2 -2
- package/okf/direct_tax/tds_services_194j/circulars/cbdt_circular_03_2020_fts_rate_cut.md +1 -1
- package/okf/direct_tax/tds_services_194j/section.json +10 -3
- package/okf/indirect_tax_gst/common_itc_reversal_rule42_43/circulars/cbic_circular_170_2022_itc_reporting.md +30 -0
- package/okf/indirect_tax_gst/common_itc_reversal_rule42_43/circulars/cbic_notification_18_2022_cutoff_amendment.md +26 -0
- package/okf/indirect_tax_gst/common_itc_reversal_rule42_43/forms/gstr_3b_table_4b1_reversal_schedule.json +101 -0
- package/okf/indirect_tax_gst/common_itc_reversal_rule42_43/forms/rule_42_43_annual_reconciliation_worksheet.json +87 -0
- package/okf/indirect_tax_gst/common_itc_reversal_rule42_43/section.json +65 -0
- package/okf/indirect_tax_gst/itc_reversal_rule37_37a/circulars/cbic_circular_192_2023_ecl_interest_calculation.md +36 -0
- package/okf/indirect_tax_gst/itc_reversal_rule37_37a/section.json +8 -1
- package/okf/indirect_tax_gst/rcm_liability_sec9_3/circulars/cbic_notification_07_2025_composition_rent_exclusion.md +41 -0
- package/okf/indirect_tax_gst/rcm_liability_sec9_3/circulars/cbic_notification_09_2024_renting_rcm.md +37 -0
- package/okf/indirect_tax_gst/rcm_liability_sec9_3/circulars/gst_council_55th_meeting_renting_rcm_regularization.md +31 -0
- package/okf/indirect_tax_gst/rcm_liability_sec9_3/section.json +24 -2
- package/okf/international_tax/financial_instruments_ecl_indas_109/circulars/mca_notification_indas_109_financial_instruments.md +43 -0
- package/okf/international_tax/financial_instruments_ecl_indas_109/forms/indas_109_ecl_provision_matrix_schedule.json +43 -0
- package/okf/international_tax/financial_instruments_ecl_indas_109/section.json +62 -0
- package/okf/manifest.json +71 -20
- package/okf/msme_commercial/lease_accounting_indas_116/circulars/mca_notification_indas_116_leases.md +48 -0
- package/okf/msme_commercial/lease_accounting_indas_116/forms/lease_rou_asset_and_liability_schedule.json +55 -0
- package/okf/msme_commercial/lease_accounting_indas_116/section.json +67 -0
- package/okf/msme_commercial/provisions_contingencies_indas_37/circulars/mca_notification_indas_37_provisions.md +36 -0
- package/okf/msme_commercial/provisions_contingencies_indas_37/forms/provisions_and_contingent_liabilities_register.json +38 -0
- package/okf/msme_commercial/provisions_contingencies_indas_37/section.json +61 -0
- package/okf/msme_commercial/revenue_recognition_indas_115/circulars/mca_notification_indas_115_revenue_contracts.md +56 -0
- package/okf/msme_commercial/revenue_recognition_indas_115/forms/revenue_contract_5step_allocation_schedule.json +54 -0
- package/okf/msme_commercial/revenue_recognition_indas_115/section.json +69 -0
- package/package.json +7 -1
- package/src/calculators.js +2195 -260
- package/src/constants.js +1 -1
- package/src/index.js +407 -23
- package/src/tally.js +812 -0
- package/src/zoho_gstr2b.js +2964 -0
- package/types/index.d.ts +476 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,163 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
## [2.
|
|
10
|
+
## [2.12.1] - 2026-11-06
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Statutory Identity Migration to Official Income-tax Act, 2025 Architecture**:
|
|
14
|
+
- Migrated colloquial Section 393 table shorthand (Table 8, Table 6, Table 5, Table 4, Table 3) to canonical enacted references under **Section 393(1), Table 1, Serial Numbers (Sl. Nos.)** for payments to residents:
|
|
15
|
+
- Section 194H $\to$ Section 393(1), Table 1, Sl. No. 1(ii) (Commission or brokerage).
|
|
16
|
+
- Section 194-I $\to$ Section 393(1), Table 1, Sl. No. 2 (Rent).
|
|
17
|
+
- Section 194-IB $\to$ Section 393(1), Table 1, Sl. No. 2(iii) (Rent by Individuals/HUF).
|
|
18
|
+
- Section 194-IA $\to$ Section 393(1), Table 1, Sl. No. 3(i) (Immovable property).
|
|
19
|
+
- Section 194A $\to$ Section 393(1), Table 1, Sl. No. 5(ii) & 5(iii) (Interest).
|
|
20
|
+
- Section 194C $\to$ Section 393(1), Table 1, Sl. No. 6(i) (Works contracts).
|
|
21
|
+
- Section 194J $\to$ Section 393(1), Table 1, Sl. No. 6(iii) (Fees for professional or technical services).
|
|
22
|
+
- Section 194-O $\to$ Section 393(1), Table 1, Sl. No. 8(i) (E-commerce).
|
|
23
|
+
- Section 194Q $\to$ Section 393(1), Table 1, Sl. No. 8(ii) (Purchase of goods).
|
|
24
|
+
- Section 194R $\to$ Section 393(1), Table 1, Sl. No. 8(iv) (Business perquisites).
|
|
25
|
+
- Section 194M $\to$ Section 393(1), Table 1, Sl. No. 6(i) / 6(iii) / 1(ii) (Specified individual contracts).
|
|
26
|
+
- Maintained backward-compatible aliases (such as `393(1)(table 8)(ii)`, `393(1)(table 6)`) for seamless query resolution.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- **Date-Effective Statutory Threshold Logic (Income-tax Act, 2025 Transition)**:
|
|
30
|
+
- Commission (194H): ₹15,000 (pre-1 April 2026) $\to$ ₹20,000 (post-1 April 2026).
|
|
31
|
+
- Professional/Technical Fees (194J): ₹30,000 (pre-1 April 2026) $\to$ ₹50,000 (post-1 April 2026); Director remuneration maintains strict ₹0 threshold under both Acts.
|
|
32
|
+
- Rent (194-I): ₹2,40,000 annual aggregate (1961 Act) $\to$ ₹50,000 per month or part thereof (2025 Act).
|
|
33
|
+
- Interest (194A): Commercial ₹5,000 $\to$ ₹10,000; Banking ₹40,000 $\to$ ₹50,000; Senior citizen bank deposits ₹50,000 $\to$ ₹1,00,000.
|
|
34
|
+
- Strict statutory excess math enforced across all thresholds (`cumulative > threshold`; exact equality is exempt).
|
|
35
|
+
|
|
36
|
+
## [2.12.0] - 2026-11-01
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
- **Corporate Finance, Accounting & Reporting Knowledge Expansion (8 New OKF Provisions & 9 Calculators)**:
|
|
40
|
+
- *Ind AS 103 / IFRS 3 / ASC 805 Business Combinations & Purchase Price Allocation (PPA)* (`corporate_ma_restructuring/business_combinations_indas_103`):
|
|
41
|
+
- Full purchase price allocation (PPA), net identifiable assets measurement at fair value, deferred tax liability (DTL) derivation on acquired intangibles, contingent consideration recognition at acquisition-date fair value.
|
|
42
|
+
- Deterministic Goodwill vs. Capital Reserve (bargain purchase) derivation with balanced double-entry vouchers.
|
|
43
|
+
- Pure calculator `calculateBusinessCombinationsIndAs103(params)`.
|
|
44
|
+
- *Ind AS 36 / IAS 36 / ASC 360 Impairment of Assets & Cash-Generating Units (CGUs)* (`corporate_ma_restructuring/impairment_of_assets_indas_36`):
|
|
45
|
+
- Recoverable amount derivation comparing Fair Value Less Costs of Disposal (FVLCD) vs. Value in Use (VIU) via Discounted Cash Flow (DCF).
|
|
46
|
+
- Sequential impairment loss allocation: Goodwill reduced to zero first, then remaining impairment apportioned pro-rata across tangible/intangible assets without breaching statutory individual asset floors (FVLCD, VIU, or zero).
|
|
47
|
+
- Pure calculator `calculateImpairmentIndAs36(params)`.
|
|
48
|
+
- *Ind AS 102 / IFRS 2 / ASC 718 Share-Based Payment (ESOP) Graded Vesting Amortization* (`corporate_ma_restructuring/share_based_payments_indas_102`):
|
|
49
|
+
- Graded vesting separate tranche mechanics (front-loaded expense profile per ICAI/MCA guidance), forfeiture rate revisions, and true-up adjustments.
|
|
50
|
+
- Indian tax deductibility analysis under the Supreme Court *Biocon Ltd.* landmark doctrine (Section 37(1) general business deduction vs. capital transaction).
|
|
51
|
+
- Pure calculator `calculateEsopAmortizationIndAs102(params)`.
|
|
52
|
+
- *Ind AS 12 / IAS 12 / ASC 740 Income Taxes & Deferred Tax Accounting* (`direct_tax/income_taxes_deferred_tax_indas_12`):
|
|
53
|
+
- Balance sheet liability method computing temporary differences between accounting carrying amounts and tax bases (e.g., Section 43B(h) MSME disallowances, Ind AS 109 ECL allowances, Section 32 accelerated depreciation).
|
|
54
|
+
- Numerical Effective Tax Rate (ETR) reconciliation across statutory rate, permanent differences, and prior period adjustments.
|
|
55
|
+
- Pure calculator `calculateDeferredTaxIndAs12(params)`.
|
|
56
|
+
- *Ind AS 115 / IFRS 15 / ASC 606 Revenue from Contracts with Customers* (`msme_commercial/revenue_recognition_indas_115`):
|
|
57
|
+
- 5-step revenue recognition framework: identifying enforceable contracts, distinct performance obligations, transaction price determination (including variable consideration constraints), relative Standalone Selling Price (SSP) allocation, and satisfaction timing (Point-in-Time vs. Over-Time using input/output methods).
|
|
58
|
+
- Contract Asset (unbilled revenue) vs. Contract Liability (unearned revenue) balance sheet derivation.
|
|
59
|
+
- Pure calculator `calculateRevenueAllocationIndAs115(params)`.
|
|
60
|
+
- *Ind AS 116 / IFRS 16 / ASC 842 Leases & Right-of-Use (ROU) Asset Accounting* (`msme_commercial/lease_accounting_indas_116`):
|
|
61
|
+
- Incremental Borrowing Rate (IBR) discounting for initial lease liability and ROU asset capitalization (including lease prepayments, initial direct costs, and dismantling/restoration asset retirement obligations).
|
|
62
|
+
- Subsequent amortization tracking front-loaded Year 1 P&L expenses (depreciation + finance charge) versus straight-line operating lease rent.
|
|
63
|
+
- Short-term (<12 months) and low-value (<$5,000 / ₹4,00,000) practical expedients evaluation.
|
|
64
|
+
- Pure calculator `calculateLeaseAmortizationIndAs116(params)`.
|
|
65
|
+
- *Ind AS 37 / IAS 37 / ASC 450 Provisions, Contingent Liabilities & Contingent Assets* (`msme_commercial/provisions_contingencies_indas_37`):
|
|
66
|
+
- Present obligation from past obligating events (legal or constructive), probable outflow (>50% probability threshold requiring balance sheet provisioning), possible obligation (5% to 50% threshold requiring footnote disclosure in notes to accounts), and remote likelihood (<5% threshold requiring zero disclosure).
|
|
67
|
+
- Best estimate valuation (expected value probabilistic weighting vs. single most likely outcome) and discounting for long-term decommissioning/restoration provisions.
|
|
68
|
+
- Pure calculator `evaluateProvisionsAndContingenciesIndAs37(params)`.
|
|
69
|
+
- *Ind AS 109 / IFRS 9 / ASC 326 Financial Instruments — Expected Credit Loss (ECL)* (`international_tax/financial_instruments_ecl_indas_109`):
|
|
70
|
+
- 3-stage forward-looking impairment model: Stage 1 (12-month ECL for performing loans/receivables), Stage 2 (Lifetime ECL upon Significant Increase in Credit Risk - SICR / 30+ DPD), and Stage 3 (Lifetime ECL for credit-impaired assets / 90+ DPD).
|
|
71
|
+
- Provision matrix simplification for trade receivables under Ind AS 109 paragraph 5.5.15 with forward-looking macroeconomic stress adjustments (GDP growth, interest rate shifts).
|
|
72
|
+
- Tax add-back mapping under Section 36(1)(vii) / Section 36(1)(viia) and deferred tax asset recognition under Ind AS 12.
|
|
73
|
+
- Pure calculator `calculateExpectedCreditLossIndAs109(params)`.
|
|
74
|
+
- *Ind AS 21 / IAS 21 / ASC 830 The Effects of Changes in Foreign Exchange Rates* (`international_tax/foreign_currency_indas_21`):
|
|
75
|
+
- Monetary vs. non-monetary asset/liability distinction, closing rate revaluation, transactional gain/loss P&L routing, and foreign operations functional-to-presentation currency translation reserve (OCI Foreign Currency Translation Reserve - FCTR).
|
|
76
|
+
- Pure calculator `calculateForeignCurrencyIndAs21(params)`.
|
|
77
|
+
- *StatutoryClient Parity & Invariant Envelope*:
|
|
78
|
+
- All 9 accounting and reporting calculators bound to `StatutoryClient.prototype`.
|
|
79
|
+
- Strict `isAuthorizedToDisburse: false` invariant enforced across every engine output.
|
|
80
|
+
- Comprehensive TypeScript type definitions in `types/index.d.ts`.
|
|
81
|
+
- **Open Knowledge Format (OKF v0.2) Corpus Growth**:
|
|
82
|
+
- Sections expanded from 38 to 46 sections across 5 canonical domains.
|
|
83
|
+
- Authoritative circulars expanded from 44 to 52 instruments with strict YAML frontmatter.
|
|
84
|
+
- Compliance forms and registers expanded from 39 to 47 templates.
|
|
85
|
+
- Deep canonical citation links expanded from 154 to 180 verified endpoints (100% link integrity, zero broken links).
|
|
86
|
+
- Test suites expanded from 155 to 165 comprehensive test suites with 100% pass rate.
|
|
87
|
+
|
|
88
|
+
## [2.11.0] - 2026-10-30
|
|
11
89
|
|
|
12
90
|
### Added
|
|
91
|
+
- **55th GST Council Intervening Commercial Rent Regularization ("As Is Where Is")**:
|
|
92
|
+
- *Statutory Codification* (`indirect_tax_gst/rcm_liability_sec9_3`): Codified 55th GST Council Meeting Recommendations (21 December 2024, Jaisalmer) regularizing past commercial property renting transactions under reverse charge for Section 10 composition taxpayers during the intervening window (10 October 2024 to 15 January 2025) on an "as is where is" basis.
|
|
93
|
+
- *Disposition `RCM_COMPOSITION_INTERVENING_REGULARIZED_PAID`*: If RCM tax was historically discharged in cash, the tax is permanently regularized with zero refund rights and booked as an expense under Section 10(4).
|
|
94
|
+
- *Disposition `RCM_COMPOSITION_INTERVENING_REGULARIZED_UNPAID`*: If RCM tax was not discharged, statutory authorities cannot initiate retrospective recovery, demand notices, or penal proceedings; full consideration is expensed with zero RCM tax payable.
|
|
95
|
+
- *Failsafe Uncertainty Routing*: Intervening bills with indeterminate or unverified cash payment status route to `REQUIRES_HUMAN_VERIFICATION` (`INDETERMINATE_INTERVENING_RCM_DISCHARGE`).
|
|
96
|
+
- **Notification No. 07/2025-CT(Rate) Composition Taxpayer Rent Exclusion**:
|
|
97
|
+
- *Entry 5AB Prospective Amendment* (w.e.f. 16 January 2025): Excludes composition taxpayers under Section 10 from reverse charge liability on commercial immovable property renting (`COMPOSITION_EXCLUDED_RCM_SUPPLY`).
|
|
98
|
+
- **CBIC Circular No. 192/04/2023-GST Head-Wise ECL Utilization Rules**:
|
|
99
|
+
- *Aggregate Pool for Wrongly Availed IGST*: Clarifies Section 49(5) cross-utilization rules for Rule 88B(3) interest on unreversed ITC. IGST credit is tested against the aggregate pool of `IGST + CGST + SGST` balances. If the combined balance never falls below unreversed IGST credit, zero interest attaches under Section 50(3) even if standalone IGST balance falls to zero.
|
|
100
|
+
- *Restricted Cross-Utilization for CGST & SGST*: CGST credit is tested against `CGST + IGST` (SGST is not cross-utilizable). SGST credit is tested against `SGST + IGST` (CGST is not cross-utilizable).
|
|
101
|
+
- *Strict Exclusion of Compensation Cess*: Compensation Cess balances in the Electronic Credit Ledger are strictly excluded from general ITC balance computations.
|
|
102
|
+
- **Cumulative Multi-Invoice Portfolio Rule 88B(3) ECL Stress-Testing**:
|
|
103
|
+
- *Portfolio Pooling*: Pools overdue exposure across multiple concurrent bills, tracking overlapping start dates, separate reversal dates, and temporary dip-recovery cycles.
|
|
104
|
+
- *Same-Day Movement Coalescing*: Multiple credit and debit entries on the same date are accurately coalesced to the net daily closing balance.
|
|
105
|
+
- **Regulatory Watchtower Expansion (9 Benchmarks & 154 Citations)**:
|
|
106
|
+
- Added Benchmark 8: `GST_RCM_COMMERCIAL_RENT_INTERVENING_REGULARIZATION` (55th GST Council meeting).
|
|
107
|
+
- Added Benchmark 9: `GST_RULE_88B3_CIRCULAR_192_ECL_UTILIZATION` (Circular No. 192/04/2023-GST).
|
|
108
|
+
- Validated all 38 sections, 44 circulars, 39 forms, and 154 deep canonical citations with zero errors.
|
|
109
|
+
- Pinned Merkle Root: `sha256-a94baf08cbdea064a7b1bd25c1e1311821bf75e9b0d15cc8e0648339d487c79b`.
|
|
110
|
+
- **Regulatory Watchtower & Continuous Empanelment Freshness Attestation (`scripts/watchtower.js`)**:
|
|
111
|
+
- *Automated Compliance Surveillance Engine*: Scans and attests the entire Open Knowledge Format (OKF v0.2) substrate across all 38 statutory sections, 41 executive circulars, 39 compliance forms, and 148 deep canonical citations.
|
|
112
|
+
- *Regulatory Freshness Horizon Audit*: Evaluates active compliance against 6 statutory benchmarks:
|
|
113
|
+
1. October 2024 Commercial Renting RCM: CBIC Notification No. 09/2024-CT(Rate) Entry 5AB.
|
|
114
|
+
2. Retrospective Section 16(5)/16(6) ITC Relief: Finance (No. 2) Act, 2024.
|
|
115
|
+
3. October 2024 Section 194H 2% Rate Reduction: Finance (No. 2) Act, 2024.
|
|
116
|
+
4. April 2025 Section 206C(1H) Goods TCS Sunset: Finance Act, 2025.
|
|
117
|
+
5. April 2025 Section 206AB Non-Filer Omission: Finance Act, 2025 Clause 61.
|
|
118
|
+
6. April 2026 Dual-Act Transition: Income-tax Act, 1961 vs Income-tax Act, 2025 Section 393.
|
|
119
|
+
- *Empanelment Freshness Certificate Generation*: Produces cryptographic, machine-readable `MF-CERT-...` attestation with 100.0% empanelment score and strict `isAuthorizedToDisburse: false` invariant enforcement.
|
|
120
|
+
- *CLI & Programmatic Integration*: Added `npx @mudraforge/statutory watchtower [--json]`, `npm run watchtower`, and `StatutoryClient.prototype.runWatchtower()`.
|
|
121
|
+
- **Commercial Property Renting RCM Engine (Notification No. 09/2024-CT(Rate) w.e.f. 10 October 2024)**:
|
|
122
|
+
- *Entry 5AB Implementation* (`indirect_tax_gst/rcm_liability_sec9_3`): Full statutory codification of reverse charge on commercial immovable property renting by unregistered suppliers to registered persons.
|
|
123
|
+
- *Auto-Classification in Zoho AP Reconciliation*: Bills for office/commercial rent from unregistered landlords are automatically classified as `isCommercialRentRcm: true` and `isRcm: true`.
|
|
124
|
+
- *Exemption from Section 16(2)(aa) GSTR-2B Matching*: Unregistered RCM supplies are classified as `RCM_UNREGISTERED_SUPPLIER_ELIGIBLE` with `itcStatus: ELIGIBLE_RCM_TABLE_4A3`, eliminating erroneous "missing in 2B" false flags.
|
|
125
|
+
- *Compliance Directives*: Mandates Self-Invoice under Section 31(3)(f), Payment Voucher under Section 31(3)(g), cash tax discharge under GSTR-3B Table 3.1(d), and credit availment under Table 4(A)(3).
|
|
126
|
+
- **Zoho Books & GST Portal Form GSTR-2B Automated AP Reconciliation Engine**:
|
|
127
|
+
- *Automated 2-Way Accounts Payable Matching*: Ingests Zoho Books Bills CSV/API JSON and GST Portal Form GSTR-2B JSON (B2B invoices + CDNR credit/debit notes) with deterministic invoice number canonicalization (resolving slash, hyphen, space, and leading zero variations) and integer-paise arithmetic.
|
|
128
|
+
- *Decoupled 4-Way Jurisdictional Decisions*: Replaces monolithic eligibility flags with 4 orthogonal, discrete decisions per transaction:
|
|
129
|
+
1. `taxClassification`: `INTRASTATE_CORRECT`, `INTERSTATE_CORRECT`, `ERRONEOUS_INTRASTATE_LEVY`, `ERRONEOUS_INTERSTATE_LEVY`, `INDETERMINATE`.
|
|
130
|
+
2. `recipientJurisdiction`: `FILING_GSTIN_MATCHES_POS`, `REGISTERED_DISTINCT_PERSON_BRANCH`, `UNREGISTERED_IN_POS_STATE`, `INDETERMINATE`.
|
|
131
|
+
3. `itcEligibility`: `ELIGIBLE_NORMAL`, `ELIGIBLE_IN_BRANCH_RETURN`, `INELIGIBLE_STRANDED_LOCAL_LEVY`, `INELIGIBLE_BLOCKED_SEC_17_5`, `INELIGIBLE_DEFECTIVE_INVOICE`, `INELIGIBLE_PORTAL_FLAGGED`, `PROVISIONAL_PENDING_FILING`, `INDETERMINATE`.
|
|
132
|
+
4. `operationalRouting`: `CLAIM_IN_CURRENT_GSTR3B_TABLE_4A5`, `ROUTE_TO_BRANCH_GSTIN`, `BOOK_AS_EXPENSE_NO_ITC`, `REPORT_IN_GSTR3B_TABLE_4B1_PERMANENT_REVERSAL`, `REQUEST_VENDOR_CREDIT_NOTE_AMENDMENT`, `WITHHOLD_CLAIM_PENDING_SUPPLIER_GSTR1`, `PHYSICAL_GOODS_RECEIPT_VERIFICATION_PENDING`, `MANUAL_HUMAN_INVESTIGATION_REQUIRED`.
|
|
133
|
+
- *Epistemic Uncertainty Routing (`REQUIRES_HUMAN_VERIFICATION`)*: Engine refuses to manufacture false certainty on incomplete evidence. Fails open to human auditor review with explicit `uncertaintyReason`:
|
|
134
|
+
- `INVALID_SUPPLIER_GSTIN_CHECKSUM`: Failed ISO Mod-36 checksum validation.
|
|
135
|
+
- `AMBIGUOUS_DUPLICATE_INVOICE_MATCH`: Multiple candidate records sharing identical supplier GSTIN and invoice number.
|
|
136
|
+
- `CONTRADICTORY_TAX_SPLIT`: Concurrent CGST/SGST and IGST on the same voucher.
|
|
137
|
+
- `MISSING_POS_DATA`: Missing or indeterminate place-of-supply information.
|
|
138
|
+
- *Rule 37 Payment Appropriation Policies*: Implements Section 16(2) second proviso read with Rule 37(1) supporting `PROPORTIONATE` (default statutory baseline), `VALUE_FIRST`, and `TAX_FIRST` payment allocation policies. Exempts Reverse Charge (RCM) and Schedule I deemed supplies.
|
|
139
|
+
- *Rule 88B(3) Electronic Credit Ledger (ECL) Utilization Audit*: Section 50(1) 18% delayed interest is audited against minimum daily ECL closing balances (`minimumEclBalanceInr`). Applies 0% interest if ECL balance exceeded unreversed ITC throughout the default window per Rule 88B(3) Proviso; applies interest strictly to the dipped/utilized portion.
|
|
140
|
+
- *Executive Markdown Memorandum Generator*: Generates an audit-ready memorandum with an ITC health matrix, actionable AP exceptions register, and statutory assurance invariants.
|
|
141
|
+
- *CLI Command Integration*: Added `npx @mudraforge/statutory reconcile-gstr2b --zoho <file> --gstr2b <file> [--report-out <path>] [--json]` to CLI.
|
|
142
|
+
- *StatutoryClient Parity*: Added programmatic methods `parseZohoBillsCsv`, `parseZohoBillsJson`, `parseGstr2bJson`, `reconcileZohoGstr2b`, `generateGstr2bAuditMarkdownReport`, `normalizeInvoiceNumber`, and `normalizeGstin` with full TypeScript declarations in `types/index.d.ts`.
|
|
143
|
+
- **Accounting Contracts, Numeric Input Resilience & Integer-Paise Precision Hardening**:
|
|
144
|
+
- *4-State Numeric Classification*: `cleanNumericAmount` cleanly classifies inputs into missing optional (default), missing mandatory (throws `MissingMandatoryParameterError`), malformed numeric (throws `MalformedNumericInputError` in strict mode), and valid zero (`0`, `"0"`, `"₹ 0.00"`).
|
|
145
|
+
- *Accounting-Aware Credit (`CR`) Handling*: Preserves positive credit balances by default; only negates when `{ interpretCreditAsNegative: true }` is explicitly provided.
|
|
146
|
+
- *Safe Integer Boundary & Sub-Paisa Rules*: Enforces `Number.MAX_SAFE_INTEGER` (₹90,071,992,547,409.91 limit) across all monetary conversions and half-up rounding on fractional paise.
|
|
147
|
+
- *Accounting Format Tolerance*: Parses parentheses accounting negatives (`(₹ 50,000.00)`), trailing minuses (`50,000.00-`), and currencies outside parentheses (`INR (25,000)`).
|
|
148
|
+
- *Daybook Dual-Column Ingestion*: Full support for dual debit/credit columns, Particulars headers, and RFC 4180 quoted strings in `parseTallyDaybookCsv`.
|
|
149
|
+
- **GST Rule 42 & Rule 43 Common Input Tax Credit (ITC) Reversal Engine**:
|
|
150
|
+
- *Indirect Tax GST Domain* (`indirect_tax_gst/common_itc_reversal_rule42_43`): Authoritative implementation of Section 17(1) and Section 17(2) of the CGST Act, 2017 read with Rule 42 (inputs & input services) and Rule 43 (capital goods).
|
|
151
|
+
- *Rule 42 Monthly Ineligible Credit Segregation*: Segregation of gross ITC ($T$) into specific ineligibles ($T_1$ non-business, $T_2$ exempt, $T_3$ blocked u/s 17(5)), Electronic Credit Ledger credited balance ($C_1$), specific eligible credit ($T_4$ taxable/zero-rated exports), and Common Credit ($C_2$).
|
|
152
|
+
- *Monthly Turnover Apportionment ($D_1$ & $D_2$)*: Deterministic computation of exempt ratio ($E/F$), exempt reversal ($D_1 = (E/F) \times C_2$), non-business 5% reversal ($D_2 = 0.05 \times C_2$), remaining eligible common credit ($C_3$), and net eligible credit ($G = T_4 + C_3$). Includes preceding tax period turnover fallback proviso where current period turnover is zero.
|
|
153
|
+
- *Mandatory GSTR-3B Table 4(B)(1) Mapping*: Strict enforcement of CBIC Circular No. 170/02/2022-GST reporting permanent non-reclaimable reversals ($T_{\text{ineligible}} + D_1 + D_2$) in Table 4(B)(1) with zero netting-off against Table 4(A).
|
|
154
|
+
- *Rule 42(2) Annual True-Up Reconciliation Engine*: Complete reconciliation of aggregate financial year common credit ($C_2^{\text{annual}}$) against cumulative monthly reversals made in Table 4(B)(1) before the statutory cutoff date of 30th November (Finance Act, 2022 read with Notification No. 18/2022-Central Tax).
|
|
155
|
+
- *Section 50(1) 18% Statutory Interest Engine*: Automatic computation of 18% annual interest on short-reversals from 1st April of the succeeding financial year up to the true-up filing date.
|
|
156
|
+
- *Excess Reversal Reclaim Mechanism*: Taxpayer entitlement to reclaim excess provisional reversals in Form GSTR-3B Table 4(A)(5) with disclosure in Table 4(D)(1) before 30th November.
|
|
157
|
+
- *Rule 43 Capital Goods 60-Month Useful Life Amortisation*: Asset-level tracking over 60 statutory months, monthly credit slices ($T_m = T_c / 60$), aggregate monthly common slice ($T_r = \sum T_m$), and monthly exempt reversal ($T_e = (E/F) \times T_r$) added to output tax liability in Table 4(B)(1).
|
|
158
|
+
- *Asset Conversion Reductions*: 5% per quarter credit reduction under Rule 43(1)(c) for capital goods converted from exclusive exempt/non-business use to common business use.
|
|
159
|
+
- *Pure Deterministic Calculators (`src/calculators.js`)*:
|
|
160
|
+
- `calculateRule42InputServiceReversal(params)`
|
|
161
|
+
- `reconcileRule42AnnualTrueUp(params)`
|
|
162
|
+
- `calculateRule43CapitalGoodsReversal(params)`
|
|
163
|
+
- `calculateGstItcApportionmentRule42_43(params)` (backward-compatible orchestrator)
|
|
164
|
+
- *StatutoryClient Parity*: Exposed client helper methods (`client.calculateRule42InputServiceReversal`, `client.reconcileRule42AnnualTrueUp`, `client.calculateRule43CapitalGoodsReversal`, `client.calculateGstItcApportionmentRule42_43`) with full TypeScript declarations in `types/index.d.ts`.
|
|
165
|
+
- *Corpus Metrics*: OKF corpus expanded to 38 sections, 40 circulars, 39 forms across 5 canonical domains with 100% citation link integrity (146/146 verified) and 0 schema defects.
|
|
166
|
+
- *Merkle Trust Root*: Recomputed root digest `sha256-2e402bb02fe71939c79b9f11ad737d20faac21daf8e27417cb13ec1933511c19` pinned in `PINNED_RELEASE_ROOTS`.
|
|
13
167
|
- **Immovable Property Acquisition & Real Estate Withholding (Section 194-IA & Form 26QB)**:
|
|
14
168
|
- *Direct Tax Domain* (`direct_tax/tds_property_194ia`): Section 194-IA TDS on transfer of immovable property other than agricultural land with 1.0% withholding rate on HIGHER of contractual consideration or Stamp Duty Value (SDV) pursuant to Finance Act, 2022.
|
|
15
169
|
- *Incidental Charges Scope*: Full inclusion of club membership fees, car parking allotments, electricity/water facility charges, and maintenance advance payments per Finance Act, 2019 Explanation.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -42,13 +42,13 @@ Every `section.json` must provide these required fields:
|
|
|
42
42
|
"governingStatute": "Income-tax Act, 1961 (Act No. 43 of 1961)",
|
|
43
43
|
"statutorySection": "Section 194Q",
|
|
44
44
|
"successorStatute": "Income-tax Act, 2025",
|
|
45
|
-
"successorSection": "Section 393(1), Table
|
|
45
|
+
"successorSection": "Section 393(1), Table 1, Sl. No. 8(ii)",
|
|
46
46
|
"title": "Deduction of tax at source on payment of a certain sum for purchase of goods",
|
|
47
47
|
"effectivePeriod": {
|
|
48
48
|
"validFrom": "2021-07-01",
|
|
49
49
|
"validTo": "2026-03-31",
|
|
50
50
|
"annualReset": "Every April 1 (Cumulative Purchases Reset Annually)",
|
|
51
|
-
"sunsetNotes": "Transitions to Section 393(1) Table 8(ii) of the Income-tax Act, 2025 effective 1 April 2026."
|
|
51
|
+
"sunsetNotes": "Transitions to Section 393(1), Table 1, Sl. No. 8(ii) of the Income-tax Act, 2025 effective 1 April 2026."
|
|
52
52
|
},
|
|
53
53
|
"plainTextSummary": "Plain English summary explaining who must deduct, when, and on what base.",
|
|
54
54
|
"keyStatutoryThresholds": {
|
package/README.md
CHANGED
|
@@ -232,7 +232,7 @@ The OKF substrate currently indexes and enforces ground truth across five major
|
|
|
232
232
|
- **Section 194J**: Fees for Technical Services (2% FTS) vs. Professional Fees (10%), enforcing standard 20% non-PAN penalty rate under Section 206AA(1)(iii) / Section 397(2)(a).
|
|
233
233
|
- **Section 194I**: Rent withholding (2% plant & machinery, 10% land & building) exceeding ₹2.4 Lakhs annual threshold.
|
|
234
234
|
- **Section 194H**: Commission and brokerage withholding (2% amended rate w.e.f. 1 October 2024) exceeding ₹15,000 threshold.
|
|
235
|
-
- **Dual-Act Forward Mapping**: Complete cross-compilation bridge from the legacy *Income-tax Act, 1961* to the *Income-tax Act, 2025* (which took effect 1 April 2026), mapping historical provisions seamlessly (e.g., Section 194Q $\rightarrow$ Section 393(1), Table
|
|
235
|
+
- **Dual-Act Forward Mapping**: Complete cross-compilation bridge from the legacy *Income-tax Act, 1961* to the *Income-tax Act, 2025* (which took effect 1 April 2026), mapping historical provisions seamlessly (e.g., Section 194Q $\rightarrow$ Section 393(1), Table 1, Sl. No. 8(ii)).
|
|
236
236
|
|
|
237
237
|
### 2. Indirect Tax (Goods & Services Tax - GST)
|
|
238
238
|
- **CGST Section 8**: Composite and mixed supplies—naturally bundled supplies taxed at the principal supply rate under Section 8(a); unbundled supplies billed for a single price taxed at the highest rate under Section 8(b).
|
package/SECURITY.md
CHANGED
|
@@ -12,8 +12,8 @@ Only the current major release series receives active updates and statutory amen
|
|
|
12
12
|
|
|
13
13
|
| Version | Supported | Statutory Epistemic Baseline |
|
|
14
14
|
|---|---|---|
|
|
15
|
-
| `2.
|
|
16
|
-
| `< 2.
|
|
15
|
+
| `2.11.x` | Yes | Finance Act, 2025 & CBDT/CBIC Circulars up to October 2026 |
|
|
16
|
+
| `< 2.11.0` | No | Prior releases (upgrade via `npm install @mudraforge/statutory@latest`) |
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
package/SKILL.md
CHANGED
|
@@ -60,7 +60,7 @@ In accordance with our commercial boundary protocol (Rule 17):
|
|
|
60
60
|
|
|
61
61
|
2. **Always Enforce the Temporal Boundary**:
|
|
62
62
|
- **Section 206C(1H) (Seller TCS on Goods)**: Formally omitted and **SUNSET on 1 April 2025** by the Finance Act, 2025. For any transaction on or after 1 April 2025, seller TCS ceases; withholding tax applies conditionally via buyer TDS under Section 194Q only if the buyer independently crosses the statutory threshold (> ₹10Cr turnover, > ₹50L purchases).
|
|
63
|
-
- **Section 194Q (Buyer TDS on Goods)**: Enacted under the Income-tax Act, 1961. Transitions to **Section 393(1), Table
|
|
63
|
+
- **Section 194Q (Buyer TDS on Goods)**: Enacted under the Income-tax Act, 1961. Transitions to **Section 393(1), Table 1, Sl. No. 8(ii)** under the new **Income-tax Act, 2025** effective 1 April 2026.
|
|
64
64
|
- **Section 194J (Fees for Technical/Professional Services)**: Fees for Technical Services (FTS) are taxed at **2%**; professional services are taxed at **10%**.
|
|
65
65
|
- **MSMED Act Section 15 & 16 / IT Act Section 43B(h)**: Payment must occur within written agreement date (not exceeding 45 days) or 15 days without agreement. Delayed payment triggers compound penal interest at **3x RBI Bank Rate** (monthly rests). **Retail and wholesale traders (NIC 45-47) are strictly excluded** from delayed payment benefits per Ministry of MSME OM No. 5/2(2)/2021-E/P & G/Policy.
|
|
66
66
|
- **CGST Act Section 17(5)**: Motor vehicles for transport of persons (<= 13 seating), food and beverages, outdoor catering, and gifts/samples (under Section 17(5)(h)) are blocked ITC, **unless** obligatorily provided by the employer under statutory mandate (e.g., Factories Act, 1948 Section 46 canteen proviso). Note: Schedule I gift valuation threshold (₹50,000) does not unblock ITC under Section 17(5).
|
package/bin/cli.js
CHANGED
|
@@ -25,6 +25,17 @@ import {
|
|
|
25
25
|
getStatutoryOutcomes,
|
|
26
26
|
explainStatutoryDisposition,
|
|
27
27
|
ignorePackageUpdate,
|
|
28
|
+
parseTallyDaybookCsv,
|
|
29
|
+
parseTallyDaybookXml,
|
|
30
|
+
reconcile194QDaybook,
|
|
31
|
+
generateTally194QJournalXml,
|
|
32
|
+
generateAuditMarkdownReport,
|
|
33
|
+
parseZohoBillsCsv,
|
|
34
|
+
parseZohoBillsJson,
|
|
35
|
+
parseGstr2bJson,
|
|
36
|
+
reconcileZohoGstr2b,
|
|
37
|
+
generateGstr2bAuditMarkdownReport,
|
|
38
|
+
runStatutoryWatchtower,
|
|
28
39
|
STATUTORY_EXIT_CODES,
|
|
29
40
|
STATUTORY_CLIENT_VERSION,
|
|
30
41
|
DEFAULT_LOCAL_OKF_DIR
|
|
@@ -174,6 +185,52 @@ async function main() {
|
|
|
174
185
|
handleDecodeId(args[1]);
|
|
175
186
|
break;
|
|
176
187
|
|
|
188
|
+
case 'reconcile':
|
|
189
|
+
case 'reconcile-daybook':
|
|
190
|
+
case 'audit-daybook': {
|
|
191
|
+
const filePath = (args[1] && !args[1].startsWith('-')) ? args[1] : getNamedArg(['--file', '-f'], rawArgs);
|
|
192
|
+
const format = getNamedArg(['--format'], rawArgs);
|
|
193
|
+
const xmlOut = getNamedArg(['--xml-out'], rawArgs);
|
|
194
|
+
const reportOut = getNamedArg(['--report-out', '--out'], rawArgs);
|
|
195
|
+
const buyerTurnover = getNamedArg(['--buyer-turnover'], rawArgs);
|
|
196
|
+
if (!filePath) {
|
|
197
|
+
console.error('[ERROR] Please specify a daybook file to reconcile, e.g. npx @mudraforge/statutory reconcile daybook.csv');
|
|
198
|
+
process.exit(STATUTORY_EXIT_CODES.USAGE_ERROR);
|
|
199
|
+
}
|
|
200
|
+
await handleReconcileDaybook(filePath, { format, xmlOut, reportOut, buyerTurnover: buyerTurnover ? parseFloat(buyerTurnover) : null });
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
case 'reconcile-gstr2b':
|
|
205
|
+
case 'reconcile-zoho': {
|
|
206
|
+
const zohoPath = getNamedArg(['--zoho', '--books', '-b'], rawArgs) || (args[1] && !args[1].startsWith('-') ? args[1] : null);
|
|
207
|
+
const gstr2bPath = getNamedArg(['--gstr2b', '--2b', '-g'], rawArgs) || (args[2] && !args[2].startsWith('-') ? args[2] : null);
|
|
208
|
+
const reportOut = getNamedArg(['--report-out', '--out'], rawArgs);
|
|
209
|
+
const tolerance = getNamedArg(['--tolerance'], rawArgs);
|
|
210
|
+
const asOfDate = getNamedArg(['--as-of', '--date'], rawArgs);
|
|
211
|
+
const gstin = getNamedArg(['--gstin'], rawArgs);
|
|
212
|
+
|
|
213
|
+
if (!zohoPath || !gstr2bPath) {
|
|
214
|
+
console.error('[ERROR] Please specify both Zoho Books and GSTR-2B files:');
|
|
215
|
+
console.error(' npx @mudraforge/statutory reconcile-gstr2b --zoho <zoho_bills.csv|json> --gstr2b <gstr2b.json>');
|
|
216
|
+
process.exit(STATUTORY_EXIT_CODES.USAGE_ERROR);
|
|
217
|
+
}
|
|
218
|
+
await handleReconcileZohoGstr2b(zohoPath, gstr2bPath, {
|
|
219
|
+
reportOut,
|
|
220
|
+
toleranceInr: tolerance ? parseFloat(tolerance) : 1.0,
|
|
221
|
+
asOfDate,
|
|
222
|
+
recipientGstin: gstin
|
|
223
|
+
});
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
case 'watchtower':
|
|
228
|
+
case 'freshness':
|
|
229
|
+
case 'attest': {
|
|
230
|
+
await handleWatchtower();
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
|
|
177
234
|
case 'help':
|
|
178
235
|
default:
|
|
179
236
|
printHelp();
|
|
@@ -899,6 +956,198 @@ function handleDecodeId(rawId) {
|
|
|
899
956
|
console.log('───────────────────────────────────────────────────────────────────────────\n');
|
|
900
957
|
}
|
|
901
958
|
|
|
959
|
+
async function handleReconcileDaybook(filePath, opts = {}) {
|
|
960
|
+
const resolvedPath = path.resolve(process.cwd(), filePath);
|
|
961
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
962
|
+
console.error(`[ERROR] Daybook file not found: ${resolvedPath}`);
|
|
963
|
+
process.exit(STATUTORY_EXIT_CODES.USAGE_ERROR);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
const rawContent = fs.readFileSync(resolvedPath, 'utf8');
|
|
967
|
+
const ext = path.extname(resolvedPath).toLowerCase();
|
|
968
|
+
const format = (opts.format || (ext === '.xml' ? 'xml' : (ext === '.json' ? 'json' : 'csv'))).toLowerCase();
|
|
969
|
+
|
|
970
|
+
let vouchers = [];
|
|
971
|
+
try {
|
|
972
|
+
if (format === 'xml') {
|
|
973
|
+
vouchers = parseTallyDaybookXml(rawContent);
|
|
974
|
+
} else if (format === 'json') {
|
|
975
|
+
vouchers = JSON.parse(rawContent);
|
|
976
|
+
} else {
|
|
977
|
+
vouchers = parseTallyDaybookCsv(rawContent);
|
|
978
|
+
}
|
|
979
|
+
} catch (parseErr) {
|
|
980
|
+
console.error(`[ERROR] Failed to parse daybook file (${format}):`, parseErr.message);
|
|
981
|
+
process.exit(STATUTORY_EXIT_CODES.USAGE_ERROR);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
const reconciliation = reconcile194QDaybook(vouchers, {
|
|
985
|
+
buyerTurnoverCr: opts.buyerTurnover || null
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
if (opts.xmlOut) {
|
|
989
|
+
const xmlOutPath = path.resolve(process.cwd(), opts.xmlOut);
|
|
990
|
+
const xmlContent = generateTally194QJournalXml(reconciliation);
|
|
991
|
+
fs.writeFileSync(xmlOutPath, xmlContent, 'utf8');
|
|
992
|
+
if (!isJsonMode) {
|
|
993
|
+
console.log(`[INFO] Tally compensating XML journal written to: ${xmlOutPath}`);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
if (opts.reportOut) {
|
|
998
|
+
const reportOutPath = path.resolve(process.cwd(), opts.reportOut);
|
|
999
|
+
const reportContent = generateAuditMarkdownReport(reconciliation);
|
|
1000
|
+
fs.writeFileSync(reportOutPath, reportContent, 'utf8');
|
|
1001
|
+
if (!isJsonMode) {
|
|
1002
|
+
console.log(`[INFO] Audit Markdown memorandum written to: ${reportOutPath}`);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
if (isJsonMode) {
|
|
1007
|
+
console.log(JSON.stringify(reconciliation, null, 2));
|
|
1008
|
+
process.exit(0);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
const { auditSummary, exceptionVendors } = reconciliation;
|
|
1012
|
+
const fmtInr = (n) => '₹' + Number(n || 0).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
1013
|
+
|
|
1014
|
+
console.log('\n===========================================================================');
|
|
1015
|
+
console.log('TALLY / ERP SECTION 194Q RECONCILIATION & 40(a)(ia) EXPOSURE AUDIT');
|
|
1016
|
+
console.log('===========================================================================');
|
|
1017
|
+
console.log(`File: ${resolvedPath}`);
|
|
1018
|
+
console.log(`Format: ${format.toUpperCase()}`);
|
|
1019
|
+
console.log(`Vouchers Audited: ${auditSummary.totalVouchersScanned}`);
|
|
1020
|
+
console.log(`Unique Vendors / PANs: ${auditSummary.uniqueVendorsCount}`);
|
|
1021
|
+
console.log(`Vendors > ₹50L Threshold: ${auditSummary.vendorsExceeding50LCount}`);
|
|
1022
|
+
console.log(`Non-Compliant Vendors: ${auditSummary.vendorsWithExceptionsCount}`);
|
|
1023
|
+
console.log(`Total Purchases: ${fmtInr(auditSummary.totalPurchasesInr)}`);
|
|
1024
|
+
console.log(`Taxable Base (> ₹50L): ${fmtInr(auditSummary.totalExcessPurchasesOver50LInr)}`);
|
|
1025
|
+
console.log(`Required TDS @ 0.1%: ${fmtInr(auditSummary.totalTdsPayableInr)}`);
|
|
1026
|
+
console.log(`Actual TDS Deducted: ${fmtInr(auditSummary.totalTdsDeductedInr)}`);
|
|
1027
|
+
console.log(`Unwithheld TDS Shortfall: ${fmtInr(auditSummary.totalTdsShortfallInr)}`);
|
|
1028
|
+
console.log(`---------------------------------------------------------------------------`);
|
|
1029
|
+
console.log(`Section 40(a)(ia) Risk: ${fmtInr(auditSummary.totalSection40aDisallowanceInr)} (30% Expenditure Disallowed)`);
|
|
1030
|
+
console.log(`Estimated Income Tax Hit: ${fmtInr(auditSummary.totalEstimatedTaxImpactInr)} (@ 30% Corporate Tax)`);
|
|
1031
|
+
console.log(`Sec 201(1A) Interest: ${fmtInr(auditSummary.totalSection201InterestInr)}`);
|
|
1032
|
+
console.log(`TOTAL AUDIT EXPOSURE: ${fmtInr(auditSummary.totalAuditExposureInr)}`);
|
|
1033
|
+
console.log('===========================================================================');
|
|
1034
|
+
|
|
1035
|
+
if (exceptionVendors.length > 0) {
|
|
1036
|
+
console.log('\nNON-COMPLIANT VENDOR SCHEDULE (Form 3CD Clause 21(b) Working Papers):');
|
|
1037
|
+
console.log('─'.repeat(75));
|
|
1038
|
+
for (const v of exceptionVendors) {
|
|
1039
|
+
console.log(`• ${v.primaryVendorName} (PAN: ${v.pan || 'MISSING'})`);
|
|
1040
|
+
console.log(` Purchases: ${fmtInr(v.totalPurchasesInr)} | Excess: ${fmtInr(v.excessPurchasesOver50LInr)} | Shortfall: ${fmtInr(v.tdsShortfallInr)} | 40(a)(ia) Risk: ${fmtInr(v.section40aDisallowanceInr)}`);
|
|
1041
|
+
}
|
|
1042
|
+
console.log('─'.repeat(75));
|
|
1043
|
+
console.log(`Tip: Pass --xml-out vouchers.xml to generate Tally Prime auto-import XML.`);
|
|
1044
|
+
} else {
|
|
1045
|
+
console.log('\n[PASS] 100% Statutory Compliance. Zero Section 40(a)(ia) disallowance risk.\n');
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
async function handleReconcileZohoGstr2b(zohoPath, gstr2bPath, opts = {}) {
|
|
1050
|
+
const resolvedZoho = path.resolve(process.cwd(), zohoPath);
|
|
1051
|
+
const resolved2b = path.resolve(process.cwd(), gstr2bPath);
|
|
1052
|
+
|
|
1053
|
+
if (!fs.existsSync(resolvedZoho)) {
|
|
1054
|
+
console.error(`[ERROR] Zoho Books file not found: ${resolvedZoho}`);
|
|
1055
|
+
process.exit(STATUTORY_EXIT_CODES.USAGE_ERROR);
|
|
1056
|
+
}
|
|
1057
|
+
if (!fs.existsSync(resolved2b)) {
|
|
1058
|
+
console.error(`[ERROR] GSTR-2B file not found: ${resolved2b}`);
|
|
1059
|
+
process.exit(STATUTORY_EXIT_CODES.USAGE_ERROR);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
const zohoContent = fs.readFileSync(resolvedZoho, 'utf8');
|
|
1063
|
+
const gstr2bContent = fs.readFileSync(resolved2b, 'utf8');
|
|
1064
|
+
|
|
1065
|
+
const zohoExt = path.extname(resolvedZoho).toLowerCase();
|
|
1066
|
+
const zohoBills = zohoExt === '.json' ? parseZohoBillsJson(zohoContent) : parseZohoBillsCsv(zohoContent);
|
|
1067
|
+
const gstr2bRecords = parseGstr2bJson(gstr2bContent);
|
|
1068
|
+
|
|
1069
|
+
const reconciliation = reconcileZohoGstr2b({
|
|
1070
|
+
zohoBills,
|
|
1071
|
+
gstr2b: gstr2bRecords,
|
|
1072
|
+
options: {
|
|
1073
|
+
toleranceInr: opts.toleranceInr || 1.0,
|
|
1074
|
+
asOfDate: opts.asOfDate || new Date().toISOString().slice(0, 10),
|
|
1075
|
+
recipientGstin: opts.recipientGstin || null
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
if (opts.reportOut) {
|
|
1080
|
+
const reportOutPath = path.resolve(process.cwd(), opts.reportOut);
|
|
1081
|
+
const reportContent = generateGstr2bAuditMarkdownReport(reconciliation);
|
|
1082
|
+
fs.writeFileSync(reportOutPath, reportContent, 'utf8');
|
|
1083
|
+
if (!isJsonMode) {
|
|
1084
|
+
console.log(`[INFO] GSTR-2B Audit Markdown report written to: ${reportOutPath}`);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
if (isJsonMode) {
|
|
1089
|
+
console.log(JSON.stringify(reconciliation, null, 2));
|
|
1090
|
+
process.exit(0);
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
const s = reconciliation.summary;
|
|
1094
|
+
const fmt = n => 'INR ' + Number(n || 0).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
1095
|
+
|
|
1096
|
+
console.log('\n===========================================================================');
|
|
1097
|
+
console.log('ZOHO BOOKS & GSTR-2B AP RECONCILIATION AUDIT');
|
|
1098
|
+
console.log(`Status: ${reconciliation.status} | Disposition: ${s.reconciliationStatus}`);
|
|
1099
|
+
console.log('===========================================================================');
|
|
1100
|
+
console.log(`Zoho Books File: ${resolvedZoho}`);
|
|
1101
|
+
console.log(`GSTR-2B File: ${resolved2b}`);
|
|
1102
|
+
console.log(`Total Zoho Books Bills: ${s.totalBooksBillsCount}`);
|
|
1103
|
+
console.log(`Total GSTR-2B Records: ${s.totalGstr2bRecordsCount}`);
|
|
1104
|
+
console.log(`---------------------------------------------------------------------------`);
|
|
1105
|
+
console.log(`100% Eligible ITC: ${s.matchedEligibleCount} bills (${fmt(s.eligibleItcInr)})`);
|
|
1106
|
+
console.log(`At-Risk Missing in 2B: ${s.missingIn2bCount} bills (${fmt(s.atRiskUnfiledItcInr)}) [Withhold]`);
|
|
1107
|
+
console.log(`Sec 17(5) Blocked ITC: ${s.blocked17_5Count} bills (${fmt(s.blocked17_5ItcInr)}) [Table 4(B)(1)]`);
|
|
1108
|
+
console.log(`Place of Supply Mismatch: ${s.posMismatchCount} bills (${fmt(s.posMismatchItcInr)}) [Dispute]`);
|
|
1109
|
+
console.log(`Value Discrepancies: ${s.amountMismatchCount} bills (${fmt(s.mismatchedItcInr)})`);
|
|
1110
|
+
console.log(`Missing in Books (Unrec): ${s.missingInBooksCount} bills (${fmt(s.missingInBooksTaxInr)})`);
|
|
1111
|
+
console.log(`---------------------------------------------------------------------------`);
|
|
1112
|
+
console.log(`Rule 37 Overdue (>180 Days):${s.rule37OverdueCount} bills (Reversal: ${fmt(s.rule37ReversalAmountInr)})`);
|
|
1113
|
+
console.log(`Rule 37 Delayed Interest: ${fmt(s.rule37InterestExposureInr)} (@ 18% p.a. u/s 50(1))`);
|
|
1114
|
+
console.log('---------------------------------------------------------------------------');
|
|
1115
|
+
console.log(`isAuthorizedToDisburse: ${s.isAuthorizedToDisburse} (Statutory calculation never moves money)`);
|
|
1116
|
+
console.log('===========================================================================\n');
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
async function handleWatchtower() {
|
|
1120
|
+
try {
|
|
1121
|
+
const report = await runStatutoryWatchtower({ verbose: !isJsonMode });
|
|
1122
|
+
if (isJsonMode) {
|
|
1123
|
+
console.log(JSON.stringify(report, null, 2));
|
|
1124
|
+
} else {
|
|
1125
|
+
console.log('\n===========================================================================');
|
|
1126
|
+
console.log('MUDRAFORGE REGULATORY WATCHTOWER & FRESHNESS ATTESTATION');
|
|
1127
|
+
console.log('===========================================================================');
|
|
1128
|
+
console.log(`Status : ${report.status}`);
|
|
1129
|
+
console.log(`Sections Scanned : ${report.checks.schemaValidation.sectionsScanned}`);
|
|
1130
|
+
console.log(`Circulars Scanned : ${report.checks.schemaValidation.circularsScanned}`);
|
|
1131
|
+
console.log(`Forms Scanned : ${report.checks.schemaValidation.formsScanned}`);
|
|
1132
|
+
console.log(`Citations Verified : ${report.checks.citationIntegrity.validCitations} (0 failures)`);
|
|
1133
|
+
console.log(`Merkle Root : ${report.checks.merkleImmutability.computedRoot}`);
|
|
1134
|
+
console.log(`Pinned Root Match : ${report.checks.merkleImmutability.matchesPinnedRoot}`);
|
|
1135
|
+
console.log(`Freshness Benchmarks : ${report.checks.freshnessHorizon.benchmarksPassed}/${report.checks.freshnessHorizon.benchmarksEvaluated} passed`);
|
|
1136
|
+
console.log(`Certificate ID : ${report.certificate?.certificateId}`);
|
|
1137
|
+
console.log(`Empanelment Score : ${report.certificate?.empanelmentComplianceScore}`);
|
|
1138
|
+
console.log(`Disbursement Invariant : isAuthorizedToDisburse === ${report.certificate?.isAuthorizedToDisburse}`);
|
|
1139
|
+
console.log(`Execution Duration : ${report.executionDurationMs}ms`);
|
|
1140
|
+
console.log('===========================================================================\n');
|
|
1141
|
+
}
|
|
1142
|
+
if (report.status !== 'SUCCESS') {
|
|
1143
|
+
process.exit(STATUTORY_EXIT_CODES.SUBSTRATE_CORRUPT || 1);
|
|
1144
|
+
}
|
|
1145
|
+
} catch (err) {
|
|
1146
|
+
console.error('[FAIL] Watchtower execution failed:', err);
|
|
1147
|
+
process.exit(1);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
902
1151
|
function printHelp() {
|
|
903
1152
|
console.log(`
|
|
904
1153
|
MudraForge Statutory Commons CLI (@mudraforge/statutory)
|
|
@@ -907,37 +1156,49 @@ Usage:
|
|
|
907
1156
|
npx @mudraforge/statutory <command> [options]
|
|
908
1157
|
|
|
909
1158
|
Commands:
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1159
|
+
watchtower Run regulatory surveillance & generate Empanelment Freshness Certificate
|
|
1160
|
+
reconcile <file> Reconcile Tally/ERP daybook (CSV/XML/JSON) for Section 194Q & 40(a)(ia)
|
|
1161
|
+
reconcile-gstr2b [options] Reconcile Zoho Books AP bills with GST Portal Form GSTR-2B
|
|
1162
|
+
doctor [--offline] Run full diagnostic check of runtime, substrate integrity, & edge status
|
|
1163
|
+
verify [path] Cryptographically verify OKF substrate authenticity & file integrity
|
|
1164
|
+
crosswalk <section> Dual-act 1961 <-> 2025 bridge (earlier of credit vs payment)
|
|
1165
|
+
diff Semantic regulatory changelog (--section, --since, --domain)
|
|
1166
|
+
outcomes [provision] Inspect API dispositions, statutory states, trigger conditions & actions
|
|
1167
|
+
explain <code/status> In-depth explanation, legal rationale & remediation steps for a disposition
|
|
1168
|
+
browse Interactively browse local OKF statutory filesystem
|
|
1169
|
+
lookup <section> [date] Look up section details & temporal status (e.g. 194Q 2025-06-01)
|
|
1170
|
+
decode-id <pan_or_gstin> Offline ISO Mod-36 checksum, state name, and PAN entity decoding
|
|
1171
|
+
check-update [--ignore] Check edge updates; pass --ignore to snooze notices for current version
|
|
1172
|
+
sync [path] Download/sync latest versioned OKF bundle to disk (default: package okf/ or custom dir)
|
|
1173
|
+
list List all indexed statutory sections
|
|
1174
|
+
init-skill [path] Install SKILL.md into your agent workspace (defaults to .agents/skills/)
|
|
1175
|
+
help Show this help message
|
|
924
1176
|
|
|
925
1177
|
Options:
|
|
926
|
-
--
|
|
927
|
-
--
|
|
928
|
-
--
|
|
929
|
-
--
|
|
930
|
-
--
|
|
931
|
-
--
|
|
932
|
-
--
|
|
933
|
-
--
|
|
934
|
-
--
|
|
1178
|
+
--zoho, -b <file> Zoho Books bills CSV or JSON export path
|
|
1179
|
+
--gstr2b, -g <file> GST Portal Form GSTR-2B JSON file path
|
|
1180
|
+
--tolerance <amount> Reconciliation tolerance in INR (default: 1.00)
|
|
1181
|
+
--as-of, --date <date> Audit as-of date (YYYY-MM-DD) for Rule 37 180-day aging
|
|
1182
|
+
--gstin <gstin> Recipient taxpayer GSTIN (used for Place of Supply validation)
|
|
1183
|
+
--format <csv|xml|json> Explicit daybook file format parser
|
|
1184
|
+
--xml-out <path> Output path for Tally Prime compensating journal voucher XML
|
|
1185
|
+
--report-out <path> Output path for executive Markdown audit memorandum
|
|
1186
|
+
--buyer-turnover <Cr> Preceding FY buyer turnover in ₹ Crores (default: assumes > ₹10 Cr)
|
|
1187
|
+
--credit <YYYY-MM-DD> Date of credit to vendor/payee account in books (used in crosswalk)
|
|
1188
|
+
--payment <YYYY-MM-DD> Date of actual payment/disbursement (used in crosswalk)
|
|
1189
|
+
--since <YYYY-MM-DD> Filter amendments taking effect on or after date (used in diff)
|
|
1190
|
+
--section, -s <section> Filter amendments by section code (used in diff)
|
|
1191
|
+
--domain <domain> Filter amendments by statutory domain (used in diff)
|
|
1192
|
+
--verbose, -v Display full remediation steps, parameter schemas, and consequences in outcomes
|
|
1193
|
+
--no-update-check Bypass automated background npm package update checks
|
|
1194
|
+
--json, -j Emit clean, machine-parseable JSON to stdout (suppresses banners)
|
|
1195
|
+
--offline, -o Bypass outbound network checks (air-gapped / offline environment mode)
|
|
935
1196
|
|
|
936
1197
|
Exit Code Conventions:
|
|
937
|
-
0
|
|
938
|
-
1
|
|
939
|
-
2
|
|
940
|
-
3
|
|
1198
|
+
0 Success / Verification passed
|
|
1199
|
+
1 Usage or operational error (invalid syntax / parameters)
|
|
1200
|
+
2 Cryptographic authenticity or integrity violation (mismatch/revocation)
|
|
1201
|
+
3 Statutory policy violation (e.g. missing baseline provision)
|
|
941
1202
|
`);
|
|
942
1203
|
}
|
|
943
1204
|
|