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: document print source id fallback
Sidwebworks66ca9cb1ec94
diff --git a/apps/erp/app/routes/file+/entity+/labels.server.ts b/apps/erp/app/routes/file+/entity+/labels.server.tsindex f897111bf8..d861ce9a29 100644--- a/apps/erp/app/routes/file+/entity+/labels.server.ts+++ b/apps/erp/app/routes/file+/entity+/labels.server.ts@@ -17,10 +17,23 @@ export async function getEntityLabelData(return { error: "Tracked entity not found" };}+ // sourceDocumentId is polymorphic (Receipt, Shipment, Job Material, etc.);+ // it only equals item.id when sourceDocument === "Item". Prefer the dedicated+ // itemId FK and fall back to sourceDocumentId only for Item-sourced entities.+ const itemId =+ trackedEntity.data.itemId ??+ (trackedEntity.data.sourceDocument === "Item"+ ? trackedEntity.data.sourceDocumentId+ : null);++ if (!itemId) {+ return { error: "Item not found" };+ }+const item = await client.from("item").select("readableId, revision")- .eq("id", trackedEntity.data.sourceDocumentId ?? "")+ .eq("id", itemId).single();if (!item.data) {