{
  "schemaVersion": 1,
  "slug": "pallet-calculator",
  "category": "moving",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "2ef41881a4c804eded3e9d879a7a0e4e5ba1c4c8928d3d552c76880f288d4205",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/pallet-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": "n = max(floor(PW÷L) floor(PL÷W), floor(PW÷W) floor(PL÷L)); Q = n × max(1, floor(Hm÷H)); pallets = ceil(N÷Q)",
    "vars": [
      [
        "PW,PL",
        "Pallet width and length (mm, by type)"
      ],
      [
        "L",
        "Carton length (mm)"
      ],
      [
        "W",
        "Carton width (mm)"
      ],
      [
        "H",
        "Carton height (mm)"
      ],
      [
        "Hm",
        "Maximum stack height (mm)"
      ],
      [
        "N",
        "Total cartons"
      ]
    ],
    "note": "Cartons per layer uses the better of two simple orientations; layers = floor(max height ÷ carton height). Total shipment weight = all carton weight + empty weight of every required pallet; last pallet may be partial. Volume fill uses the full permitted stack volume."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const dims={euro:[1200,800],gma:[1219,1016],industrial:[1200,1200]},p=dims[palletType]||dims.euro,PW=p[0],PL=p[1],n1=Math.floor(PW/boxLength)*Math.floor(PL/boxWidth),n2=Math.floor(PW/boxWidth)*Math.floor(PL/boxLength),best=Math.max(n1,n2),layers=Math.floor(maxHeight/boxHeight);if(best===0||layers===0)return{perLayerNormal:n1,perLayerRotated:n2,bestPerLayer:best,layers:0,perPallet:0,palletsNeeded:null,totalWeight:null,perPalletWeight:null,volumeEfficiency:null,__error:'inputError'};const perPallet=best*layers,palletsNeeded=Math.ceil(totalCartons/perPallet),perPalletWeight=perPallet*boxWeight+palletWeight,totalWeight=totalCartons*boxWeight+palletsNeeded*palletWeight,volumeEfficiency=Math.min(100,perPallet*boxLength*boxWidth*boxHeight/(PW*PL*maxHeight)*100);return{perLayerNormal:n1,perLayerRotated:n2,bestPerLayer:best,layers,perPallet,palletsNeeded,totalWeight,perPalletWeight,volumeEfficiency}",
    "inputs": [
      {
        "name": "palletType",
        "type": "select",
        "default": "euro",
        "options": [
          {
            "value": "euro"
          },
          {
            "value": "gma"
          },
          {
            "value": "industrial"
          }
        ]
      },
      {
        "name": "boxLength",
        "type": "number",
        "default": 400,
        "min": 1,
        "max": 3000,
        "step": 1,
        "slider": true
      },
      {
        "name": "boxWidth",
        "type": "number",
        "default": 300,
        "min": 1,
        "max": 3000,
        "step": 1,
        "slider": true
      },
      {
        "name": "boxHeight",
        "type": "number",
        "default": 200,
        "min": 1,
        "max": 3000,
        "step": 1,
        "slider": true
      },
      {
        "name": "boxWeight",
        "type": "number",
        "default": 8,
        "min": 0,
        "max": 1000,
        "step": 0.1
      },
      {
        "name": "maxHeight",
        "type": "number",
        "default": 1800,
        "min": 100,
        "max": 4000,
        "step": 50,
        "slider": true
      },
      {
        "name": "palletWeight",
        "type": "number",
        "default": 25,
        "min": 0,
        "max": 200,
        "step": 1,
        "slider": true
      },
      {
        "name": "totalCartons",
        "type": "number",
        "default": 500,
        "min": 1,
        "max": 1000000,
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "perLayerNormal",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "perLayerRotated",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "bestPerLayer",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "layers",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "perPallet",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "palletsNeeded",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "totalWeight",
        "precision": 1,
        "unit": "kg"
      },
      {
        "name": "volumeEfficiency",
        "precision": 1,
        "unit": "%"
      },
      {
        "name": "perPalletWeight",
        "precision": 1,
        "unit": "kg"
      }
    ],
    "interpret": null
  }
}
