{
  "schemaVersion": 1,
  "slug": "sales-tax-calculator",
  "category": "finance",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "3bf8230978ced16d1f713b4f709df82777b1def35f6b477af8e19a1d62d25801",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/sales-tax-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "m = 0 → T = A(1 + r ÷ 100); m = 1 → N = A ÷ (1 + r ÷ 100); m ∈ {0,1}",
    "vars": [
      [
        "A",
        "Entered amount"
      ],
      [
        "r",
        "Tax rate (%)"
      ],
      [
        "m",
        "Mode: 0 add tax, 1 remove tax"
      ],
      [
        "T",
        "Gross total with tax"
      ],
      [
        "N",
        "Net before tax"
      ]
    ],
    "note": "Add mode: tax = A × r ÷ 100. Remove mode: tax = A - N; the amount is treated as already tax-inclusive."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if(mode === 'remove'){ const net = amount/(1+taxRate/100); return { net, tax: amount-net, total: amount }; } const tax = amount*taxRate/100; return { net: amount, tax, total: amount+tax };",
    "inputs": [
      {
        "name": "amount",
        "type": "number",
        "default": 100,
        "min": 0,
        "max": 1000000000,
        "step": 1
      },
      {
        "name": "taxRate",
        "type": "number",
        "default": 8.5,
        "min": 0,
        "max": 50,
        "step": 0.01,
        "slider": true
      },
      {
        "name": "mode",
        "type": "select",
        "default": "add",
        "options": [
          {
            "value": "add"
          },
          {
            "value": "remove"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "net",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "tax",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "total",
        "precision": 2,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
