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.

feat(import): clarify Tracking Type and add optional Unit Cost field

Gaurav Bhatt7ea6eb471fd1
diff --git a/apps/erp/app/modules/shared/imports.models.ts b/apps/erp/app/modules/shared/imports.models.ts
index 1804688fe2..43ee784b69 100644
--- a/apps/erp/app/modules/shared/imports.models.ts
+++ b/apps/erp/app/modules/shared/imports.models.ts
@@ -20,6 +20,10 @@ const itemTrackingTypes = [
"Serial",
"Batch"
] as const;
+// Shared so the four-value explanation stays in one place (it had drifted to a
+// stale two-value description duplicated across every item type).
+const itemTrackingTypeDescription =
+ "How the item's stock is tracked: Inventory (stocked and counted), Non-Inventory (not stocked, e.g. services), Batch (tracked by lot), or Serial (tracked per individual unit).";
const supplierStatusTypes = [
"Active",
"Inactive",
@@ -141,6 +145,17 @@ const itemPurchasingImportFields = {
}
} as const;
+// Item-level cost. Spread into every real item-type entry; written to the
+// item's "itemCost" row (auto-created by the create_item_related_records
+// trigger) in the edge function's post-pass.
+const itemCostImportFields = {
+ unitCost: {
+ label: "Unit Cost",
+ required: false,
+ type: "string"
+ }
+} as const;
+
// Method (BOM/BOP) import — one row-type-multiplexed format (ADR-0002). A single
// CSV may carry six row kinds discriminated by `Row Type`; each non-PART row names
// its parent part explicitly, so multi-level BOMs need no positional Level column.
@@ -492,7 +507,7 @@ const partImportFields = {
required: false,
type: "enum",
enumData: {
- description: "Whether a part is tracked as inventory or not",
+ description: itemTrackingTypeDescription,
options: itemTrackingTypes,
default: "Inventory"
}
@@ -925,7 +940,8 @@ export const fieldMappings = {
}
},
part: {
- ...partImportFields
+ ...partImportFields,
+ ...itemCostImportFields
},
tool: {
id: {
@@ -981,7 +997,7 @@ export const fieldMappings = {
required: false,
type: "enum",
enumData: {
- description: "Whether a part is tracked as inventory or not",
+ description: itemTrackingTypeDescription,
options: itemTrackingTypes,
default: "Inventory"
}
@@ -1016,7 +1032,8 @@ export const fieldMappings = {
}
},
...supplierPartImportFields,
- ...itemPurchasingImportFields
+ ...itemPurchasingImportFields,
+ ...itemCostImportFields
},
fixture: {
id: {
@@ -1072,7 +1089,7 @@ export const fieldMappings = {
required: false,
type: "enum",
enumData: {
- description: "Whether a part is tracked as inventory or not",
+ description: itemTrackingTypeDescription,
options: itemTrackingTypes,
default: "Inventory"
}
@@ -1107,7 +1124,8 @@ export const fieldMappings = {
}
},
...supplierPartImportFields,
- ...itemPurchasingImportFields
+ ...itemPurchasingImportFields,
+ ...itemCostImportFields
},
consumable: {
id: {
@@ -1163,7 +1181,7 @@ export const fieldMappings = {
required: false,
type: "enum",
enumData: {
- description: "Whether a part is tracked as inventory or not",
+ description: itemTrackingTypeDescription,
options: itemTrackingTypes,
default: "Inventory"
}
@@ -1198,7 +1216,8 @@ export const fieldMappings = {
}
},
...supplierPartImportFields,
- ...itemPurchasingImportFields
+ ...itemPurchasingImportFields,
+ ...itemCostImportFields
},
material: {
id: {
@@ -1281,7 +1300,7 @@ export const fieldMappings = {
required: false,
type: "enum",
enumData: {
- description: "Whether a part is tracked as inventory or not",
+ description: itemTrackingTypeDescription,
options: itemTrackingTypes,
default: "Inventory"
}
@@ -1331,7 +1350,8 @@ export const fieldMappings = {
}
},
...supplierPartImportFields,
- ...itemPurchasingImportFields
+ ...itemPurchasingImportFields,
+ ...itemCostImportFields
},
// Focused BOM file — BOM lines against parts that already exist. Every row is a
// BOM line (rowType defaults to BOM), keyed to its parent part.
@@ -1867,7 +1887,8 @@ export const importSchemas: Record<
orderMultiple: z.string().optional(),
conversionFactor: z.string().optional(),
unitPrice: z.string().optional(),
- leadTime: z.string().optional()
+ leadTime: z.string().optional(),
+ unitCost: z.string().optional()
}),
tool: z.object({
id: z
@@ -1910,7 +1931,8 @@ export const importSchemas: Record<
orderMultiple: z.string().optional(),
conversionFactor: z.string().optional(),
unitPrice: z.string().optional(),
- leadTime: z.string().optional()
+ leadTime: z.string().optional(),
+ unitCost: z.string().optional()
}),
fixture: z.object({
id: z
@@ -1953,7 +1975,8 @@ export const importSchemas: Record<
orderMultiple: z.string().optional(),
conversionFactor: z.string().optional(),
unitPrice: z.string().optional(),
- leadTime: z.string().optional()
+ leadTime: z.string().optional(),
+ unitCost: z.string().optional()
}),
consumable: z.object({
id: z
@@ -1996,7 +2019,8 @@ export const importSchemas: Record<
orderMultiple: z.string().optional(),
conversionFactor: z.string().optional(),
unitPrice: z.string().optional(),
- leadTime: z.string().optional()
+ leadTime: z.string().optional(),
+ unitCost: z.string().optional()
}),
material: z.object({
id: z
@@ -2046,7 +2070,8 @@ export const importSchemas: Record<
orderMultiple: z.string().optional(),
conversionFactor: z.string().optional(),
unitPrice: z.string().optional(),
- leadTime: z.string().optional()
+ leadTime: z.string().optional(),
+ unitCost: z.string().optional()
}),
bom: z.object({
...methodParentKeySchema,