{
  "schemaVersion": 1,
  "slug": "cashback-calculator",
  "category": "shopping",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "be3bd50deebb6ec96ea6d424639f87d40336affad5caff4064133a03849961bb",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/cashback-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": "Net = 12 × [(S − S_c)·r ÷ 100 + S_c·r_c ÷ 100] − F",
    "vars": [
      [
        "Net",
        "Net cashback per year"
      ],
      [
        "S",
        "Total monthly spend"
      ],
      [
        "S_c",
        "Bonus-category monthly spend"
      ],
      [
        "r",
        "Base cashback rate (%)"
      ],
      [
        "r_c",
        "Bonus-category rate (%)"
      ],
      [
        "F",
        "Annual card fee"
      ]
    ],
    "note": "Annual reward uses monthly base and category spend × 12 × reward rates. The one-time bonus qualifies when monthly spend × qualification months ≥ required spend; annual fee is subtracted each model year."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const empty={annualCashback:null,bonusValue:null,netPerYear:null,totalOverPeriod:null,effectiveRate:null,note:null};if(categorySpend>monthlySpend||!Number.isInteger(bonusPeriodMonths)||!Number.isInteger(years))return{...empty,__error:'inputError'};const baseSpend=monthlySpend-categorySpend;const annualCashback=(baseSpend*cashbackRate/100+categorySpend*categoryRate/100)*12;const bonusEligible=monthlySpend*bonusPeriodMonths>=bonusSpendRequired?1:0;const bonusValue=signupBonus*bonusEligible;const netPerYear=annualCashback-annualFee;return{annualCashback,bonusValue,netPerYear,totalOverPeriod:netPerYear*years+bonusValue,effectiveRate:monthlySpend>0?netPerYear/(monthlySpend*12)*100:0,note:bonusEligible?'You meet the minimum spend for the sign-up bonus':'You would need to spend more to earn the sign-up bonus'};",
    "inputs": [
      {
        "name": "monthlySpend",
        "type": "number",
        "default": 1200,
        "min": 0,
        "max": 500000,
        "step": 50
      },
      {
        "name": "cashbackRate",
        "type": "number",
        "default": 2,
        "min": 0,
        "max": 20,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "annualFee",
        "type": "number",
        "default": 95,
        "min": 0,
        "max": 2000,
        "step": 5,
        "slider": true
      },
      {
        "name": "signupBonus",
        "type": "number",
        "default": 200,
        "min": 0,
        "max": 5000,
        "step": 25,
        "slider": true,
        "advanced": true
      },
      {
        "name": "bonusSpendRequired",
        "type": "number",
        "default": 3000,
        "min": 0,
        "max": 100000,
        "step": 100,
        "slider": true,
        "advanced": true
      },
      {
        "name": "bonusPeriodMonths",
        "type": "number",
        "default": 3,
        "min": 1,
        "max": 24,
        "step": 1,
        "advanced": true
      },
      {
        "name": "categoryRate",
        "type": "number",
        "default": 3,
        "min": 0,
        "max": 20,
        "step": 0.1,
        "slider": true,
        "advanced": true
      },
      {
        "name": "categorySpend",
        "type": "number",
        "default": 300,
        "min": 0,
        "max": 200000,
        "step": 25,
        "advanced": true
      },
      {
        "name": "years",
        "type": "number",
        "default": 3,
        "min": 1,
        "max": 20,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "annualCashback",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "bonusValue",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "netPerYear",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "totalOverPeriod",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "effectiveRate",
        "precision": 2,
        "unit": "%"
      },
      {
        "name": "note",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
