{
  "schemaVersion": 1,
  "slug": "cbm-shipping-calculator",
  "category": "moving",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "bab9939e79af41b123fc5f21ed615b4eed418940e0ae1f6b317ba86cde3af26b",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/cbm-shipping-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": "Cost = max(V·r_v, W_c·r_w),  V = n·L·W·H ÷ 10⁶,  W_g = n·w,  W_c = max(W_g, V·10⁶ ÷ d)",
    "vars": [
      [
        "Cost",
        "Freight charge"
      ],
      [
        "V",
        "Total volume (CBM)"
      ],
      [
        "W_c",
        "Chargeable weight"
      ],
      [
        "r_v",
        "Rate per CBM"
      ],
      [
        "r_w",
        "Rate per kg"
      ],
      [
        "n",
        "Number of boxes"
      ],
      [
        "L",
        "Box length (cm)"
      ],
      [
        "W",
        "Box width (cm)"
      ],
      [
        "H",
        "Box height (cm)"
      ],
      [
        "w",
        "Weight per box (kg)"
      ],
      [
        "W_g",
        "Total gross weight"
      ],
      [
        "d",
        "Volumetric divisor"
      ]
    ],
    "note": "Dimensions in cm; d = volumetric divisor (6000 air, 5000 courier, 4000 express, 139 in³/lb US)."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const empty={totalCbm:null,totalWeight:null,volumetricWeight:null,chargeableWeight:null,chargedOn:null,freightCost:null,containerEquivalent:null,cbmPerBox:null};const divisors=[6000,5000,4000,139];if(!Number.isInteger(boxCount)||boxCount<1||boxLength<=0||boxWidth<=0||boxHeight<=0||boxWeight<0||!divisors.includes(Number(divisor))||ratePerCbm<0||ratePerKg<0)return{...empty,__error:'inputError'};const volumeCm3=boxLength*boxWidth*boxHeight;const perBox=volumeCm3/1000000;const cbm=perBox*boxCount;const weight=boxWeight*boxCount;const volWeight=Number(divisor)===139?volumeCm3/16.387064/139*0.45359237*boxCount:volumeCm3/Number(divisor)*boxCount;const chargeable=Math.max(weight,volWeight);const byCbm=cbm*ratePerCbm;const byKg=chargeable*ratePerKg;const cost=Math.max(byCbm,byKg);const container=cbm<=33.1?'Fits in a 20 ft container':cbm<=67.7?'Needs a 40 ft container':cbm<=86?'Needs a 45 ft high cube': 'Needs '+Math.ceil(cbm/76.3)+' x 40 ft high cube containers';return{totalCbm:cbm,totalWeight:weight,volumetricWeight:volWeight,chargeableWeight:chargeable,chargedOn:volWeight>weight?'Volumetric weight (bulky light goods)':'Actual weight (dense goods)',freightCost:cost,containerEquivalent:container,cbmPerBox:perBox};",
    "inputs": [
      {
        "name": "boxCount",
        "type": "number",
        "default": 20,
        "min": 1,
        "max": 100000,
        "step": 1
      },
      {
        "name": "boxLength",
        "type": "number",
        "default": 60,
        "min": 1,
        "max": 1000,
        "step": 0.1
      },
      {
        "name": "boxWidth",
        "type": "number",
        "default": 40,
        "min": 1,
        "max": 1000,
        "step": 0.1
      },
      {
        "name": "boxHeight",
        "type": "number",
        "default": 40,
        "min": 1,
        "max": 1000,
        "step": 0.1
      },
      {
        "name": "boxWeight",
        "type": "number",
        "default": 12,
        "min": 0,
        "max": 10000,
        "step": 0.1
      },
      {
        "name": "divisor",
        "type": "select",
        "default": 6000,
        "options": [
          {
            "value": 6000
          },
          {
            "value": 5000
          },
          {
            "value": 4000
          },
          {
            "value": 139
          }
        ]
      },
      {
        "name": "ratePerCbm",
        "type": "number",
        "default": 120,
        "min": 0,
        "max": 100000,
        "step": 1
      },
      {
        "name": "ratePerKg",
        "type": "number",
        "default": 3,
        "min": 0,
        "max": 10000,
        "step": 0.01
      }
    ],
    "outputs": [
      {
        "name": "totalCbm",
        "precision": 4,
        "unit": "m³"
      },
      {
        "name": "totalWeight",
        "precision": 2,
        "unit": "kg"
      },
      {
        "name": "volumetricWeight",
        "precision": 2,
        "unit": "kg"
      },
      {
        "name": "chargeableWeight",
        "precision": 2,
        "unit": "kg"
      },
      {
        "name": "chargedOn",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "freightCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "containerEquivalent",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "cbmPerBox",
        "precision": 5,
        "unit": "m³"
      }
    ],
    "interpret": null
  }
}
