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.

refactor(import): use "Material ID" for BOM component field

sidgaikwad5a9ba894ac36
diff --git a/apps/erp/app/modules/shared/imports.models.ts b/apps/erp/app/modules/shared/imports.models.ts
index 4ce2f1afac..ff77c75a4e 100644
--- a/apps/erp/app/modules/shared/imports.models.ts
+++ b/apps/erp/app/modules/shared/imports.models.ts
@@ -197,12 +197,12 @@ const methodOpNoField = {
// from the component item, never read from the import (PRD / commit #903).
const methodBomFields = {
componentId: {
- label: "Component ID",
+ label: "Material ID",
required: false,
type: "string"
},
componentRevision: {
- label: "Component Revision",
+ label: "Material Revision",
required: false,
type: "string",
default: "0"
@@ -1335,7 +1335,8 @@ export const fieldMappings = {
quantity: { ...methodBomFields.quantity, required: true }
},
// Focused Operations file — operations plus their steps/tools/parameters against
- // parts that already exist. Carries every method row type except BOM and PART.
+ // parts that already exist. Carries every method row type except BOM and PART,
+ // so Row Type is required to discriminate BOP / STEP / TOOL / PARAM rows.
operations: {
...methodParentKeyFields,
rowType: { ...methodParentKeyFields.rowType, required: true },
@@ -2048,7 +2049,7 @@ export const importSchemas: Record<
...methodBomSchema,
componentId: z
.string()
- .min(1, { message: "Component ID is required" })
+ .min(1, { message: "Material ID is required" })
.describe("The readable id of the component consumed by this BOM line"),
quantity: z
.string()
diff --git a/packages/database/supabase/functions/import-csv/method-import.ts b/packages/database/supabase/functions/import-csv/method-import.ts
index 0b96e95afa..cfb824d56c 100644
--- a/packages/database/supabase/functions/import-csv/method-import.ts
+++ b/packages/database/supabase/functions/import-csv/method-import.ts
@@ -92,6 +92,9 @@ function normalizeRowType(
table: string
): RowType | null {
const v = (raw ?? "").trim().toUpperCase();
+ // The BOM file is homogeneous — every row is a BOM line — so a blank Row Type
+ // defaults to BOM. The operations and combined files are multi-type (BOP/STEP/
+ // TOOL/PARAM, +PART), so Row Type is a required discriminator there.
if (!v) return table === "bom" ? "BOM" : null;
return (ROW_TYPES as readonly string[]).includes(v) ? (v as RowType) : null;
}
@@ -438,14 +441,14 @@ function validateGroup(
for (const e of bucket.bom) {
const componentId = text(e.record.componentId);
if (!componentId) {
- errors.push({ row: lineNo(e.index), reason: "BOM row is missing Component ID" });
+ errors.push({ row: lineNo(e.index), reason: "BOM row is missing Material ID" });
continue;
}
const compKey = key(componentId, text(e.record.componentRevision));
if (!lk.itemMap.has(compKey) && !lk.fileCreatedParts.has(compKey)) {
errors.push({
row: lineNo(e.index),
- reason: `Component ${componentId} rev ${text(e.record.componentRevision) || "0"} not found`,
+ reason: `Material ${componentId} rev ${text(e.record.componentRevision) || "0"} not found`,
});
}
if (num(e.record.quantity) === undefined) {