{
  "schemaVersion": 1,
  "slug": "gift-card-balance-tracker-calculator",
  "category": "shopping",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "5eaec10522df31e7ce3fefa35c379d5d96d977c9a3401a57496c2559ba9d43eb",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/gift-card-balance-tracker-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": "R = max(0, V − Σs_i − f×m)",
    "vars": [
      [
        "R",
        "Remaining balance"
      ],
      [
        "V",
        "Original card value"
      ],
      [
        "Σs_i",
        "Sum of all purchases"
      ],
      [
        "f",
        "Monthly inactivity fee"
      ],
      [
        "m",
        "Months inactive"
      ]
    ],
    "note": "Any inactivity fee is user-entered for illustration. Expiration and fee rules depend on the card terms and applicable local law; verify with the issuer or local authority."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const totalSpent = spent1+spent2+spent3; const fees = monthlyFee*monthsInactive; const remaining = Math.max(0, originalValue-totalSpent-fees); return { totalSpent, fees, remaining, usedPercent: originalValue > 0 ? (totalSpent+fees)/originalValue*100 : 0, note: monthlyFee > 0 && monthsInactive > 6 ? 'The entered inactivity fee is reducing the estimated balance; verify the card terms and local rules' : 'No fee entered; check the card terms for expiration and inactivity rules' };",
    "inputs": [
      {
        "name": "originalValue",
        "type": "number",
        "default": 100,
        "min": 0,
        "max": 10000,
        "step": 1
      },
      {
        "name": "spent1",
        "type": "number",
        "default": 35,
        "min": 0,
        "max": 10000,
        "step": 0.01
      },
      {
        "name": "spent2",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 10000,
        "step": 0.01
      },
      {
        "name": "spent3",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 10000,
        "step": 0.01
      },
      {
        "name": "monthlyFee",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 50,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "monthsInactive",
        "type": "number",
        "default": 3,
        "min": 0,
        "max": 120,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "totalSpent",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "fees",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "remaining",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "usedPercent",
        "precision": 1,
        "unit": "%"
      },
      {
        "name": "note",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
