@mudraforge/statutory 2.12.1 → 2.14.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.
- package/CHANGELOG.md +32 -0
- package/README.md +19 -0
- package/okf/corporate_ma_restructuring/business_combinations_indas_103/ast.json +20 -0
- package/okf/corporate_ma_restructuring/impairment_of_assets_indas_36/ast.json +20 -0
- package/okf/corporate_ma_restructuring/loss_carryforward_sec79/ast.json +33 -0
- package/okf/corporate_ma_restructuring/share_based_payments_indas_102/ast.json +20 -0
- package/okf/corporate_ma_restructuring/slump_sale_50b/ast.json +21 -0
- package/okf/corporate_ma_restructuring/tax_clearance_sec281/ast.json +21 -0
- package/okf/direct_tax/corporate_tax_115baa_115jb/ast.json +23 -0
- package/okf/direct_tax/income_taxes_deferred_tax_indas_12/ast.json +20 -0
- package/okf/direct_tax/special_rates_non_filer_206ab/ast.json +26 -0
- package/okf/direct_tax/statutory_disallowance_43b/ast.json +35 -0
- package/okf/direct_tax/tcs_goods_206c_1h/ast.json +69 -0
- package/okf/direct_tax/tds_commission_194h/ast.json +60 -0
- package/okf/direct_tax/tds_contractor_194c/ast.json +71 -0
- package/okf/direct_tax/tds_ecommerce_194o/ast.json +48 -0
- package/okf/direct_tax/tds_goods_194q/ast.json +71 -0
- package/okf/direct_tax/tds_goods_393/ast.json +59 -0
- package/okf/direct_tax/tds_individual_contract_194m/ast.json +59 -0
- package/okf/direct_tax/tds_interest_194a/ast.json +59 -0
- package/okf/direct_tax/tds_perquisites_194r/ast.json +47 -0
- package/okf/direct_tax/tds_property_194ia/ast.json +70 -0
- package/okf/direct_tax/tds_rent_194i/ast.json +60 -0
- package/okf/direct_tax/tds_rent_individual_194ib/ast.json +59 -0
- package/okf/direct_tax/tds_services_194j/ast.json +60 -0
- package/okf/indirect_tax_gst/blocked_itc_17_5/ast.json +26 -0
- package/okf/indirect_tax_gst/common_itc_reversal_rule42_43/ast.json +26 -0
- package/okf/indirect_tax_gst/composite_mixed_supplies_sec8/ast.json +21 -0
- package/okf/indirect_tax_gst/composition_levy_sec10/ast.json +23 -0
- package/okf/indirect_tax_gst/credit_debit_notes_sec34/ast.json +21 -0
- package/okf/indirect_tax_gst/e_invoicing_rule48_4/ast.json +20 -0
- package/okf/indirect_tax_gst/export_services_lut_sec16/ast.json +20 -0
- package/okf/indirect_tax_gst/gst_tds_sec51/ast.json +23 -0
- package/okf/indirect_tax_gst/itc_eligibility_16_2/ast.json +20 -0
- package/okf/indirect_tax_gst/itc_reversal_rule37_37a/ast.json +45 -0
- package/okf/indirect_tax_gst/rcm_liability_sec9_3/ast.json +26 -0
- package/okf/international_tax/cross_border_remittance_195/ast.json +39 -0
- package/okf/international_tax/financial_instruments_ecl_indas_109/ast.json +24 -0
- package/okf/international_tax/foreign_exchange_indas_21_109/ast.json +20 -0
- package/okf/international_tax/foreign_tax_credit_irc_901_904/ast.json +20 -0
- package/okf/international_tax/transfer_pricing_alp_92c/ast.json +25 -0
- package/okf/manifest.json +49 -3
- package/okf/msme_commercial/delayed_payments_15_16/ast.json +38 -0
- package/okf/msme_commercial/enterprise_classification_sec7/ast.json +25 -0
- package/okf/msme_commercial/lease_accounting_indas_116/ast.json +20 -0
- package/okf/msme_commercial/mca_msme_1_filing/ast.json +20 -0
- package/okf/msme_commercial/provisions_contingencies_indas_37/ast.json +20 -0
- package/okf/msme_commercial/revenue_recognition_indas_115/ast.json +20 -0
- package/okf/msme_commercial/statutory_disclosures_sec22/ast.json +21 -0
- package/package.json +16 -4
- package/src/calculators.js +139 -3
- package/src/constants.js +1 -1
- package/src/index.js +16 -2
- package/src/payroll.js +506 -0
- package/src/usvm/evaluation_vm.js +504 -0
- package/src/usvm/index.js +65 -0
- package/src/usvm/math_rational.js +165 -0
- package/src/usvm/rules/sec_115baa_115jb_mat.json +23 -0
- package/src/usvm/rules/sec_192_salary_tds.json +23 -0
- package/src/usvm/rules/sec_194a_interest.json +59 -0
- package/src/usvm/rules/sec_194c_contractors.json +71 -0
- package/src/usvm/rules/sec_194h_commission.json +60 -0
- package/src/usvm/rules/sec_194i_rent.json +60 -0
- package/src/usvm/rules/sec_194ia_property.json +70 -0
- package/src/usvm/rules/sec_194ib_rent_ind.json +59 -0
- package/src/usvm/rules/sec_194j_services.json +60 -0
- package/src/usvm/rules/sec_194m_contract_ind.json +59 -0
- package/src/usvm/rules/sec_194o_ecommerce.json +48 -0
- package/src/usvm/rules/sec_194q_goods.json +71 -0
- package/src/usvm/rules/sec_194r_perquisites.json +47 -0
- package/src/usvm/rules/sec_195_cross_border.json +39 -0
- package/src/usvm/rules/sec_206ab_non_filer.json +26 -0
- package/src/usvm/rules/sec_206c1h_tcs.json +69 -0
- package/src/usvm/rules/sec_281_tax_clearance.json +21 -0
- package/src/usvm/rules/sec_393_goods.json +59 -0
- package/src/usvm/rules/sec_43bh_disallowance.json +35 -0
- package/src/usvm/rules/sec_50b_slump_sale.json +21 -0
- package/src/usvm/rules/sec_79_loss_continuity.json +33 -0
- package/src/usvm/rules/sec_92c_transfer_pricing.json +25 -0
- package/src/usvm/rules/sec_ftc_dtaa_relief.json +20 -0
- package/src/usvm/rules/sec_gst_blocked_itc_17_5.json +26 -0
- package/src/usvm/rules/sec_gst_composite_mixed_8.json +21 -0
- package/src/usvm/rules/sec_gst_composition_levy_10.json +23 -0
- package/src/usvm/rules/sec_gst_credit_debit_notes_34.json +21 -0
- package/src/usvm/rules/sec_gst_einvoicing_rule48_4.json +20 -0
- package/src/usvm/rules/sec_gst_ewaybill_rule138.json +21 -0
- package/src/usvm/rules/sec_gst_export_lut_16.json +20 -0
- package/src/usvm/rules/sec_gst_itc_eligibility_16_2.json +20 -0
- package/src/usvm/rules/sec_gst_itc_reversal_rule37_37a.json +45 -0
- package/src/usvm/rules/sec_gst_rcm_liability_9_3.json +26 -0
- package/src/usvm/rules/sec_gst_rule42_43_apportionment.json +26 -0
- package/src/usvm/rules/sec_gst_tds_sec51.json +23 -0
- package/src/usvm/rules/sec_indas102_esop.json +20 -0
- package/src/usvm/rules/sec_indas103_mna.json +20 -0
- package/src/usvm/rules/sec_indas109_ecl.json +24 -0
- package/src/usvm/rules/sec_indas115_revenue.json +20 -0
- package/src/usvm/rules/sec_indas116_leases.json +20 -0
- package/src/usvm/rules/sec_indas12_deferred_tax.json +20 -0
- package/src/usvm/rules/sec_indas21_fx_reval.json +20 -0
- package/src/usvm/rules/sec_indas36_impairment.json +20 -0
- package/src/usvm/rules/sec_indas37_provisions.json +20 -0
- package/src/usvm/rules/sec_msme_classification_sec7.json +25 -0
- package/src/usvm/rules/sec_msme_delayed_payments_15_16.json +38 -0
- package/src/usvm/rules/sec_msme_disclosures_sec22.json +21 -0
- package/src/usvm/rules/sec_msme_mca_form_1.json +20 -0
- package/src/usvm/schemas/statutory_ast_schema.js +203 -0
- package/src/usvm/usvm_domain_evaluators.js +1021 -0
- package/types/index.d.ts +134 -0
- package/conformance/README.md +0 -54
- package/conformance/fixtures/invalid_malformed_temporal_dates.json +0 -10
- package/conformance/fixtures/invalid_missing_effective_period.json +0 -6
- package/conformance/fixtures/invalid_missing_section_code.json +0 -9
- package/conformance/fixtures/valid_circular_frontmatter.md +0 -16
- package/conformance/fixtures/valid_full_section.json +0 -35
- package/conformance/fixtures/valid_minimal_section.json +0 -11
- package/conformance/test_conformance.js +0 -129
- package/docs/ACCOUNTING_ASSURANCE_AUDIT_DOSSIER.md +0 -276
- package/docs/ADESHA_ASSURANCE_OVERVIEW.md +0 -166
- package/docs/ARCHITECTURE.md +0 -750
- package/docs/ARCHITECTURE_DECISIONS.md +0 -138
- package/docs/CASE_01_FORM_TEXT.txt +0 -48
- package/docs/CATALOG.md +0 -1901
- package/docs/CA_PILOT_BENCHMARK_CASES.md +0 -282
- package/docs/CORPUS_QUALITY.md +0 -106
- package/docs/DATA_LICENSING.md +0 -73
- package/docs/DOMAIN_BREADTH_AND_DEPTH_COMPARISON.md +0 -209
- package/docs/ENTERPRISE_GOVERNANCE.md +0 -159
- package/docs/OKF_MAINTENANCE_SOP.md +0 -286
- package/docs/PILOT_EVALUATION_GUIDE.md +0 -214
- package/docs/PROVENANCE.md +0 -33
- package/docs/VERIFICATION.md +0 -106
- package/examples/README.md +0 -56
- package/examples/invoice_deduction_trace.json +0 -149
- package/examples/simulate_end_to_end_trace.js +0 -106
package/examples/README.md
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# MudraForge Statutory & Adesha: End-to-End Execution Traces
|
|
2
|
-
|
|
3
|
-
> **Purpose**: Demonstrates the concrete operational bridge connecting public OKF statutory rules with the commercial Adesha Autonomous Finance Runtime.
|
|
4
|
-
> **Demonstration Notice**: This trace contains synthetic transaction data and modeled authorization, banking, and ledger events. It does not connect to a real bank, verify a live biometric event, or execute a real-world payment. All PANs, GSTINs, and account numbers are explicitly synthetic test fixtures.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## 1. Overview
|
|
9
|
-
|
|
10
|
-
A common question from developers and Chief Financial Officers is:
|
|
11
|
-
> *"How does a declarative statutory tax rule in `@mudraforge/statutory` translate into a safe, real-world corporate payment without giving an AI agent uncontrolled access to company bank accounts?"*
|
|
12
|
-
|
|
13
|
-
This directory contains concrete, audited end-to-end execution traces illustrating every stage of that journey:
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
[Raw Vendor Invoice]
|
|
17
|
-
↓
|
|
18
|
-
Stage 1: Ingestion & Vendor PAN/GSTIN Validation
|
|
19
|
-
↓
|
|
20
|
-
Stage 2: OKF Rule Resolution (Section 194Q TDS on Purchase of Goods)
|
|
21
|
-
↓
|
|
22
|
-
Stage 3: Deterministic Tax Calculation (0.1% on excess over ₹50L, GST unbundled per CBDT 13/2021)
|
|
23
|
-
↓
|
|
24
|
-
Stage 4: Adesha Payment Authorization Lease (Single-use cryptographic token, amount-locked)
|
|
25
|
-
↓
|
|
26
|
-
Stage 5: Human-In-The-Loop Mobile Authorization (CFO Biometric/Passkey Approval on Mobile)
|
|
27
|
-
↓
|
|
28
|
-
Stage 6: Host-to-Host Corporate Bank Rail Disbursement (RTGS Settlement with Bank UTR)
|
|
29
|
-
↓
|
|
30
|
-
Stage 7: General Ledger Writeback (ERP Balanced Double-Entry Journal Entry: Debits ≡ Credits)
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 2. Artifacts in this Directory
|
|
36
|
-
|
|
37
|
-
| File | Description |
|
|
38
|
-
| :--- | :--- |
|
|
39
|
-
| [`invoice_deduction_trace.json`](./invoice_deduction_trace.json) | Full machine-readable execution trace payload covering all 7 stages. |
|
|
40
|
-
| [`simulate_end_to_end_trace.js`](./simulate_end_to_end_trace.js) | Standalone simulation runner printing the step-by-step audit lifecycle. |
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## 3. Running the Trace Locally
|
|
45
|
-
|
|
46
|
-
Any developer can run this simulation locally with zero external network access:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
node examples/simulate_end_to_end_trace.js
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Or via npm:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
npm run example:trace
|
|
56
|
-
```
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://mudraforge.in/schemas/v1/execution-trace.json",
|
|
3
|
-
"traceId": "trace_e2e_2026_sec194q_001",
|
|
4
|
-
"timestamp": "2026-04-15T10:30:00Z",
|
|
5
|
-
"isSyntheticDemonstrationFixture": true,
|
|
6
|
-
"disclaimer": "Demonstration only: This trace contains synthetic transaction data and simulated authorization, banking and general ledger events. It does not connect to a real bank, verify a real biometric event, or execute a live payment.",
|
|
7
|
-
"workflow": "ACCOUNTS_PAYABLE_STATUTORY_DISBURSEMENT",
|
|
8
|
-
|
|
9
|
-
"stage1_incoming_invoice": {
|
|
10
|
-
"invoiceNumber": "INV-2026-891",
|
|
11
|
-
"invoiceDate": "2026-04-15",
|
|
12
|
-
"vendor": {
|
|
13
|
-
"legalName": "Apex Synthetic Industrial Steels Private Limited (Demonstration Fixture)",
|
|
14
|
-
"pan": "AAAPA0000A",
|
|
15
|
-
"panStatus": "OPERATIVE_VERIFIED_SYNTHETIC",
|
|
16
|
-
"gstin": "27AAAPA0000A1Z5",
|
|
17
|
-
"msmeStatus": "NOT_APPLICABLE_LARGE_ENTERPRISE"
|
|
18
|
-
},
|
|
19
|
-
"currency": "INR",
|
|
20
|
-
"lineItems": [
|
|
21
|
-
{
|
|
22
|
-
"description": "Hot Rolled Steel Coils (Grade IS 2062)",
|
|
23
|
-
"quantity": 120,
|
|
24
|
-
"unit": "MT",
|
|
25
|
-
"basicAmountInr": 6000000.00
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"basicGoodsAmountInr": 6000000.00,
|
|
29
|
-
"gstRatePercent": 18.0,
|
|
30
|
-
"cgstAmountInr": 540000.00,
|
|
31
|
-
"sgstAmountInr": 540000.00,
|
|
32
|
-
"totalGstAmountInr": 1080000.00,
|
|
33
|
-
"grossInvoiceAmountInr": 7080000.00
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
"stage2_okf_statutory_rule_resolution": {
|
|
37
|
-
"provisionResolved": "194Q",
|
|
38
|
-
"source": "LOCAL_OKF_FS",
|
|
39
|
-
"governingStatute": "Income-tax Act, 1961 (Act No. 43 of 1961)",
|
|
40
|
-
"successorStatute": "Income-tax Act, 2025 Section 393(1) Table 8 Item (ii)",
|
|
41
|
-
"temporalStatus": "ACTIVE",
|
|
42
|
-
"retrievalMode": "LOCAL_OFFLINE_FASTPATH",
|
|
43
|
-
"statutoryRule": {
|
|
44
|
-
"thresholdInr": 5000000.00,
|
|
45
|
-
"buyerPriorYearTurnoverCr": 10.00,
|
|
46
|
-
"standardDeductionRatePercent": 0.1,
|
|
47
|
-
"inoperativePanPenaltyRatePercent": 5.0,
|
|
48
|
-
"taxableBaseScope": "EXCESS_OVER_50_LAKHS_ONLY",
|
|
49
|
-
"gstUnbundlingMandated": true,
|
|
50
|
-
"citation": "CBDT Circular No. 13 of 2021 (Dated 30 June 2021)"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
"stage3_deterministic_statutory_computation": {
|
|
55
|
-
"engine": "MudraForge Deterministic Statutory Calculator",
|
|
56
|
-
"inputs": {
|
|
57
|
-
"buyerPriorYearGrossTurnoverCr": 24.50,
|
|
58
|
-
"isBuyerEligible": true,
|
|
59
|
-
"priorPurchasesInCurrentFYInr": 4500000.00,
|
|
60
|
-
"currentInvoiceBasicInr": 6000000.00,
|
|
61
|
-
"cumulativeFYPurchasesInr": 10500000.00
|
|
62
|
-
},
|
|
63
|
-
"calculationSteps": {
|
|
64
|
-
"statutoryThresholdInr": 5000000.00,
|
|
65
|
-
"portionExemptFromPriorBalanceInr": 500000.00,
|
|
66
|
-
"taxableBaseForThisInvoiceInr": 5500000.00,
|
|
67
|
-
"gstComponentExcludedInr": 1080000.00,
|
|
68
|
-
"tdsRateAppliedPercent": 0.1,
|
|
69
|
-
"tdsDeductionCalculatedInr": 5500.00,
|
|
70
|
-
"netPayableToVendorInr": 7074500.00
|
|
71
|
-
},
|
|
72
|
-
"verificationStatus": "DETERMINISTIC_PASS"
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
"stage4_adesha_payment_authorization_lease": {
|
|
76
|
-
"runtime": "MudraForge Adesha Sovereign Runtime",
|
|
77
|
-
"leaseId": "lease_2026_04_apex_89a1",
|
|
78
|
-
"leaseStatus": "PENDING_HUMAN_AUTHORIZATION",
|
|
79
|
-
"singleUseLeaseToken": "sha256-4f9e8a71b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9",
|
|
80
|
-
"authorizedRecipient": {
|
|
81
|
-
"beneficiaryName": "Apex Synthetic Industrial Steels Pvt Ltd (Demonstration Fixture)",
|
|
82
|
-
"bankAccountNumber": "0000000000009812",
|
|
83
|
-
"ifscCode": "TEST0000001"
|
|
84
|
-
},
|
|
85
|
-
"maximumAuthorizedDisbursementInr": 7074500.00,
|
|
86
|
-
"leaseExpiresAt": "2026-04-15T12:00:00Z",
|
|
87
|
-
"formalState": "LEASE_ISSUED_UNCONSUMED"
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
"stage5_human_in_the_loop_authorization": {
|
|
91
|
-
"channel": "Adesha Mobile Authority Harness (Simulated Android/iOS)",
|
|
92
|
-
"decision": "APPROVED",
|
|
93
|
-
"authorizedBy": {
|
|
94
|
-
"officerId": "usr_cfo_synthetic_01",
|
|
95
|
-
"email": "cfo@example-enterprise.invalid",
|
|
96
|
-
"role": "CHIEF_FINANCIAL_OFFICER"
|
|
97
|
-
},
|
|
98
|
-
"authenticationFactor": "SIMULATED_BIOMETRIC_PASSKEY_VERIFIED",
|
|
99
|
-
"authorizedAt": "2026-04-15T10:32:15Z",
|
|
100
|
-
"stateTransition": "LEASE_ISSUED_UNCONSUMED -> AUTHORIZED_FOR_SETTLEMENT"
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
"stage6_banking_rail_disbursement": {
|
|
104
|
-
"bankingPartner": "Simulated Corporate Banking Gateway (H2H RTGS)",
|
|
105
|
-
"rail": "RTGS_SIMULATED",
|
|
106
|
-
"transportIdempotencyKey": "idem_synthetic_inv891_20260415_01",
|
|
107
|
-
"bankUniqueTransactionReference": "SIMULATED-RTGS-UTR-2026-891",
|
|
108
|
-
"disbursedAmountInr": 7074500.00,
|
|
109
|
-
"settlementTimestamp": "2026-04-15T10:32:18Z",
|
|
110
|
-
"networkOutcome": "SIMULATED_HTTP_200_SETTLED_CONFIRMED"
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
"stage7_general_ledger_double_entry_writeback": {
|
|
114
|
-
"erpSystem": "Enterprise ERP (SAP S/4HANA / Zoho Books / Tally Prime)",
|
|
115
|
-
"voucherNumber": "JV-2026-04-0042",
|
|
116
|
-
"postingDate": "2026-04-15",
|
|
117
|
-
"journalLines": [
|
|
118
|
-
{
|
|
119
|
-
"account": "Purchases / Cost of Goods Sold (IS 2062)",
|
|
120
|
-
"type": "DEBIT",
|
|
121
|
-
"amountInr": 6000000.00
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"account": "Input CGST Receivable (9%)",
|
|
125
|
-
"type": "DEBIT",
|
|
126
|
-
"amountInr": 540000.00
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"account": "Input SGST Receivable (9%)",
|
|
130
|
-
"type": "DEBIT",
|
|
131
|
-
"amountInr": 540000.00
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
"account": "TDS Payable under Section 194Q",
|
|
135
|
-
"type": "CREDIT",
|
|
136
|
-
"amountInr": 5500.00
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"account": "HDFC Corporate Bank Operating Account",
|
|
140
|
-
"type": "CREDIT",
|
|
141
|
-
"amountInr": 7074500.00
|
|
142
|
-
}
|
|
143
|
-
],
|
|
144
|
-
"totalDebitsInr": 7080000.00,
|
|
145
|
-
"totalCreditsInr": 7080000.00,
|
|
146
|
-
"netDiscrepancyInr": 0.00,
|
|
147
|
-
"equilibriumVerification": "PAISA_LEVEL_PERFECT_BALANCE"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ═══════════════════════════════════════════════════════════════════════════
|
|
5
|
-
* @mudraforge/statutory — End-to-End Execution Trace Simulator
|
|
6
|
-
* Demonstrates the Complete Bridge from OKF Tax Rules to Adesha Governance
|
|
7
|
-
* ═══════════════════════════════════════════════════════════════════════════
|
|
8
|
-
* Usage:
|
|
9
|
-
* node examples/simulate_end_to_end_trace.js
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import fs from 'node:fs';
|
|
13
|
-
import path from 'node:path';
|
|
14
|
-
import { fileURLToPath } from 'node:url';
|
|
15
|
-
import { lookupLocalStatute } from '../src/index.js';
|
|
16
|
-
|
|
17
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
-
const __dirname = path.dirname(__filename);
|
|
19
|
-
const TRACE_PATH = path.join(__dirname, 'invoice_deduction_trace.json');
|
|
20
|
-
|
|
21
|
-
export function runTraceSimulation() {
|
|
22
|
-
console.log('===========================================================================');
|
|
23
|
-
console.log('MUDRAFORGE & ADESHA: END-TO-END AP STATUTORY EXECUTION TRACE');
|
|
24
|
-
console.log('===========================================================================');
|
|
25
|
-
console.log('[NOTE] DEMONSTRATION FIXTURE ONLY:');
|
|
26
|
-
console.log('This trace models synthetic transaction data and simulated authorization,');
|
|
27
|
-
console.log('banking, and general ledger events to illustrate the Adesha governance contract.');
|
|
28
|
-
console.log('It does not connect to a real bank, verify a live biometric event, or execute a real payment.');
|
|
29
|
-
console.log('===========================================================================\n');
|
|
30
|
-
|
|
31
|
-
const trace = JSON.parse(fs.readFileSync(TRACE_PATH, 'utf8'));
|
|
32
|
-
|
|
33
|
-
// Stage 1: Incoming Invoice
|
|
34
|
-
console.log('── STAGE 1: INCOMING VENDOR INVOICE INGESTION ──');
|
|
35
|
-
const inv = trace.stage1_incoming_invoice;
|
|
36
|
-
console.log(`Invoice No: ${inv.invoiceNumber} (Dated: ${inv.invoiceDate})`);
|
|
37
|
-
console.log(`Vendor: ${inv.vendor.legalName} (PAN: ${inv.vendor.pan})`);
|
|
38
|
-
console.log(`Basic Value: INR ${inv.basicGoodsAmountInr.toLocaleString('en-IN')}`);
|
|
39
|
-
console.log(`GST (18%): INR ${inv.totalGstAmountInr.toLocaleString('en-IN')}`);
|
|
40
|
-
console.log(`Gross Total: INR ${inv.grossInvoiceAmountInr.toLocaleString('en-IN')}\n`);
|
|
41
|
-
|
|
42
|
-
// Stage 2: OKF Rule Resolution
|
|
43
|
-
console.log('── STAGE 2: OPEN KNOWLEDGE FORMAT (OKF) RULE RESOLUTION ──');
|
|
44
|
-
const statute = lookupLocalStatute('194Q');
|
|
45
|
-
console.log(`Provision: ${statute.statutorySection} (${statute.governingStatute})`);
|
|
46
|
-
console.log(`Successor: ${statute.successorStatute} (${statute.successorSection})`);
|
|
47
|
-
console.log(`Threshold: INR ${statute.keyStatutoryThresholds.annualPurchaseThresholdInr.toLocaleString('en-IN')}`);
|
|
48
|
-
console.log(`Standard Rate: ${statute.keyStatutoryThresholds.standardDeductionRatePercent}%`);
|
|
49
|
-
console.log(`Taxable Scope: ${statute.keyStatutoryThresholds.taxableBaseScope}\n`);
|
|
50
|
-
|
|
51
|
-
// Stage 3: Deterministic Statutory Computation
|
|
52
|
-
console.log('── STAGE 3: DETERMINISTIC STATUTORY COMPUTATION ──');
|
|
53
|
-
const calc = trace.stage3_deterministic_statutory_computation;
|
|
54
|
-
console.log(`Prior FY Purchases: INR ${calc.inputs.priorPurchasesInCurrentFYInr.toLocaleString('en-IN')}`);
|
|
55
|
-
console.log(`Cumulative Total: INR ${calc.inputs.cumulativeFYPurchasesInr.toLocaleString('en-IN')}`);
|
|
56
|
-
console.log(`Taxable Base (Excess): INR ${calc.calculationSteps.taxableBaseForThisInvoiceInr.toLocaleString('en-IN')}`);
|
|
57
|
-
console.log(`GST Excluded from Base: INR ${calc.calculationSteps.gstComponentExcludedInr.toLocaleString('en-IN')} (CBDT Circular 13/2021)`);
|
|
58
|
-
console.log(`TDS Deducted (0.1%): INR ${calc.calculationSteps.tdsDeductionCalculatedInr.toLocaleString('en-IN')}`);
|
|
59
|
-
console.log(`Net Payable to Vendor: INR ${calc.calculationSteps.netPayableToVendorInr.toLocaleString('en-IN')}\n`);
|
|
60
|
-
|
|
61
|
-
// Stage 4: Adesha Payment Authorization Lease
|
|
62
|
-
console.log('── STAGE 4: ADESHA CRYPTOGRAPHIC PAYMENT AUTHORIZATION LEASE ──');
|
|
63
|
-
const lease = trace.stage4_adesha_payment_authorization_lease;
|
|
64
|
-
console.log(`Lease ID: ${lease.leaseId}`);
|
|
65
|
-
console.log(`Single-Use Token: ${lease.singleUseLeaseToken}`);
|
|
66
|
-
console.log(`Max Authorized: INR ${lease.maximumAuthorizedDisbursementInr.toLocaleString('en-IN')}`);
|
|
67
|
-
console.log(`Lease State: ${lease.formalState}\n`);
|
|
68
|
-
|
|
69
|
-
// Stage 5: Human-In-The-Loop Approval
|
|
70
|
-
console.log('── STAGE 5: HUMAN-IN-THE-LOOP MOBILE HARNESS AUTHORIZATION ──');
|
|
71
|
-
const hitl = trace.stage5_human_in_the_loop_authorization;
|
|
72
|
-
console.log(`Channel: ${hitl.channel}`);
|
|
73
|
-
console.log(`Decision: ${hitl.decision}`);
|
|
74
|
-
console.log(`Authorized By: ${hitl.authorizedBy.role} (${hitl.authorizedBy.email})`);
|
|
75
|
-
console.log(`Auth Factor: ${hitl.authenticationFactor}`);
|
|
76
|
-
console.log(`State Transition: ${hitl.stateTransition}\n`);
|
|
77
|
-
|
|
78
|
-
// Stage 6: Banking Settlement
|
|
79
|
-
console.log('── STAGE 6: BANK RAIL DISBURSEMENT (HOST-TO-HOST RTGS) ──');
|
|
80
|
-
const bank = trace.stage6_banking_rail_disbursement;
|
|
81
|
-
console.log(`Bank Partner: ${bank.bankingPartner}`);
|
|
82
|
-
console.log(`Payment Rail: ${bank.rail}`);
|
|
83
|
-
console.log(`Bank UTR: ${bank.bankUniqueTransactionReference}`);
|
|
84
|
-
console.log(`Outcome: ${bank.networkOutcome} (${bank.disbursedAmountInr.toLocaleString('en-IN')} INR)\n`);
|
|
85
|
-
|
|
86
|
-
// Stage 7: General Ledger Writeback
|
|
87
|
-
console.log('── STAGE 7: GENERAL LEDGER BALANCED DOUBLE-ENTRY WRITEBACK ──');
|
|
88
|
-
const gl = trace.stage7_general_ledger_double_entry_writeback;
|
|
89
|
-
console.log(`Voucher No: ${gl.voucherNumber} (${gl.erpSystem})`);
|
|
90
|
-
for (const line of gl.journalLines) {
|
|
91
|
-
const amtStr = `INR ${line.amountInr.toLocaleString('en-IN', { minimumFractionDigits: 2 })}`;
|
|
92
|
-
console.log(` [${line.type.padEnd(6)}] ${line.account.padEnd(42)} ${amtStr.padStart(16)}`);
|
|
93
|
-
}
|
|
94
|
-
console.log(` -------------------------------------------------------------------`);
|
|
95
|
-
console.log(` Total Debits: INR ${gl.totalDebitsInr.toLocaleString('en-IN', { minimumFractionDigits: 2 })}`);
|
|
96
|
-
console.log(` Total Credits: INR ${gl.totalCreditsInr.toLocaleString('en-IN', { minimumFractionDigits: 2 })}`);
|
|
97
|
-
console.log(` Equilibrium: ${gl.equilibriumVerification} (Discrepancy: INR ${gl.netDiscrepancyInr.toFixed(2)})\n`);
|
|
98
|
-
|
|
99
|
-
console.log('===========================================================================');
|
|
100
|
-
console.log('[PASS] END-TO-END EXECUTION TRACE VERIFIED WITH ZERO DEFECTS.');
|
|
101
|
-
console.log('===========================================================================\n');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
105
|
-
runTraceSimulation();
|
|
106
|
-
}
|