Skip to content

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.

fix: handle part that already exists in carbon from paperless integration

Brad Barbin0523ede9a03e
diff --git a/packages/ee/src/paperless-parts/lib/utils.ts b/packages/ee/src/paperless-parts/lib/utils.ts
index 1a42b86f28..38cbaa4666 100644
--- a/packages/ee/src/paperless-parts/lib/utils.ts
+++ b/packages/ee/src/paperless-parts/lib/utils.ts
@@ -1865,6 +1865,22 @@ export async function createPartFromComponent(
const name =
component.part_name || component.part_number || `Part ${component.id}`;
+ // Check if part already exists by partId (readableId)
+ const existingItem = await carbon
+ .from("item")
+ .select("id")
+ .eq("companyId", companyId)
+ .eq("readableId", partId)
+ .eq("revision", revision)
+ .maybeSingle();
+
+ if (existingItem.data) {
+ return {
+ itemId: existingItem.data.id,
+ partId: partId,
+ };
+ }
+
// Create the item first
const itemInsert = await carbon
.from("item")