{
  "schemaVersion": 1,
  "slug": "dimensional-weight-calculator",
  "category": "moving",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "53cd8a6a2dbe247538971ef251a1d12d9cfc168642bff82035434d940b7cca37",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/dimensional-weight-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": "u ∈ {cm, in}; k = {2.20462, u = cm ∨ d ≥ 1000; 1, u = in ∧ d < 1000}; Q = max(A, L × W × H ÷ d × k)",
    "vars": [
      [
        "L",
        "length"
      ],
      [
        "W",
        "width"
      ],
      [
        "H",
        "height"
      ],
      [
        "d",
        "carrier divisor"
      ],
      [
        "u",
        "dimension unit, cm or in"
      ],
      [
        "A",
        "actual weight"
      ],
      [
        "k",
        "kg-to-lb conversion factor"
      ],
      [
        "Q",
        "chargeable weight"
      ]
    ],
    "note": "For inches: L×W×H÷divisor gives lb. For cm with divisor 5000: L×W×H÷5000 gives kg, converted to lb by ×2.20462. Chargeable estimate = max(actual, dimensional); carrier rules vary."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const metric=unit==='cm'; const validDivisor=metric?Number(divisor)===5000:[139,166].includes(Number(divisor)); const vol=length*width*height; if(!validDivisor)return {cubicInches:null,dimensionalWeight:null,chargeableWeight:null,chargedOn:null,weightDifference:null,costMultiplier:null}; const dimWeight=metric?vol/Number(divisor)*2.20462:vol/Number(divisor); const actual=actualWeight,chargeable=Math.max(actual,dimWeight); return {cubicInches:metric?vol/16.3871:vol,dimensionalWeight:dimWeight,chargeableWeight:chargeable,chargedOn:dimWeight>actual?'Dimensional weight — the parcel is bulky':'Actual weight',weightDifference:dimWeight-actual,costMultiplier:actual>0?chargeable/actual:1};",
    "inputs": [
      {
        "name": "length",
        "type": "number",
        "default": 20,
        "min": 0.1,
        "max": 1000,
        "step": 0.1
      },
      {
        "name": "width",
        "type": "number",
        "default": 16,
        "min": 0.1,
        "max": 1000,
        "step": 0.1
      },
      {
        "name": "height",
        "type": "number",
        "default": 12,
        "min": 0.1,
        "max": 1000,
        "step": 0.1
      },
      {
        "name": "actualWeight",
        "type": "number",
        "default": 5,
        "min": 0,
        "max": 10000,
        "step": 0.1
      },
      {
        "name": "divisor",
        "type": "select",
        "default": 139,
        "options": [
          {
            "value": 139
          },
          {
            "value": 166
          },
          {
            "value": 5000
          }
        ]
      },
      {
        "name": "unit",
        "type": "select",
        "default": "in",
        "options": [
          {
            "value": "in"
          },
          {
            "value": "cm"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "cubicInches",
        "precision": 1,
        "unit": "in³",
        "optional": true
      },
      {
        "name": "dimensionalWeight",
        "precision": 2,
        "unit": "lb",
        "optional": true
      },
      {
        "name": "chargeableWeight",
        "precision": 2,
        "unit": "lb",
        "optional": true
      },
      {
        "name": "chargedOn",
        "precision": 0,
        "unit": "",
        "type": "text",
        "optional": true
      },
      {
        "name": "weightDifference",
        "precision": 2,
        "unit": "lb",
        "optional": true
      },
      {
        "name": "costMultiplier",
        "precision": 2,
        "unit": "x",
        "optional": true
      }
    ],
    "interpret": null
  }
}
