{
  "schemaVersion": 1,
  "slug": "black-friday-savings-calculator",
  "category": "shopping",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "2b8f45e50fa3f97101c415815f4e186574a44efe0c487acd1c5f6beb5453854a",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/black-friday-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": "D = (1 − deal/ref) × 100",
    "vars": [
      [
        "deal",
        "Deal price"
      ],
      [
        "ref",
        "Reference price (listed or recent low)"
      ],
      [
        "D",
        "Discount percent (can be negative)"
      ]
    ],
    "note": "Verdict vs the recent low: real deal above +5%, marginal from −2% to +5%, otherwise not a deal; saving vs average = average − deal."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const claimedDiscount = listedPrice > 0 ? (1-dealPrice/listedPrice)*100 : 0; const realDiscountVsRecent = lowestRecentPrice > 0 ? (1-dealPrice/lowestRecentPrice)*100 : 0; const savingVsAverage = averagePrice-dealPrice; const verdict = realDiscountVsRecent > 5 ? 'Yes — cheaper than it has been recently' : realDiscountVsRecent > -2 ? 'Marginal — about the same as the recent low' : 'No — it has been cheaper in the last three months'; const advice = needed === 'no' ? 'The biggest saving here is not buying it at all' : needed === 'maybe' ? 'Only a real deal if it is replacing something you already planned to buy' : 'Price is competitive — buying now is reasonable'; return { claimedDiscount, realDiscountVsRecent, savingVsAverage, verdict, advice };",
    "inputs": [
      {
        "name": "dealPrice",
        "type": "number",
        "default": 299,
        "min": 0,
        "max": 100000,
        "step": 0.01
      },
      {
        "name": "listedPrice",
        "type": "number",
        "default": 499,
        "min": 0,
        "max": 100000,
        "step": 0.01
      },
      {
        "name": "lowestRecentPrice",
        "type": "number",
        "default": 379,
        "min": 0,
        "max": 100000,
        "step": 0.01
      },
      {
        "name": "averagePrice",
        "type": "number",
        "default": 420,
        "min": 0,
        "max": 100000,
        "step": 0.01
      },
      {
        "name": "needed",
        "type": "select",
        "default": "maybe",
        "options": [
          {
            "value": "yes"
          },
          {
            "value": "maybe"
          },
          {
            "value": "no"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "claimedDiscount",
        "precision": 1,
        "unit": "%"
      },
      {
        "name": "realDiscountVsRecent",
        "precision": 1,
        "unit": "%"
      },
      {
        "name": "savingVsAverage",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "verdict",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "advice",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
