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(mes): log return-sweep errors, tighten pick-method type, autosuggest on add
sidgaikwade66101c49743
diff --git a/apps/mes/app/components/JobOperation/components/IssueMaterialModal.tsx b/apps/mes/app/components/JobOperation/components/IssueMaterialModal.tsxindex c392ce7e92..421829f791 100644--- a/apps/mes/app/components/JobOperation/components/IssueMaterialModal.tsx+++ b/apps/mes/app/components/JobOperation/components/IssueMaterialModal.tsx@@ -501,10 +501,15 @@ export function IssueMaterialModal({const addSerialNumber = useCallback(() => {setSelectedSerialNumbers((prev) => {- const newIndex = prev.length;- return [...prev, { index: newIndex, id: "" }];+ // Pre-fill the new row with the next available serial (in picker order)+ // not already chosen, skipping expired — a starting point, still editable.+ const used = new Set(prev.map((s) => s.id).filter(Boolean));+ const next = serialOptions.find(+ (o) => !used.has(o.value) && !o.isExpired+ );+ return [...prev, { index: prev.length, id: next?.value ?? "" }];});- }, []);+ }, [serialOptions]);const removeSerialNumber = useCallback((indexToRemove: number) => {setSelectedSerialNumbers((prev) => {@@ -541,10 +546,18 @@ export function IssueMaterialModal({const addBatchNumber = useCallback(() => {setSelectedBatchNumbers((prev) => {- const newIndex = prev.length;- return [...prev, { index: newIndex, id: "", quantity: 1 }];+ // Pre-fill the new row with the next available batch (in picker order)+ // not already chosen, skipping expired — a starting point, still editable.+ const used = new Set(prev.map((b) => b.id).filter(Boolean));+ const next = batchOptions.find(+ (o) => !used.has(o.value) && !o.isExpired+ );+ return [+ ...prev,+ { index: prev.length, id: next?.value ?? "", quantity: 1 }+ ];});- }, []);+ }, [batchOptions]);const removeBatchNumber = useCallback((indexToRemove: number) => {setSelectedBatchNumbers((prev) => {diff --git a/apps/mes/app/services/allocation.ts b/apps/mes/app/services/allocation.tsindex e320993183..b851462592 100644--- a/apps/mes/app/services/allocation.ts+++ b/apps/mes/app/services/allocation.ts@@ -45,7 +45,7 @@ function cmpNullable(*/export function sortLotsByPickMethod<T extends SortableLot>(lots: T[],- sortMethod: PickMethodSortMethod | string+ sortMethod: PickMethodSortMethod): T[] {const sorted = [...lots];if (sortMethod === "FIFO") {diff --git a/apps/mes/app/services/operations.service.ts b/apps/mes/app/services/operations.service.tsindex 81765ae5b6..015c4f7b64 100644--- a/apps/mes/app/services/operations.service.ts+++ b/apps/mes/app/services/operations.service.ts@@ -261,7 +261,19 @@ async function returnAllocatedRemaindersAtJobComplete();});- await Promise.all(returns);+ // `functions.invoke` resolves to `{ data, error }` rather than rejecting, so a+ // failed return never surfaces through Promise.all — inspect each result and log+ // it, otherwise a stranded lineside remainder is lost silently.+ const results = await Promise.all(returns);+ for (const { error } of results) {+ if (error) {+ log.error("returnPickedRemainder failed at job complete", {+ error,+ jobId,+ companyId: args.companyId+ });+ }+ }}export async function getActiveJobOperationsByEmployee(