{
  "schemaVersion": 1,
  "slug": "price-match-savings-calculator",
  "category": "shopping",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "2260f4e4b4c977f9ada40a87f342ed6c3893e0279e7b9292af7af4667743ffc1",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/price-match-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": "Pm = P − max(0, P − Pc) × m ÷ 100; S = (P − Pm) × q; R = S ÷ (t ÷ 60); B = Pc × q × b ÷ 100",
    "vars": [
      [
        "P",
        "Your price"
      ],
      [
        "Pc",
        "Competitor price"
      ],
      [
        "m",
        "Matched percentage (%)"
      ],
      [
        "q",
        "Number of items"
      ],
      [
        "S",
        "Total saving"
      ],
      [
        "R",
        "Effective hourly rate"
      ],
      [
        "t",
        "Minutes needed to claim"
      ],
      [
        "b",
        "Cashback (%)"
      ],
      [
        "B",
        "Cashback amount"
      ]
    ],
    "note": "Matched price = own price − max(0, own price − competitor price) × match percentage (0–100%). Savings and optional cashback use entered quantities. Percent savings is undefined when own price is zero; savings per hour is undefined at zero claim time. Actual retailer eligibility varies."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const gap = Math.max(0, yourPrice-competitorPrice); const matched = yourPrice-gap*(matchPercent/100); const cashbackValue = competitorPrice*items*cashbackPercent/100; const totalSaving = (yourPrice-matched)*items; return { matchedPrice: matched, savingPerItem: yourPrice-matched, totalSaving, savingPercent: yourPrice > 0 ? (yourPrice-matched)/yourPrice*100 : null, effectiveHourlyRate: minutesToClaim > 0 ? totalSaving/(minutesToClaim/60) : null, cashbackValue };",
    "inputs": [
      {
        "name": "yourPrice",
        "type": "number",
        "default": 249,
        "min": 0,
        "max": 100000,
        "step": 0.01
      },
      {
        "name": "competitorPrice",
        "type": "number",
        "default": 199,
        "min": 0,
        "max": 100000,
        "step": 0.01
      },
      {
        "name": "matchPercent",
        "type": "number",
        "default": 100,
        "min": 0,
        "max": 100,
        "step": 5,
        "slider": true
      },
      {
        "name": "items",
        "type": "number",
        "default": 1,
        "min": 1,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "minutesToClaim",
        "type": "number",
        "default": 15,
        "min": 0,
        "max": 480,
        "step": 5,
        "slider": true
      },
      {
        "name": "cashbackPercent",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 20,
        "step": 0.5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "matchedPrice",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "savingPerItem",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "totalSaving",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "savingPercent",
        "precision": 2,
        "unit": "%",
        "optional": true
      },
      {
        "name": "effectiveHourlyRate",
        "precision": 2,
        "unit": "$/h",
        "optional": true
      },
      {
        "name": "cashbackValue",
        "precision": 2,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
