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 case where multiple RFQ lines have same customer part number and rev

Rob Carrington062b49501e1b
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index f64d42f383..cbfb599b9a 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -296,13 +296,18 @@ serve(async (req: Request) => {
.eq("companyId", companyId)
.single();
- if (error || !data) {
+ if (
+ // If multiple line items in the RFQ have the same customer part number and revision,
+ // make sure they get assiged different readableIds
+ !readableIdToLineIdMapping.has(readableId) &&
+ (error || !data)
+ ) {
// readableId is unique, we can use it
break;
}
// If not unique, append or increment suffix
- readableId = `${baseReadableId}-${suffix}`;
+ readableId = `${baseReadableId} (${suffix})`;
suffix++;
}