INTEGRATION / PACKING-STATION

Packing stations: box choice and loading order

Turn an order released by the WMS into the carton to use, the order to load it in, a CSV the WMS imports back and a printable work order.

WHERE IT SITS

At the pick-and-pack step of a warehouse: the WMS releases an order, a packer needs to know which carton to build and what goes in first.

HOW THE DATA FLOWS
  1. 01

    The WMS releases an order with item dimensions, weights and handling flags such as keep_upright.

  2. 02

    pack() chooses the carton and places every item; anything that cannot go is named with a reason.

  3. 03

    safeLoadingOrder() orders each carton supports-first, so every item has a clear path in.

  4. 04

    buildOperationalArtifact() bundles plan, request and order into one document; exportCsv and exportWorkOrderHtml turn it into a WMS import and a sheet to print.

THE WHOLE PROGRAM, IN Node / JavaScript
import { pack, safeLoadingOrder } from '@packvium/engine';
import { buildOperationalArtifact } from '@packvium/engine/artifacts.js';
import { exportCsv, exportWorkOrderHtml } from '@packvium/engine/artifact-exports.js';

// One order as the WMS releases it to a packing station.
const request = {
  items: [
    { id: 'monitor', quantity: 1, weight: '5 kg', keep_upright: true,
      dimensions: { length: '600', width: '180', height: '420' }, metadata: { order: 'SO-2291' } },
    { id: 'keyboard', quantity: 2, weight: '900 g', dimensions: { length: '450', width: '150', height: '40' } },
    { id: 'cable', quantity: 3, weight: '120 g', dimensions: { length: '150', width: '100', height: '40' } },
  ],
  containers: [
    { id: 'carton-60', quantity: 2, inner_dimensions: { length: '620', width: '400', height: '450' } },
  ],
};

const result = pack(request);

// A loading order per box: supports first, every item with a clear path in.
const loadingOrders = {};
result.containers.forEach((box, index) => {
  const ticks = (box3) => ({ length: box3.length.ticks, width: box3.width.ticks, height: box3.height.ticks });
  loadingOrders[index] = safeLoadingOrder(
    box.placements.map((placement) => ({
      origin: { x: placement.position.x.ticks, y: placement.position.y.ticks, z: placement.position.z.ticks },
      dimensions: ticks(placement.dimensions),
    })),
    ticks(box.inner_dimensions),
  );
});

// One document for the station: the plan, the request it answers, and the order to load in.
const artifact = buildOperationalArtifact(request, result, { loadingOrders });
const csv = exportCsv(artifact);              // import into the WMS
const html = exportWorkOrderHtml(artifact);   // print at the station

console.log(result.containers.length, 'carton(s),', artifact.plan.containers[0].steps.length, 'steps, order', artifact.plan.containers[0].order);
console.log(csv.split('\r\n')[1]);
console.log(html.length > 0 ? 'work order ready' : 'no work order');
WHAT IT DOES

The order fits one carton in six steps, and the plan states its order as loading rather than unavailable. The CSV has one row per step - item, orientation, position in exact ticks and in millimetres - and the work order is self-contained HTML with no script, ready to print at the station.

Every program on these pages is run exactly as printed by this site's test suite, against the published package, on every change.

WHAT TO KEEP

Store the artifact's canonical JSON (exportJson) next to the order. It holds the request it answers, so anyone can replay it later without the engine version that made it; the CSV and the HTML are derived from it and need not be kept.

WHEN THE ENGINE SAYS NO

An item that fits no carton is listed in the CSV as an unplaced row with its reason and proof level, so the WMS can route it to an exception lane instead of a packer discovering it at the bench. When no safe loading order exists for a carton, the plan says unavailable for it rather than inventing one.

INSTALL
npm install @packvium/engine