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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: job operation id for notification in assignment
Brad Barbin39251506228b
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsxindex fa3f0fcc13..4fb47c870c 100644--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx@@ -36,6 +36,7 @@ import {LuGripVertical,LuHardHat,LuPencil,+ LuPlay,LuSquareUser,LuTimer,LuTrash,@@ -213,6 +214,14 @@ export function ItemCard({ item, isOverlay, progressByItemId }: ItemCardProps) {/></DropdownMenuTrigger><DropdownMenuContent>+ {item.link && (+ <DropdownMenuItem asChild>+ <Link to={`${item.link}?selectedOperation=${item.id}`}>+ <DropdownMenuIcon icon={<LuPencil />} />+ Edit Operation+ </Link>+ </DropdownMenuItem>+ )}<DropdownMenuItemonClick={() =>setSelectedGroup?.(@@ -228,14 +237,12 @@ export function ItemCard({ item, isOverlay, progressByItemId }: ItemCardProps) {/>{isHighlighted ? "Remove Highlight" : "Highlight Job"}</DropdownMenuItem>- {item.link && (- <DropdownMenuItem asChild>- <Link to={`${item.link}?selectedOperation=${item.id}`}>- <DropdownMenuIcon icon={<LuPencil />} />- Edit Operation- </Link>- </DropdownMenuItem>- )}+ <DropdownMenuItem asChild>+ <a href={path.to.external.mesJobOperation(item.id)}>+ <DropdownMenuIcon icon={<LuPlay />} />+ Open in MES+ </a>+ </DropdownMenuItem></DropdownMenuContent></DropdownMenu></HStack>diff --git a/apps/erp/app/routes/api+/assign.ts b/apps/erp/app/routes/api+/assign.tsindex 93a9e7c11d..0ab45c8c49 100644--- a/apps/erp/app/routes/api+/assign.ts+++ b/apps/erp/app/routes/api+/assign.ts@@ -15,7 +15,7 @@ export async function action({ request }: ActionFunctionArgs) {const { client, companyId, userId } = await requirePermissions(request, {});const formData = await request.formData();- const id = formData.get("id") as string;+ let id = formData.get("id") as string;const assignee = formData.get("assignee") as string;const table = formData.get("table") as string;@@ -29,6 +29,20 @@ export async function action({ request }: ActionFunctionArgs) {);}+ if (table === "jobOperation") {+ const job = await client+ .from("jobOperation")+ .select("*, job(id, assignee), jobMakeMethod(id, parentMaterialId)")+ .eq("id", id)+ .single();++ const jobId = job.data?.job?.id;+ const makeMethodId = job.data?.jobMakeMethod?.id;+ const materialId = job.data?.jobMakeMethod?.parentMaterialId;++ id = `${jobId}:${id}:${makeMethodId}:${materialId ?? ""}`;+ }+if (assignee) {const notificationEvent = getNotificationEvent(table);if (notificationEvent) {diff --git a/apps/erp/app/trigger/notify.ts b/apps/erp/app/trigger/notify.tsindex affa4c01e0..f77b588e97 100644--- a/apps/erp/app/trigger/notify.ts+++ b/apps/erp/app/trigger/notify.ts@@ -48,6 +48,7 @@ export const notifyTask = task({function getWorkflow(type: NotificationEvent) {switch (type) {case NotificationEvent.JobAssignment:+ case NotificationEvent.JobOperationAssignment:case NotificationEvent.PurchaseInvoiceAssignment:case NotificationEvent.PurchaseOrderAssignment:case NotificationEvent.QuoteAssignment:diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.tsindex c8ea6bfbd4..a46c7045b1 100644--- a/apps/erp/app/utils/path.ts+++ b/apps/erp/app/utils/path.ts@@ -79,6 +79,10 @@ export const path = {paymentTerms: `${api}/accounting/payment-terms`,shippingMethods: `${api}/inventory/shipping-methods`,},+ external: {+ mesJobOperation: (id: string) =>+ generatePath(`https://mes.carbonos.dev/x/operation//${id}`),+ },file: {cadModel: (id: string) => generatePath(`${file}/model/${id}`),previewImage: (bucket: string, path: string) =>diff --git a/apps/mes/app/components/Kanban/components/ItemCard.tsx b/apps/mes/app/components/Kanban/components/ItemCard.tsxindex ef09fd85a9..3726b7de4e 100644--- a/apps/mes/app/components/Kanban/components/ItemCard.tsx+++ b/apps/mes/app/components/Kanban/components/ItemCard.tsx@@ -90,135 +90,136 @@ export function ItemCard({: false;return (- <Card- className={cn(- "max-w-[330px] shadow-sm dark:shadow-sm py-0",- cardVariants({- status: item.status,- })- )}- >- <CardHeader className="-mx-4 relative border-b py-3 px-4 rounded-t-lg">- <div className="flex w-full max-w-full justify-between items-start gap-0">- <div className="flex flex-col space-y-0 min-w-0">- {item.itemReadableId && (- <span className="text-xs text-muted-foreground line-clamp-1">- {item.itemReadableId}+ <Link to={path.to.operation(item.id)}>+ <Card+ className={cn(+ "max-w-[330px] shadow-sm dark:shadow-sm py-0",+ cardVariants({+ status: item.status,+ })+ )}+ >+ <CardHeader className="-mx-4 relative border-b py-3 px-4 rounded-t-lg">+ <div className="flex w-full max-w-full justify-between items-start gap-0">+ <div className="flex flex-col space-y-0 min-w-0">+ {item.itemReadableId && (+ <span className="text-xs text-muted-foreground line-clamp-1">+ {item.itemReadableId}+ </span>+ )}+ <span className="mr-auto font-semibold line-clamp-2 leading-tight">+ {item.itemDescription || item.itemReadableId}</span>- )}- <Link- to={path.to.operation(item.id)}- className="mr-auto font-semibold line-clamp-2 leading-tight"- >- {item.itemDescription || item.itemReadableId}- </Link>+ </div></div>- </div>- </CardHeader>-- <CardContent className="pt-3 px-1 gap-2 text-left whitespace-pre-wrap text-sm">- {showThumbnail && item.thumbnailPath && (- <div className="flex justify-center">- <img- src={getPrivateUrl(item.thumbnailPath)}- alt={item.title}- className="w-full h-auto rounded-lg"- />- </div>- )}- <HStack className="justify-start space-x-2">- <LuHardHat className="text-muted-foreground" />- <span className="text-sm line-clamp-1">{item.title}</span>- </HStack>+ </CardHeader>- {showDescription && item.description && (- <HStack className="justify-start space-x-2">- <LuClipboardCheck className="text-muted-foreground" />- <span className="text-sm line-clamp-1">{item.description}</span>- </HStack>- )}- {showStatus && item.status && (- <HStack className="justify-start space-x-2">- {getStatusIcon(item.status)}- <span className="text-sm">{item.status}</span>- </HStack>- )}- {showDuration && typeof item.duration === "number" && (- <HStack className="justify-start space-x-2">- <LuTimer className="text-muted-foreground" />- <span className="text-sm">- {formatDurationMilliseconds(item.duration)}- </span>- </HStack>- )}- {showDueDate && item.deadlineType && (- <HStack className="justify-start space-x-2">- <DeadlineIcon- deadlineType={item.deadlineType}- overdue={isOverdue}- />- <Tooltip>- <TooltipTrigger>- <span- className={cn("text-sm", isOverdue ? "text-red-500" : "")}- >- {["ASAP", "No Deadline"].includes(item.deadlineType)- ? item.deadlineType- : item.dueDate- ? `Due ${formatRelativeTime(- convertDateStringToIsoString(item.dueDate)- )}`- : "–"}- </span>- </TooltipTrigger>- <TooltipContent side="right">{item.deadlineType}</TooltipContent>- </Tooltip>- </HStack>- )}- {showDueDate && item.dueDate && (+ <CardContent className="pt-3 px-1 gap-2 text-left whitespace-pre-wrap text-sm">+ {showThumbnail && item.thumbnailPath && (+ <div className="flex justify-center">+ <img+ src={getPrivateUrl(item.thumbnailPath)}+ alt={item.title}+ className="w-full h-auto rounded-lg"+ />+ </div>+ )}<HStack className="justify-start space-x-2">- <LuCalendarDays />- <span className="text-sm">{formatDate(item.dueDate)}</span>+ <LuHardHat className="text-muted-foreground" />+ <span className="text-sm line-clamp-1">{item.title}</span></HStack>- )}- {showSalesOrder &&- item.salesOrderReadableId &&- item.salesOrderId &&- item.salesOrderLineId && (+ {showDescription && item.description && (<HStack className="justify-start space-x-2">- <RiProgress8Line className="text-muted-foreground" />- <span className="text-sm">{item.salesOrderReadableId}</span>+ <LuClipboardCheck className="text-muted-foreground" />+ <span className="text-sm line-clamp-1">{item.description}</span>+ </HStack>+ )}+ {showStatus && item.status && (+ <HStack className="justify-start space-x-2">+ {getStatusIcon(item.status)}+ <span className="text-sm">{item.status}</span>+ </HStack>+ )}+ {showDuration && typeof item.duration === "number" && (+ <HStack className="justify-start space-x-2">+ <LuTimer className="text-muted-foreground" />+ <span className="text-sm">+ {formatDurationMilliseconds(item.duration)}+ </span>+ </HStack>+ )}+ {showDueDate && item.deadlineType && (+ <HStack className="justify-start space-x-2">+ <DeadlineIcon+ deadlineType={item.deadlineType}+ overdue={isOverdue}+ />+ <Tooltip>+ <TooltipTrigger>+ <span+ className={cn("text-sm", isOverdue ? "text-red-500" : "")}+ >+ {["ASAP", "No Deadline"].includes(item.deadlineType)+ ? item.deadlineType+ : item.dueDate+ ? `Due ${formatRelativeTime(+ convertDateStringToIsoString(item.dueDate)+ )}`+ : "–"}+ </span>+ </TooltipTrigger>+ <TooltipContent side="right">+ {item.deadlineType}+ </TooltipContent>+ </Tooltip>+ </HStack>+ )}+ {showDueDate && item.dueDate && (+ <HStack className="justify-start space-x-2">+ <LuCalendarDays />+ <span className="text-sm">{formatDate(item.dueDate)}</span></HStack>)}- {showCustomer && item.customerId && (- <HStack className="justify-start space-x-2">- <LuSquareUser className="text-muted-foreground" />- <HStack className="truncate no-underline hover:no-underline">- <Avatar size="xs" name={customer?.name ?? ""} />- <span>{customer?.name}</span>+ {showSalesOrder &&+ item.salesOrderReadableId &&+ item.salesOrderId &&+ item.salesOrderLineId && (+ <HStack className="justify-start space-x-2">+ <RiProgress8Line className="text-muted-foreground" />+ <span className="text-sm">{item.salesOrderReadableId}</span>+ </HStack>+ )}++ {showCustomer && item.customerId && (+ <HStack className="justify-start space-x-2">+ <LuSquareUser className="text-muted-foreground" />+ <HStack className="truncate no-underline hover:no-underline">+ <Avatar size="xs" name={customer?.name ?? ""} />+ <span>{customer?.name}</span>+ </HStack></HStack>- </HStack>- )}- </CardContent>- {(item.assignee || (item.tags && item.tags.length > 0)) && (- <CardFooter className="bg-accent/50 -mx-4 border-t px-4 py-2 items-center justify-start space-2 rounded-b-lg text-xs flex-wrap">- {item.assignee && (- <EmployeeAvatar size="xs" employeeId={item.assignee} />)}- {item.tags?.map((tag) => (- <Badge- key={tag}- variant="secondary"- className="border dark:border-none dark:shadow-button-base"- >- {tag}- </Badge>- ))}- </CardFooter>- )}- </Card>+ </CardContent>+ {(item.assignee || (item.tags && item.tags.length > 0)) && (+ <CardFooter className="bg-accent/50 -mx-4 border-t px-4 py-2 items-center justify-start space-2 rounded-b-lg text-xs flex-wrap">+ {item.assignee && (+ <EmployeeAvatar size="xs" employeeId={item.assignee} />+ )}+ {item.tags?.map((tag) => (+ <Badge+ key={tag}+ variant="secondary"+ className="border dark:border-none dark:shadow-button-base"+ >+ {tag}+ </Badge>+ ))}+ </CardFooter>+ )}+ </Card>+ </Link>);}