Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix(picking): show unit of measure and allow sub-1 batch picks (#1757)
Sid9aa6d1a5fff5
diff --git a/apps/erp/app/modules/inventory/inventory.service.ts b/apps/erp/app/modules/inventory/inventory.service.tsindex 28cba44ff5..912fa124f1 100644--- a/apps/erp/app/modules/inventory/inventory.service.ts+++ b/apps/erp/app/modules/inventory/inventory.service.ts@@ -2816,7 +2816,7 @@ export async function getPickingListLines(return client.from("pickingListLine").select(- "*, item(name, readableId, itemTrackingType), jobMaterial(itemId, quantity, substitutionFactor, item(readableId, itemSupersession!itemSupersession_itemId_fkey(conversionFactor))), job(jobId), jobOperation(order, processId, workCenterId, process:process(name), workCenter:workCenter(name)), storageUnit:storageUnit!pickingListLine_storageUnitId_fkey(name, locationId), toStorageUnit:storageUnit!pickingListLine_toStorageUnitId_fkey(name, locationId), trackedEntities:pickingListLineTrackedEntity(trackedEntityId, quantity, quantityPicked, trackedEntity(readableId))"+ "*, item(name, readableId, itemTrackingType, unitOfMeasureCode), jobMaterial(itemId, quantity, substitutionFactor, item(readableId, itemSupersession!itemSupersession_itemId_fkey(conversionFactor))), job(jobId), jobOperation(order, processId, workCenterId, process:process(name), workCenter:workCenter(name)), storageUnit:storageUnit!pickingListLine_storageUnitId_fkey(name, locationId), toStorageUnit:storageUnit!pickingListLine_toStorageUnitId_fkey(name, locationId), trackedEntities:pickingListLineTrackedEntity(trackedEntityId, quantity, quantityPicked, trackedEntity(readableId))").eq("pickingListId", pickingListId).order("jobOperationId")@@ -3032,7 +3032,13 @@ export async function setPickingListLineTrackedEntity(};if (!args.unpick) {body.fromStorageUnitId = args.fromStorageUnitId ?? null;- if (isBatch) body.quantity = Math.max(1, args.quantity ?? 1);+ // A batch pick may be fractional (0.5 kg): send the requested quantity as+ // is and fall back to 1 only when none was given. Flooring at 1 turned+ // every sub-1 remainder into an over-pick the edge function refused.+ if (isBatch) {+ body.quantity =+ args.quantity !== undefined && args.quantity > 0 ? args.quantity : 1;+ }}const result = await client.functions.invoke("post-picking", { body });diff --git a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsxindex 482c582e8d..6f588727cf 100644--- a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx+++ b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx@@ -12,7 +12,6 @@ import {CardDescription,CardHeader,CardTitle,- Count,cn,DropdownMenu,DropdownMenuContent,@@ -295,6 +294,10 @@ function PickingListLineItem({const item = items.find((i) => i.id === line.itemId);const itemName = item?.name ?? line.item?.name ?? "";+ // Pick quantities are in the picked item's own stock unit (a substituted+ // line is already converted into the successor's units at generation).+ const unitOfMeasureCode = line.item?.unitOfMeasureCode ?? null;+ const unitSuffix = unitOfMeasureCode ? ` ${unitOfMeasureCode}` : "";// A pick is substituted when its item differs from the source job material's// item (an item-supersession redirect at generation time). Show the original.const sourceMaterial = (@@ -437,7 +440,8 @@ function PickingListLineItem({className="font-mono tabular-nums normal-case">{lot.trackedEntity?.readableId ?? lot.trackedEntityId}- {isBatch && ` × ${Number(lot.quantityPicked ?? 0)}`}+ {isBatch &&+ ` × ${Number(lot.quantityPicked ?? 0)}${unitSuffix}`}</Badge>))}</HStack>@@ -467,13 +471,16 @@ function PickingListLineItem({className="text-base tabular-nums">{quantityPicked}/{quantityToPick}+ {unitSuffix}</Badge>) : (- <Count- count={isShort ? quantityPicked : quantityToPick}+ <Badgevariant={isPicked ? "green" : isShort ? "orange" : "red"}className="text-base tabular-nums"- />+ >+ {isShort ? quantityPicked : quantityToPick}+ {unitSuffix}+ </Badge>)}{isLocked ? null : isTracked ? (<HStack spacing={1}>@@ -564,6 +571,7 @@ function PickingListLineItem({itemName={itemName}quantityToPick={quantityToPick}quantityPicked={quantityPicked}+ unitOfMeasureCode={unitOfMeasureCode}onClose={() => setShortOpen(false)}/>)}diff --git a/apps/erp/app/modules/inventory/ui/PickingLists/ShortPickModal.tsx b/apps/erp/app/modules/inventory/ui/PickingLists/ShortPickModal.tsxindex 852b6216b6..892fa5cb33 100644--- a/apps/erp/app/modules/inventory/ui/PickingLists/ShortPickModal.tsx+++ b/apps/erp/app/modules/inventory/ui/PickingLists/ShortPickModal.tsx@@ -21,6 +21,7 @@ export function ShortPickModal({itemName,quantityToPick,quantityPicked,+ unitOfMeasureCode,onClose}: {pickingListId: string;@@ -28,6 +29,7 @@ export function ShortPickModal({itemName: string;quantityToPick: number;quantityPicked: number;+ unitOfMeasureCode?: string | null;onClose: () => void;}) {const { t } = useLingui();@@ -72,7 +74,11 @@ export function ShortPickModal({<Hidden name="markShort" value="true" /><NumberControlledname="quantity"- label={t`Picked quantity`}+ label={+ unitOfMeasureCode+ ? `${t`Picked quantity`} (${unitOfMeasureCode})`+ : t`Picked quantity`+ }value={quantity}onChange={setQuantity}minValue={0}diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.jsonindex 99b17c0c81..38ded418d5 100644--- a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json@@ -211,7 +211,7 @@{"name":"inventory_getPickingList","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"227255936b96","injectAuth":"companyId","permission":"inventory:view","paginates":false},{"name":"inventory_getPickingListAvailability","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"none","injectAuth":"companyId","permission":"inventory:view","paginates":false},{"name":"inventory_getPickingListLine","classification":"READ","paramCount":1,"schema":"063a6777d378","response":"b51ad23d436f","injectAuth":"companyId","permission":"inventory:view","paginates":false},- {"name":"inventory_getPickingListLines","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"07d244c0f017","injectAuth":"companyId","permission":"inventory:view","paginates":false},+ {"name":"inventory_getPickingListLines","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"b3ab0a2018d9","injectAuth":"companyId","permission":"inventory:view","paginates":false},{"name":"inventory_getPickingListLineTrackedEntities","classification":"READ","paramCount":1,"schema":"063a6777d378","response":"51dd622ce168","injectAuth":"companyId","permission":"inventory:view","paginates":false},{"name":"inventory_getPickingListRecommendations","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"24283057a15d","injectAuth":"companyId","permission":"inventory:view","paginates":false},{"name":"inventory_getPickingLists","classification":"READ","paramCount":6,"schema":"3599c50bdc36","response":"2112d9a1ea1d","injectAuth":"companyId","permission":"inventory:view","paginates":true},diff --git a/apps/mes/app/components/ShortPickModal.tsx b/apps/mes/app/components/ShortPickModal.tsxindex f03b4f06a1..8be8f77ad3 100644--- a/apps/mes/app/components/ShortPickModal.tsx+++ b/apps/mes/app/components/ShortPickModal.tsx@@ -21,6 +21,7 @@ export function ShortPickModal({itemName,quantityToPick,quantityPicked,+ unitOfMeasureCode,onClose}: {pickingListId: string;@@ -28,6 +29,7 @@ export function ShortPickModal({itemName: string;quantityToPick: number;quantityPicked: number;+ unitOfMeasureCode?: string | null;onClose: () => void;}) {const { t } = useLingui();@@ -72,7 +74,11 @@ export function ShortPickModal({<Hidden name="markShort" value="true" /><NumberControlledname="quantity"- label={t`Picked quantity`}+ label={+ unitOfMeasureCode+ ? `${t`Picked quantity`} (${unitOfMeasureCode})`+ : t`Picked quantity`+ }value={quantity}onChange={setQuantity}minValue={0}diff --git a/apps/mes/app/routes/x+/picking.$pickingListId.tsx b/apps/mes/app/routes/x+/picking.$pickingListId.tsxindex e72efc14d2..4f24fcf23c 100644--- a/apps/mes/app/routes/x+/picking.$pickingListId.tsx+++ b/apps/mes/app/routes/x+/picking.$pickingListId.tsx@@ -13,7 +13,6 @@ import {CardDescription,CardHeader,CardTitle,- Count,cn,DropdownMenu,DropdownMenuContent,@@ -441,9 +440,17 @@ function PickLineItem({}}, [fetcher.data]);- const lineItem = line.item as { name: string; readableId: string } | null;+ const lineItem = line.item as {+ name: string;+ readableId: string;+ unitOfMeasureCode: string | null;+ } | null;const item = items.find((i) => i.id === line.itemId);const itemName = item?.name ?? lineItem?.name ?? "";+ // Pick quantities are in the picked item's own stock unit (a substituted+ // line is already converted into the successor's units at generation).+ const unitOfMeasureCode = lineItem?.unitOfMeasureCode ?? null;+ const unitSuffix = unitOfMeasureCode ? ` ${unitOfMeasureCode}` : "";const sourceMaterial = (line as {jobMaterial?: {@@ -560,10 +567,10 @@ function PickLineItem({)}>{quantityPicked}/{quantityToPick}+ {unitSuffix}</Badge>) : (- <Count- count={isShort ? quantityPicked : quantityToPick}+ <BadgeclassName={cn("text-white text-base tabular-nums",isFullyPicked@@ -572,7 +579,10 @@ function PickLineItem({? "bg-orange-500": "bg-red-600")}- />+ >+ {isShort ? quantityPicked : quantityToPick}+ {unitSuffix}+ </Badge>);return (@@ -655,7 +665,8 @@ function PickLineItem({className="font-mono tabular-nums normal-case">{lot.trackedEntity?.readableId ?? lot.trackedEntityId}- {isBatch && ` × ${Number(lot.quantityPicked ?? 0)}`}+ {isBatch &&+ ` × ${Number(lot.quantityPicked ?? 0)}${unitSuffix}`}</Badge>))}</HStack>@@ -772,6 +783,7 @@ function PickLineItem({itemName={itemName}quantityToPick={quantityToPick}quantityPicked={quantityPicked}+ unitOfMeasureCode={unitOfMeasureCode}onClose={() => setShortOpen(false)}/>)}diff --git a/apps/mes/app/services/picking.service.ts b/apps/mes/app/services/picking.service.tsindex 432e389ed1..68e31341b9 100644--- a/apps/mes/app/services/picking.service.ts+++ b/apps/mes/app/services/picking.service.ts@@ -29,7 +29,7 @@ export async function getPickingListForExecution(const { data: lines, error: lineError } = await client.from("pickingListLine").select(- "*, item:item(name, readableId), jobMaterial:jobMaterial(itemId, quantity, substitutionFactor, item(readableId, itemSupersession!itemSupersession_itemId_fkey(conversionFactor))), job:job(jobId), jobOperation:jobOperation(order, processId, workCenterId, process:process(name), workCenter:workCenter(name)), storageUnit:storageUnit!pickingListLine_storageUnitId_fkey(name), toStorageUnit:storageUnit!pickingListLine_toStorageUnitId_fkey(name)"+ "*, item:item(name, readableId, unitOfMeasureCode), jobMaterial:jobMaterial(itemId, quantity, substitutionFactor, item(readableId, itemSupersession!itemSupersession_itemId_fkey(conversionFactor))), job:job(jobId), jobOperation:jobOperation(order, processId, workCenterId, process:process(name), workCenter:workCenter(name)), storageUnit:storageUnit!pickingListLine_storageUnitId_fkey(name), toStorageUnit:storageUnit!pickingListLine_toStorageUnitId_fkey(name)").eq("pickingListId", pickingListId).order("jobOperationId")@@ -387,7 +387,13 @@ export async function setPickingListLineTrackedEntity(};if (!args.unpick) {body.fromStorageUnitId = args.fromStorageUnitId ?? null;- if (isBatch) body.quantity = Math.max(1, args.quantity ?? 1);+ // A batch pick may be fractional (0.5 kg): send the requested quantity as+ // is and fall back to 1 only when none was given. Flooring at 1 turned+ // every sub-1 remainder into an over-pick the edge function refused.+ if (isBatch) {+ body.quantity =+ args.quantity !== undefined && args.quantity > 0 ? args.quantity : 1;+ }}const result = await client.functions.invoke("post-picking", { body });