{
  "schemaVersion": 1,
  "slug": "subscription-cost-calculator",
  "category": "shopping",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "6279f3aa0e92569f66db96b10011dd5bb3aab27a39ca4242218f7b1ab2ed38bb",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/subscription-cost-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": "FV = 12np × (((1 + r)^t − 1) ÷ r)",
    "vars": [
      [
        "n",
        "Number of subscriptions"
      ],
      [
        "p",
        "Average monthly cost each"
      ],
      [
        "r",
        "Annual return rate (decimal)"
      ],
      [
        "t",
        "Number of years"
      ],
      [
        "FV",
        "Value if invested instead"
      ]
    ],
    "note": "Unused annual spend = subscription cost × entered unused share. Hypothetical investment value compounds annual contributions made at year-end at the entered return; it does not project actual returns."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const monthlyCost=subscriptions*averageCost; const yearlyCost=monthlyCost*12; const wastedPerYear=yearlyCost*unusedPercent/100; const fiveYearCost=yearlyCost*years; const r=investmentReturn/100; const investedValue=r>0?wastedPerYear*((Math.pow(1+r,years)-1)/r):wastedPerYear*years; return {monthlyCost,yearlyCost,wastedPerYear,fiveYearCost,investedValue,opportunityCost:investedValue-wastedPerYear*years};",
    "inputs": [
      {
        "name": "subscriptions",
        "type": "number",
        "default": 6,
        "min": 0,
        "max": 200,
        "step": 1,
        "slider": true
      },
      {
        "name": "averageCost",
        "type": "number",
        "default": 14.99,
        "min": 0,
        "max": 1000,
        "step": 0.01
      },
      {
        "name": "unusedPercent",
        "type": "number",
        "default": 30,
        "min": 0,
        "max": 100,
        "step": 5,
        "slider": true
      },
      {
        "name": "investmentReturn",
        "type": "number",
        "default": 7,
        "min": 0,
        "max": 30,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "years",
        "type": "number",
        "default": 5,
        "min": 1,
        "max": 40,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "monthlyCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "yearlyCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "wastedPerYear",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "fiveYearCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "investedValue",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "opportunityCost",
        "precision": 2,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
