{
  "schemaVersion": 1,
  "slug": "coupon-savings-calculator",
  "category": "shopping",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "bf4f0115a114b13f56261986c0591cb2883f42a61c470db693f255a25abde846",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/coupon-savings-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": "A = 12 × t × (n × s − x) − 12 × t × (m ÷ 60) × v",
    "vars": [
      [
        "t",
        "Trips per month"
      ],
      [
        "n",
        "Items per trip"
      ],
      [
        "s",
        "Average saving per item"
      ],
      [
        "x",
        "Extra spend per trip"
      ],
      [
        "m",
        "Minutes per trip"
      ],
      [
        "v",
        "Value of your time per hour"
      ]
    ],
    "note": "Annual net savings = (items × saving per coupon − extra spend per trip) × trips per month × 12 − (minutes per trip ÷ 60 × hourly time value × trips per month × 12)."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const grossSavingPerTrip = itemsPerTrip*averageSaving; const netSavingPerTrip = grossSavingPerTrip-extraSpend; const monthlySaving = netSavingPerTrip*tripsPerMonth; const timeCostPerYear = minutesPerTrip/60*timeValue*tripsPerMonth*12; return { grossSavingPerTrip, netSavingPerTrip, monthlySaving, yearlySaving: monthlySaving*12, timeCostPerYear, trueSaving: monthlySaving*12-timeCostPerYear };",
    "inputs": [
      {
        "name": "itemsPerTrip",
        "type": "number",
        "default": 8,
        "min": 0,
        "max": 200,
        "step": 1,
        "slider": true
      },
      {
        "name": "averageSaving",
        "type": "number",
        "default": 1.25,
        "min": 0,
        "max": 100,
        "step": 0.05,
        "slider": true
      },
      {
        "name": "tripsPerMonth",
        "type": "number",
        "default": 4,
        "min": 1,
        "max": 60,
        "step": 1,
        "slider": true
      },
      {
        "name": "extraSpend",
        "type": "number",
        "default": 6,
        "min": 0,
        "max": 500,
        "step": 1,
        "slider": true
      },
      {
        "name": "minutesPerTrip",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 600,
        "step": 5,
        "slider": true
      },
      {
        "name": "timeValue",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 1000,
        "step": 5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "grossSavingPerTrip",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "netSavingPerTrip",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "monthlySaving",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "yearlySaving",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "timeCostPerYear",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "trueSaving",
        "precision": 0,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
