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: add equipment id to equipment

Brad Barbinf785971fab9d
diff --git a/apps/carbon/app/modules/resources/resources.models.ts b/apps/carbon/app/modules/resources/resources.models.ts
index 6f45767327..b2a40425af 100644
--- a/apps/carbon/app/modules/resources/resources.models.ts
+++ b/apps/carbon/app/modules/resources/resources.models.ts
@@ -113,7 +113,8 @@ export const employeeJobValidator = z.object({
export const equipmentValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }),
- description: z.string(),
+ equipmentId: zfd.text(z.string().optional()),
+ description: zfd.text(z.string().optional()),
equipmentTypeId: z.string().min(1, { message: "Type is required" }),
operatorsRequired: zfd.numeric(z.number().optional()),
locationId: z.string().min(1, { message: "Location is required" }),
diff --git a/apps/carbon/app/modules/resources/resources.service.ts b/apps/carbon/app/modules/resources/resources.service.ts
index c52c10431a..7762e0299e 100644
--- a/apps/carbon/app/modules/resources/resources.service.ts
+++ b/apps/carbon/app/modules/resources/resources.service.ts
@@ -433,7 +433,9 @@ export async function getEquipmentType(
) {
return client
.from("equipmentType")
- .select("*, equipment(id, name, location(id, name))")
+ .select(
+ "*, equipment(id, name, equipmentId, description, location(id, name))"
+ )
.eq("active", true)
.eq("id", equipmentTypeId)
.single();
@@ -446,7 +448,7 @@ export async function getEquipmentTypes(
) {
let query = client
.from("equipmentType")
- .select("*, equipment(id, name)", {
+ .select("*, equipment(id, name, equipmentId, description)", {
count: "exact",
})
.eq("companyId", companyId)
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx
index e73bd6b4d8..c21d3a0c65 100644
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx
@@ -114,6 +114,7 @@ const EquipmentForm = ({
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
+ <Input name="equipmentId" label="Equipment ID" />
<TextArea name="description" label="Description" />
<Select
name="equipmentTypeId"
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail.tsx
index 7f15144ae9..cda943358c 100644
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail.tsx
+++ b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail.tsx
@@ -9,6 +9,7 @@ import {
DrawerTitle,
DropdownMenuIcon,
DropdownMenuItem,
+ Enumerable,
HStack,
VStack,
useDisclosure,
@@ -70,12 +71,14 @@ const EquipmentTypeDetail = ({
{equipmentType.equipment.map((equipment) => {
return (
<HStack key={equipment.id} className="w-full">
- <VStack spacing={0} className="flex-grow">
- <span className="font-bold">{equipment.name}</span>
- <span className="text-sm text-muted-foreground">
- {/* @ts-ignore */}
- {equipment.location?.name}
- </span>
+ <VStack spacing={1} className="flex-grow">
+ <HStack>
+ <span className="font-bold">{equipment.name}</span>
+ <span className="text-sm text-muted-foreground">
+ {equipment.equipmentId ?? null}
+ </span>
+ </HStack>
+ <Enumerable value={equipment?.location?.name ?? null} />
</VStack>
<ActionMenu>
<DropdownMenuItem asChild>
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index ab08a23498..eacd57ece1 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -5143,6 +5143,7 @@ export type Database = {
createdBy: string
customFields: Json | null
description: string | null
+ equipmentId: string | null
equipmentTypeId: string
id: string
locationId: string
@@ -5161,6 +5162,7 @@ export type Database = {
createdBy: string
customFields?: Json | null
description?: string | null
+ equipmentId?: string | null
equipmentTypeId: string
id?: string
locationId: string
@@ -5179,6 +5181,7 @@ export type Database = {
createdBy?: string
customFields?: Json | null
description?: string | null
+ equipmentId?: string | null
equipmentTypeId?: string
id?: string
locationId?: string
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index ab08a23498..eacd57ece1 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -5143,6 +5143,7 @@ export type Database = {
createdBy: string
customFields: Json | null
description: string | null
+ equipmentId: string | null
equipmentTypeId: string
id: string
locationId: string
@@ -5161,6 +5162,7 @@ export type Database = {
createdBy: string
customFields?: Json | null
description?: string | null
+ equipmentId?: string | null
equipmentTypeId: string
id?: string
locationId: string
@@ -5179,6 +5181,7 @@ export type Database = {
createdBy?: string
customFields?: Json | null
description?: string | null
+ equipmentId?: string | null
equipmentTypeId?: string
id?: string
locationId?: string
diff --git a/packages/database/supabase/migrations/20240713151328_equipment-id.sql b/packages/database/supabase/migrations/20240713151328_equipment-id.sql
new file mode 100644
index 0000000000..be683e4f4d
--- /dev/null
+++ b/packages/database/supabase/migrations/20240713151328_equipment-id.sql
@@ -0,0 +1 @@
+ALTER TABLE "equipment" ADD COLUMN "equipmentId" TEXT;
\ No newline at end of file