{
  "schemaVersion": 1,
  "slug": "investment-calculator-germany",
  "category": "finance",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "bde1da1d0f9702e3675641d799f4259bd054314c23b07087cf4986eee5545f0d",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/investment-calculator-germany.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": "tax = max(0, gain − allowance) × base tax rate × (1 + 5.5% solidarity surcharge + church-tax rate)",
    "vars": [
      [
        "B_k",
        "Balance after k months"
      ],
      [
        "r_m",
        "Monthly rate"
      ],
      [
        "r_a",
        "Annual return (%)"
      ],
      [
        "M",
        "Monthly contribution (€)"
      ],
      [
        "n",
        "Number of months"
      ]
    ],
    "note": "No money-weighted annualized return is calculated. The simplified tax is based on the entered rates and one aggregate allowance."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const r=annualReturn/100; const rm=Math.pow(1+r,1/12)-1; const n=Math.max(0,Math.round(years*12)); let bal=initialAmount; for(let i=0;i<n;i++) bal=bal*(1+rm)+monthlyContribution; const contributed=initialAmount+monthlyContribution*n; const gain=bal-contributed; const taxable=Math.max(0,gain-allowance); const baseTax=taxable*taxRate/100; const tax=baseTax*(1+0.055+churchTaxRate/100); const net=bal-tax; const deflator=Math.pow(1+inflationRate/100,years); return {grossBalance:bal,totalContributed:contributed,totalGain:gain,taxableGain:taxable,taxDue:tax,netBalance:net,realValue:deflator>0?net/deflator:net};",
    "inputs": [
      {
        "name": "initialAmount",
        "type": "number",
        "default": 10000,
        "min": 0,
        "max": 5000000,
        "step": 100
      },
      {
        "name": "monthlyContribution",
        "type": "number",
        "default": 250,
        "min": 0,
        "max": 100000,
        "step": 10
      },
      {
        "name": "annualReturn",
        "type": "number",
        "default": 7,
        "min": -20,
        "max": 30,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "years",
        "type": "number",
        "default": 20,
        "min": 1,
        "max": 60,
        "step": 1,
        "slider": true
      },
      {
        "name": "allowance",
        "type": "number",
        "default": 1000,
        "min": 0,
        "max": 5000,
        "step": 1,
        "slider": true
      },
      {
        "name": "taxRate",
        "type": "number",
        "default": 25,
        "min": 0,
        "max": 60,
        "step": 0.005
      },
      {
        "name": "churchTaxRate",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 10,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "inflationRate",
        "type": "number",
        "default": 2,
        "min": 0,
        "max": 20,
        "step": 0.1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "grossBalance",
        "precision": 2,
        "unit": "€"
      },
      {
        "name": "totalContributed",
        "precision": 2,
        "unit": "€"
      },
      {
        "name": "totalGain",
        "precision": 2,
        "unit": "€"
      },
      {
        "name": "taxableGain",
        "precision": 2,
        "unit": "€"
      },
      {
        "name": "taxDue",
        "precision": 2,
        "unit": "€"
      },
      {
        "name": "netBalance",
        "precision": 2,
        "unit": "€"
      },
      {
        "name": "realValue",
        "precision": 2,
        "unit": "€"
      }
    ],
    "interpret": null
  }
}
