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
feat: sales order job summary and mes fixes
Brad Barbin7097e0e0759c
diff --git a/apps/erp/app/components/Form/SequenceOrCustomId.tsx b/apps/erp/app/components/Form/SequenceOrCustomId.tsxindex 95a2a14a4f..cd89450c89 100644--- a/apps/erp/app/components/Form/SequenceOrCustomId.tsx+++ b/apps/erp/app/components/Form/SequenceOrCustomId.tsx@@ -58,8 +58,8 @@ const SequenceOrCustomId = forwardRef<<IconButtonaria-label="Toggle"className={cn(- "absolute right-0 top-0",- "bg-card flex-shrink-0 h-10 w-10 px-3 rounded-l-none before:rounded-l-none border -ml-px shadow-none hover:shadow-button-base"+ "bg-card absolute right-0 top-0",+ "flex-shrink-0 h-10 w-10 px-3 rounded-l-none before:rounded-l-none border-none -ml-px shadow-button-base")}icon={isCustom ? <LuToggleLeft /> : <LuToggleRight />}variant="secondary"diff --git a/apps/erp/app/components/ItemThumbnail.tsx b/apps/erp/app/components/ItemThumbnail.tsxindex c48fb60e08..0b7b934394 100644--- a/apps/erp/app/components/ItemThumbnail.tsx+++ b/apps/erp/app/components/ItemThumbnail.tsx@@ -16,8 +16,8 @@ const itemVariants = cva({variants: {size: {- sm: "w-7 h-7",- md: "w-9 h-9",+ sm: "w-8 h-8",+ md: "w-10 h-10",lg: "w-11 h-11 bg-gradient-to-bl from-muted to-muted/40",},withPadding: {@@ -49,7 +49,7 @@ const itemVariants = cva(});-const iconVariants = cva("text-muted-foreground", {+const iconVariants = cva("text-[#AAAAAA] dark:text-[#444]", {variants: {size: {sm: "w-4 h-4",diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSummary.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSummary.tsxindex 80ffa0453d..744ec4794b 100644--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSummary.tsx+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSummary.tsx@@ -18,7 +18,7 @@ import { useLocale } from "@react-aria/i18n";import { Link, useParams } from "@remix-run/react";import { motion } from "framer-motion";import { useState } from "react";-import { LuChevronDown, LuImage } from "react-icons/lu";+import { LuChevronRight, LuImage } from "react-icons/lu";import { SupplierAvatar } from "~/components";import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";import {@@ -93,7 +93,7 @@ const LineItems = ({src={getPrivateUrl(line.thumbnailPath)}/>) : (- <div className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-2">+ <div className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-4"><LuImage className="w-16 h-16 text-muted-foreground" /></div>)}@@ -137,11 +137,11 @@ const LineItems = ({</VStack><motion.divanimate={{- rotate: openItems.includes(line.id) ? 180 : 0,+ rotate: openItems.includes(line.id) ? 90 : 0,}}transition={{ duration: 0.3 }}>- <LuChevronDown size={24} />+ <LuChevronRight size={24} /></motion.div></HStack></div>diff --git a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsxindex 000b058b04..f76c91d019 100644--- a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx+++ b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx@@ -18,14 +18,20 @@ import {toast,useDisclosure,} from "@carbon/react";-import { useFetcher } from "@remix-run/react";+import { Link, useFetcher } from "@remix-run/react";import { useEffect, useState } from "react";-import { LuGitBranch, LuGitMerge, LuTriangleAlert } from "react-icons/lu";+import {+ LuGitBranch,+ LuGitFork,+ LuGitMerge,+ LuTriangleAlert,+} from "react-icons/lu";import { Hidden, Item } from "~/components/Form";import { usePermissions } from "~/hooks";import type { MethodItemType } from "~/modules/shared";import { path } from "~/utils/path";import { getMethodValidator } from "../../items.models";+import { getLinkToItemManufacturing } from "./ItemForm";type MakeMethodToolsProps = {itemId: string;@@ -52,6 +58,9 @@ const MakeMethodTools = ({ itemId, type }: MakeMethodToolsProps) => {const getMethodModal = useDisclosure();const saveMethodModal = useDisclosure();+ const itemLink =+ type && itemId ? getLinkToItemManufacturing(type, itemId) : null;+return (<><Menubar>@@ -77,6 +86,13 @@ const MakeMethodTools = ({ itemId, type }: MakeMethodToolsProps) => {>Save Method</MenubarItem>+ {itemLink && (+ <MenubarItem leftIcon={<LuGitFork />} asChild>+ <Link prefetch="intent" to={itemLink}>+ Item Master+ </Link>+ </MenubarItem>+ )}</HStack></HStack></Menubar>diff --git a/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx b/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsxindex 99d6f618e3..8efd342947 100644--- a/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx+++ b/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx@@ -83,7 +83,7 @@ const MaterialsTable = memo(({ data, tags, count }: MaterialsTableProps) => {cell: ({ row }) => (<HStack className="py-1 min-w-[200px] truncate"><ItemThumbnail- size="sm"+ size="md"thumbnailPath={row.original.thumbnailPath}type="Material"/>diff --git a/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx b/apps/erp/app/modules/items/ui/Parts/PartsTable.tsxindex b4b13f5ac5..161a93b553 100644--- a/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx+++ b/apps/erp/app/modules/items/ui/Parts/PartsTable.tsx@@ -82,7 +82,7 @@ const PartsTable = memo(({ data, tags, count }: PartsTableProps) => {cell: ({ row }) => (<HStack className="py-1 min-w-[200px] truncate" spacing={2}><ItemThumbnail- size="sm"+ size="md"thumbnailPath={row.original.thumbnailPath}type="Part"/>diff --git a/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx b/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsxindex fa8b345777..6d057c8658 100644--- a/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx+++ b/apps/erp/app/modules/items/ui/Tools/ToolsTable.tsx@@ -82,7 +82,7 @@ const ToolsTable = memo(({ data, tags, count }: ToolsTableProps) => {cell: ({ row }) => (<HStack className="py-1 min-w-[200px] truncate"><ItemThumbnail- size="sm"+ size="md"thumbnailPath={row.original.thumbnailPath}type="Tool"/>diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsxindex df2b879c1d..9f2d4d25f1 100644--- a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx+++ b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx@@ -66,7 +66,7 @@ const JobMaterialsTable = memo(({ data, count }: JobMaterialsTableProps) => {cell: ({ row }) => (<HStack className="py-1"><ItemThumbnail- size="sm"+ size="md"// @ts-ignoretype={row.original.itemType}/>diff --git a/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsxindex 560cf3b6cd..edd2d37e5e 100644--- a/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx+++ b/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx@@ -95,7 +95,7 @@ const JobsTable = memo(({ data, count, tags }: JobsTableProps) => {cell: ({ row }) => (<HStack><ItemThumbnail- size="sm"+ size="md"thumbnailPath={row.original.thumbnailPath}// @ts-ignoretype={row.original.itemType}diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsxindex 0594537b0f..9739960763 100644--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx@@ -18,7 +18,7 @@ import { useLocale } from "@react-aria/i18n";import { Link, useParams } from "@remix-run/react";import { motion } from "framer-motion";import { useState } from "react";-import { LuChevronDown, LuImage } from "react-icons/lu";+import { LuChevronRight, LuImage } from "react-icons/lu";import { SupplierAvatar } from "~/components";import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";import {@@ -94,7 +94,7 @@ const LineItems = ({src={getPrivateUrl(line.thumbnailPath)}/>) : (- <div className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-2">+ <div className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-4"><LuImage className="w-16 h-16 text-muted-foreground" /></div>)}@@ -136,11 +136,11 @@ const LineItems = ({</VStack><motion.divanimate={{- rotate: openItems.includes(line.id) ? 180 : 0,+ rotate: openItems.includes(line.id) ? 90 : 0,}}transition={{ duration: 0.3 }}>- <LuChevronDown size={24} />+ <LuChevronRight size={24} /></motion.div></HStack></div>diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSummary.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSummary.tsxindex 9ad0202501..d51bf6410b 100644--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSummary.tsx+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSummary.tsx@@ -20,7 +20,7 @@ import { useLocale } from "@react-aria/i18n";import { Link, useParams } from "@remix-run/react";import { motion } from "framer-motion";import { useMemo, useState } from "react";-import { LuChevronDown, LuImage } from "react-icons/lu";+import { LuChevronRight, LuImage } from "react-icons/lu";import { SupplierAvatar } from "~/components";import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";import { useCurrencyFormatter, useRouteData, useUser } from "~/hooks";@@ -107,7 +107,7 @@ const LineItems = ({src={getPrivateUrl(line.thumbnailPath)}/>) : (- <div className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-2">+ <div className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-4"><LuImage className="w-16 h-16 text-muted-foreground" /></div>)}@@ -136,11 +136,11 @@ const LineItems = ({<HStack spacing={4}><motion.divanimate={{- rotate: openItems.includes(line.id) ? 180 : 0,+ rotate: openItems.includes(line.id) ? 90 : 0,}}transition={{ duration: 0.3 }}>- <LuChevronDown size={24} />+ <LuChevronRight size={24} /></motion.div></HStack></div>diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteToOrderDrawer.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteToOrderDrawer.tsxindex 4efc6c2b5f..5f3327880d 100644--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteToOrderDrawer.tsx+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteToOrderDrawer.tsx@@ -178,11 +178,11 @@ const LinePricingForm = ({{line.thumbnailPath ? (<imgalt={line.itemReadableId!}- className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg"+ className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg"src={getPrivateUrl(line.thumbnailPath)}/>) : (- <div className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-2">+ <div className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-4"><LuImage className="w-16 h-16 text-muted-foreground" /></div>)}diff --git a/apps/erp/app/modules/sales/types.ts b/apps/erp/app/modules/sales/types.tsindex 9c14b7375d..628ac4d673 100644--- a/apps/erp/app/modules/sales/types.ts+++ b/apps/erp/app/modules/sales/types.ts@@ -1,4 +1,5 @@import type { Database } from "@carbon/database";+import type { jobStatus } from "../production/production.models";import type { QuantityEffect } from "../shared";import type {getCustomer,@@ -128,6 +129,16 @@ export type SalesOrder = NonNullable<Awaited<ReturnType<typeof getSalesOrders>>["data"]>[number];+export type SalesOrderJob = {+ id: string;+ jobId: string;+ status: (typeof jobStatus)[number];+ salesOrderLineId: string;+ productionQuantity: number;+ quantityComplete: number;+ assignee: string;+};+export type SalesOrderLine = NonNullable<Awaited<ReturnType<typeof getSalesOrderLines>>["data"]>[number];diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsxindex 898a876b1d..45d512e881 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx@@ -24,7 +24,7 @@ import { motion } from "framer-motion";import MotionNumber from "motion-number";import type { Dispatch, SetStateAction } from "react";import { useEffect, useMemo, useState } from "react";-import { LuChevronDown, LuImage } from "react-icons/lu";+import { LuChevronRight, LuImage } from "react-icons/lu";import { CustomerAvatar } from "~/components";import { usePercentFormatter, useRouteData, useUser } from "~/hooks";import { getPrivateUrl, path } from "~/utils/path";@@ -143,7 +143,7 @@ const LineItems = ({src={getPrivateUrl(line.thumbnailPath)}/>) : (- <div className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-2">+ <div className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-4"><LuImage className="w-16 h-16 text-muted-foreground" /></div>)}@@ -196,11 +196,11 @@ const LineItems = ({/><motion.divanimate={{- rotate: openItems.includes(line.id) ? 180 : 0,+ rotate: openItems.includes(line.id) ? 90 : 0,}}transition={{ duration: 0.3 }}>- <LuChevronDown size={24} />+ <LuChevronRight size={24} /></motion.div></HStack></div>diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsxindex 5a14119378..e2b74ed7e2 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx@@ -374,11 +374,11 @@ const LinePricingForm = ({{line.thumbnailPath ? (<imgalt={line.itemReadableId!}- className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg"+ className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg"src={getPrivateUrl(line.thumbnailPath)}/>) : (- <div className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-2">+ <div className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-4"><LuImage className="w-16 h-16 text-muted-foreground" /></div>)}diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsxindex b5d9a2ccfd..1866deaaff 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx@@ -69,7 +69,7 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {cell: ({ row }) => (<HStack><ItemThumbnail- size="sm"+ size="md"thumbnailPath={row.original.thumbnailPath}// @ts-ignoretype={row.original.itemType}diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsxindex 37afc0847c..67f735ecea 100644--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx@@ -1,4 +1,5 @@import {+ Badge,Button,Card,CardContent,@@ -6,10 +7,15 @@ import {CardHeader,CardTitle,Heading,+ HoverCard,+ HoverCardContent,+ HoverCardTrigger,HStack,Table,Tbody,Td,+ Th,+ Thead,Tooltip,TooltipContent,TooltipTrigger,@@ -22,14 +28,21 @@ import { Link, useParams } from "@remix-run/react";import { motion } from "framer-motion";import MotionNumber from "motion-number";import { useMemo, useState } from "react";-import { LuChevronDown, LuImage, LuInfo } from "react-icons/lu";-import { CustomerAvatar } from "~/components";-import { usePercentFormatter, useRouteData } from "~/hooks";+import {+ LuChevronRight,+ LuEllipsisVertical,+ LuImage,+ LuInfo,+} from "react-icons/lu";+import { Assignee, CustomerAvatar, Empty, Hyperlink } from "~/components";+import { usePercentFormatter, usePermissions, useRouteData } from "~/hooks";+import JobStatus from "~/modules/production/ui/Jobs/JobStatus";import { getPrivateUrl, path } from "~/utils/path";import type {Customer,Quotation,SalesOrder,+ SalesOrderJob,SalesOrderLine,} from "../../types";@@ -126,6 +139,7 @@ const SalesOrderSummary = ({</CardHeader><CardContent><LineItems+ salesOrder={routeData?.salesOrder}currencyCode={routeData?.salesOrder?.currencyCode ?? "USD"}locale={locale}formatter={formatter}@@ -211,14 +225,17 @@ function LineItems({formatter,locale,lines,+ salesOrder,}: {currencyCode: string;formatter: Intl.NumberFormat;locale: string;lines: SalesOrderLine[];+ salesOrder?: SalesOrder;}) {const { orderId } = useParams();if (!orderId) throw new Error("Could not find orderId");+ const permissions = usePermissions();const percentFormatter = usePercentFormatter();const [openItems, setOpenItems] = useState<string[]>([]);@@ -233,6 +250,35 @@ function LineItems({<VStack spacing={8} className="w-full overflow-hidden">{lines.map((line) => {if (!line.id) return null;++ const jobs = (salesOrder?.jobs?.filter(+ (j) => (j as unknown as SalesOrderJob).salesOrderLineId === line.id+ ) ?? []) as SalesOrderJob[];++ const isMade = line.methodType === "Make";++ const hasEnoughJobsToCoverQuantity =+ jobs.reduce((acc, job) => acc + job.productionQuantity, 0) >=+ (line.saleQuantity ?? 0);++ const hasEnoughCompletedToCoverQuantity =+ jobs.reduce((acc, job) => acc + job.quantityComplete, 0) >=+ (line.saleQuantity ?? 0);++ const jobVariant: "red" | "orange" | "green" =+ hasEnoughJobsToCoverQuantity && hasEnoughCompletedToCoverQuantity+ ? "green"+ : hasEnoughJobsToCoverQuantity+ ? "orange"+ : "red";++ const jobLabel: "Requires Jobs" | "In Progress" | "Complete" =+ hasEnoughJobsToCoverQuantity && hasEnoughCompletedToCoverQuantity+ ? "Complete"+ : hasEnoughJobsToCoverQuantity+ ? "In Progress"+ : "Requires Jobs";+return (<motion.divkey={line.id}@@ -249,7 +295,7 @@ function LineItems({src={getPrivateUrl(line.thumbnailPath)}/>) : (- <div className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-2">+ <div className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-4"><LuImage className="w-16 h-16 text-muted-foreground" /></div>)}@@ -293,17 +339,52 @@ function LineItems({/><motion.divanimate={{- rotate: openItems.includes(line.id) ? 180 : 0,+ rotate: openItems.includes(line.id) ? 90 : 0,}}transition={{ duration: 0.3 }}>- <LuChevronDown size={24} />+ <LuChevronRight size={24} /></motion.div></HStack></div><span className="text-muted-foreground text-base truncate">{line.description}</span>+ {isMade && (+ <div className="mt-2 flex flex-row items-center gap-x-2">+ <Badge variant={jobVariant}>{jobLabel}</Badge>+ {jobs.length > 0 && (+ <HoverCard>+ <HoverCardTrigger>+ <Badge variant="secondary">+ {jobs.length} Jobs+ <LuEllipsisVertical className="w-3 h-3 ml-2" />+ </Badge>+ </HoverCardTrigger>+ <HoverCardContent>+ <div className="flex flex-col w-full gap-4 text-sm">+ {jobs.map((job) => (+ <div+ key={job.id}+ className="flex items-center justify-between gap-2"+ >+ <Hyperlink+ to={path.to.jobDetails(job.id)}+ className="flex items-center justify-start gap-1"+ >+ {job.jobId}+ </Hyperlink>+ <div className="flex items-center justify-end">+ <JobStatus status={job.status} />+ </div>+ </div>+ ))}+ </div>+ </HoverCardContent>+ </HoverCard>+ )}+ </div>+ )}</div></VStack></HStack>@@ -318,7 +399,7 @@ function LineItems({transition={{ duration: 0.3 }}className="w-full overflow-hidden">- <div className="w-full">+ <div className="flex flex-col gap-y-4 w-full"><Table><Tbody><Tr>@@ -427,6 +508,54 @@ function LineItems({</Tr></Tbody></Table>++ {isMade && (+ <Table>+ <Thead>+ <Tr>+ <Th>Job ID</Th>+ <Th>Status</Th>+ <Th>Quantity</Th>+ <Th>Assignee</Th>+ </Tr>+ </Thead>+ <Tbody>+ {jobs.length > 0 ? (+ jobs.map((job) => (+ <Tr key={job.id}>+ <Td>+ <Hyperlink to={path.to.job(job.id!)}>+ {job.jobId}+ </Hyperlink>+ </Td>+ <Td>+ <JobStatus status={job.status} />+ </Td>+ <Td>+ {job.quantityComplete}/{job.productionQuantity}+ </Td>+ <Td>+ <Assignee+ id={job.id!}+ table="job"+ value={job.assignee ?? ""}+ isReadOnly={+ !permissions.can("update", "production")+ }+ />+ </Td>+ </Tr>+ ))+ ) : (+ <Tr>+ <Td colSpan={4} className="py-8">+ <Empty />+ </Td>+ </Tr>+ )}+ </Tbody>+ </Table>+ )}</div></motion.div></motion.div>diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsxindex 235f24aa83..520aeedda8 100644--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx@@ -1,13 +1,15 @@import {Badge,Checkbox,+ HoverCard,+ HoverCardContent,+ HoverCardTrigger,HStack,MenuIcon,MenuItem,- Popover,- PopoverContent,- PopoverHeader,- PopoverTrigger,+ Tooltip,+ TooltipContent,+ TooltipTrigger,useDisclosure,} from "@carbon/react";import { formatDate } from "@carbon/utils";@@ -17,14 +19,18 @@ import { memo, useCallback, useMemo, useState } from "react";import {LuBookMarked,LuCalendar,+ LuCheck,LuCreditCard,LuDollarSign,- LuExternalLink,+ LuEllipsisVertical,+ LuFactory,+ LuLoader,LuPencil,LuQrCode,LuSquareUser,LuStar,LuTrash,+ LuTriangleAlert,LuTruck,LuUser,} from "react-icons/lu";@@ -47,7 +53,7 @@ import JobStatus from "~/modules/production/ui/Jobs/JobStatus";import { useCustomers, usePeople } from "~/stores";import { path } from "~/utils/path";import { salesOrderStatusType } from "../../sales.models";-import type { SalesOrder } from "../../types";+import type { SalesOrder, SalesOrderJob } from "../../types";import SalesStatus from "./SalesStatus";type SalesOrdersTableProps = {@@ -81,7 +87,7 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {cell: ({ row }) => (<HStack><ItemThumbnail- size="sm"+ size="md"thumbnailPath={row.original.thumbnailPath}// @ts-ignoretype={row.original.itemType}@@ -135,47 +141,108 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {id: "jobs",header: "Jobs",cell: ({ row }) => {- if (row.original.jobs === null || !Array.isArray(row.original.jobs))+ const jobs = (row.original.jobs ?? []) as SalesOrderJob[];+ const lines =+ (row.original.lines as {+ id: string;+ saleQuantity: number;+ methodType: "Buy" | "Make" | "Pick";+ }[]) ?? [];++ if (+ lines.length === 0 ||+ lines.every((line) => line.methodType !== "Make")+ ) {return null;+ }++ const everyMadeLineHasSufficientJobs = lines.every((line) => {+ if (line.methodType !== "Make") return true;+ const relevantJobs =+ jobs.filter((job) => job.salesOrderLineId === line.id) ?? [];+ const totalJobQuantity = relevantJobs.reduce(+ (acc, job) => acc + job.productionQuantity,+ 0+ );++ return totalJobQuantity >= line.saleQuantity;+ });++ const everyMadeLineIsCompleted = lines.every((line) => {+ if (line.methodType !== "Make") return true;+ const relevantJobs =+ jobs.filter((job) => job.salesOrderLineId === line.id) ?? [];+ const totalJobQuantity = relevantJobs.reduce(+ (acc, job) => acc + job.quantityComplete,+ 0+ );+ return totalJobQuantity >= line.saleQuantity;+ });++ const statusIcon = everyMadeLineIsCompleted ? (+ <LuCheck className="w-3 h-3 mr-2 text-emerald-500" />+ ) : everyMadeLineHasSufficientJobs ? (+ <LuLoader className="w-3 h-3 mr-2 text-orange-500" />+ ) : (+ <LuTriangleAlert className="w-3 h-3 mr-2 text-red-500" />+ );+return (- <Popover>- <PopoverTrigger>- <Badge variant="secondary">- {row.original.jobs.length} Jobs- <LuExternalLink className="w-3 h-3 ml-2" />- </Badge>- </PopoverTrigger>- <PopoverContent>- <PopoverHeader>Jobs</PopoverHeader>- <div className="flex flex-col w-full gap-4 text-sm">- {(- row.original.jobs as {- id: string;- jobId: string;- status: "Draft";- }[]- ).map((job) => (- <div- key={job.id}- className="flex items-center justify-between gap-2"- >- <Hyperlink- to={path.to.jobDetails(job.id)}- className="flex items-center justify-start gap-1"- >- {job.jobId}- <LuExternalLink className="w-4 h-4" />- </Hyperlink>- <div className="flex items-center justify-end">- <JobStatus status={job.status} />- </div>+ <div className="flex flex-row items-center justify-center gap-2">+ {!everyMadeLineHasSufficientJobs && jobs.length === 0 && (+ <Tooltip>+ <TooltipTrigger>+ <LuTriangleAlert className="w-3 h-3 mr-2 text-red-500" />+ </TooltipTrigger>+ <TooltipContent side="left">+ <p>Not enough jobs to cover quantity</p>+ </TooltipContent>+ </Tooltip>+ )}+ {jobs.length > 0 && (+ <HoverCard>+ <HoverCardTrigger>+ <Badge variant="secondary" className="cursor-pointer">+ {statusIcon}+ {jobs.length} Job+ {jobs.length > 1 ? "s" : ""}+ <LuEllipsisVertical className="w-3 h-3 ml-2" />+ </Badge>+ </HoverCardTrigger>+ <HoverCardContent>+ <div className="flex flex-col w-full gap-4 text-sm">+ {(+ jobs as {+ id: string;+ jobId: string;+ status: "Draft";+ }[]+ ).map((job) => (+ <div+ key={job.id}+ className="flex items-center justify-between gap-2"+ >+ <Hyperlink+ to={path.to.jobDetails(job.id)}+ className="flex items-center justify-start gap-1"+ >+ {job.jobId}+ </Hyperlink>+ <div className="flex items-center justify-end">+ <JobStatus status={job.status} />+ </div>+ </div>+ ))}</div>- ))}- </div>- </PopoverContent>- </Popover>+ </HoverCardContent>+ </HoverCard>+ )}+ </div>);},+ meta: {+ icon: <LuFactory />,+ },},{accessorKey: "customerReference",diff --git a/apps/erp/app/routes/share+/quote.$id.tsx b/apps/erp/app/routes/share+/quote.$id.tsxindex 21eadba1ad..b2bc533b7e 100644--- a/apps/erp/app/routes/share+/quote.$id.tsx+++ b/apps/erp/app/routes/share+/quote.$id.tsx@@ -45,7 +45,7 @@ import type { Dispatch, SetStateAction } from "react";import { useEffect, useMemo, useRef, useState } from "react";import { useDropzone } from "react-dropzone";import {- LuChevronDown,+ LuChevronRight,LuCircleX,LuCreditCard,LuImage,@@ -515,7 +515,7 @@ const LineItems = ({src={thumbnails[line.id!] ?? undefined}/>) : (- <div className="w-20 h-20 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-2">+ <div className="w-24 h-24 bg-gradient-to-bl from-muted to-muted/40 rounded-lg p-4"><LuImage className="w-16 h-16 text-muted-foreground" /></div>)}@@ -546,11 +546,11 @@ const LineItems = ({/><motion.divanimate={{- rotate: openItems.includes(line.id) ? 180 : 0,+ rotate: openItems.includes(line.id) ? 90 : 0,}}transition={{ duration: 0.3 }}>- <LuChevronDown size={24} />+ <LuChevronRight size={24} /></motion.div></HStack></div>diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.details.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.details.tsxindex ca12b3038b..a2837f784b 100644--- a/apps/erp/app/routes/x+/sales-order+/$orderId.details.tsx+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.details.tsx@@ -3,13 +3,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";import type { Database } from "@carbon/database";import { validationError, validator } from "@carbon/form";-import {- Card,- CardContent,- CardHeader,- CardTitle,- Spinner,-} from "@carbon/react";+import { Spinner } from "@carbon/react";import { Await, useLoaderData, useParams } from "@remix-run/react";import type { FileObject } from "@supabase/storage-js";import type { JSONContent } from "@tiptap/react";@@ -186,7 +180,7 @@ export default function SalesOrderDetailsRoute() {opportunity={orderData?.opportunity!}/><SalesOrderSummary onEditShippingCost={handleEditShippingCost} />- {/* <SalesOrderJobsSummary /> */}+<OpportunityNoteskey={`notes-${orderId}`}id={orderData.salesOrder.id}@@ -228,18 +222,3 @@ export default function SalesOrderDetailsRoute() {</>);}--function SalesOrderJobsSummary() {- return (- <Card>- <CardHeader>- <CardTitle>Jobs</CardTitle>- </CardHeader>- <CardContent>- <div>- <p>Jobs</p>- </div>- </CardContent>- </Card>- );-}diff --git a/apps/mes/app/components/Kanban/components/ItemCard.tsx b/apps/mes/app/components/Kanban/components/ItemCard.tsxindex 3726b7de4e..76f606b4fb 100644--- a/apps/mes/app/components/Kanban/components/ItemCard.tsx+++ b/apps/mes/app/components/Kanban/components/ItemCard.tsx@@ -5,6 +5,7 @@ import {CardFooter,CardHeader,cn,+ Heading,HStack,Tooltip,TooltipContent,@@ -99,8 +100,8 @@ export function ItemCard({}))}>- <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">+ <CardHeader className="-mx-4 flex flex-row justify-between relative border-b py-3 px-4 rounded-t-lg">+ <div className="flex w-full max-w-full justify-between items-start gap-2"><div className="flex flex-col space-y-0 min-w-0">{item.itemReadableId && (<span className="text-xs text-muted-foreground line-clamp-1">@@ -111,6 +112,9 @@ export function ItemCard({{item.itemDescription || item.itemReadableId}</span></div>+ <Heading size="h4" className="text-muted-foreground/70">+ {item.operationQuantity}+ </Heading></div></CardHeader>diff --git a/apps/mes/app/components/Kanban/types.ts b/apps/mes/app/components/Kanban/types.tsindex 3983fd1287..b8c79f74c3 100644--- a/apps/mes/app/components/Kanban/types.ts+++ b/apps/mes/app/components/Kanban/types.ts@@ -47,6 +47,7 @@ const itemValidator = z.object({itemDescription: z.string().optional(),itemReadableId: z.string().optional(),jobReadableId: z.string().optional(),+ operationQuantity: z.number().optional(),progress: z.number().optional(), // milisecondsstatus: z.enum(jobOperationStatus).optional(),salesOrderReadableId: z.string().optional(),diff --git a/apps/mes/app/components/OperationsList.tsx b/apps/mes/app/components/OperationsList.tsxindex 867039e00d..36ed540d7b 100644--- a/apps/mes/app/components/OperationsList.tsx+++ b/apps/mes/app/components/OperationsList.tsx@@ -5,6 +5,7 @@ import {CardFooter,CardHeader,cn,+ Heading,HStack,Tooltip,TooltipContent,@@ -109,7 +110,7 @@ function OperationCard({className="flex flex-col flex-1"><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 w-full max-w-full justify-between items-start gap-2"><div className="flex flex-col space-y-0 min-w-0">{operation.itemReadableId && (<span className="text-xs text-muted-foreground line-clamp-1">@@ -117,9 +118,12 @@ function OperationCard({</span>)}<span className="mr-auto font-semibold line-clamp-2 leading-tight">- {operation.itemDescription}+ {operation.itemDescription || operation.itemReadableId}</span></div>+ <Heading size="h4" className="text-muted-foreground/70">+ {operation.operationQuantity}+ </Heading></div></CardHeader><CardContent className="pt-3 px-1 gap-2 text-left whitespace-pre-wrap text-sm flex-grow">diff --git a/apps/mes/app/routes/x+/operation.$operationId.tsx b/apps/mes/app/routes/x+/operation.$operationId.tsxindex 0c1dfb334a..3b2d3cea98 100644--- a/apps/mes/app/routes/x+/operation.$operationId.tsx+++ b/apps/mes/app/routes/x+/operation.$operationId.tsx@@ -62,7 +62,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {const thumbnailPath = await getThumbnailPathByItemId(serviceRole,- job.data.itemId+ operation.data?.[0].itemId);return defer({diff --git a/apps/mes/app/routes/x+/operations.tsx b/apps/mes/app/routes/x+/operations.tsxindex 5f4a1191b5..23607c22b0 100644--- a/apps/mes/app/routes/x+/operations.tsx+++ b/apps/mes/app/routes/x+/operations.tsx@@ -230,6 +230,7 @@ export async function loader({ request }: LoaderFunctionArgs) {Math.max(operation.laborDuration, operation.machineDuration),deadlineType: op.jobDeadlineType,customerId: op.jobCustomerId,+ operationQuantity: op.operationQuantity,jobReadableId: op.jobReadableId,itemReadableId: op.itemReadableId,itemDescription: op.itemDescription,diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex f7f12cbd74..fe6f8b6c75 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -7879,20 +7879,6 @@ export type Database = {referencedRelation: "quotes"referencedColumns: ["id"]},- {- foreignKeyName: "job_quoteLineId_fkey"- columns: ["quoteLineId"]- isOneToOne: false- referencedRelation: "quoteLine"- referencedColumns: ["id"]- },- {- foreignKeyName: "job_quoteLineId_fkey"- columns: ["quoteLineId"]- isOneToOne: false- referencedRelation: "quoteLines"- referencedColumns: ["id"]- },{foreignKeyName: "job_salesOrderId_fkey"columns: ["salesOrderId"]@@ -27076,20 +27062,6 @@ export type Database = {referencedRelation: "quotes"referencedColumns: ["id"]},- {- foreignKeyName: "job_quoteLineId_fkey"- columns: ["quoteLineId"]- isOneToOne: false- referencedRelation: "quoteLine"- referencedColumns: ["id"]- },- {- foreignKeyName: "job_quoteLineId_fkey"- columns: ["quoteLineId"]- isOneToOne: false- referencedRelation: "quoteLines"- referencedColumns: ["id"]- },{foreignKeyName: "job_salesOrderId_fkey"columns: ["salesOrderId"]@@ -30351,6 +30323,7 @@ export type Database = {internalNotes: Json | nullitemType: Database["public"]["Enums"]["itemType"] | nulljobs: Json[] | null+ lines: Json[] | nulllocationId: string | nullorderDate: string | nullorderTotal: number | nulldiff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex f7f12cbd74..fe6f8b6c75 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -7879,20 +7879,6 @@ export type Database = {referencedRelation: "quotes"referencedColumns: ["id"]},- {- foreignKeyName: "job_quoteLineId_fkey"- columns: ["quoteLineId"]- isOneToOne: false- referencedRelation: "quoteLine"- referencedColumns: ["id"]- },- {- foreignKeyName: "job_quoteLineId_fkey"- columns: ["quoteLineId"]- isOneToOne: false- referencedRelation: "quoteLines"- referencedColumns: ["id"]- },{foreignKeyName: "job_salesOrderId_fkey"columns: ["salesOrderId"]@@ -27076,20 +27062,6 @@ export type Database = {referencedRelation: "quotes"referencedColumns: ["id"]},- {- foreignKeyName: "job_quoteLineId_fkey"- columns: ["quoteLineId"]- isOneToOne: false- referencedRelation: "quoteLine"- referencedColumns: ["id"]- },- {- foreignKeyName: "job_quoteLineId_fkey"- columns: ["quoteLineId"]- isOneToOne: false- referencedRelation: "quoteLines"- referencedColumns: ["id"]- },{foreignKeyName: "job_salesOrderId_fkey"columns: ["salesOrderId"]@@ -30351,6 +30323,7 @@ export type Database = {internalNotes: Json | nullitemType: Database["public"]["Enums"]["itemType"] | nulljobs: Json[] | null+ lines: Json[] | nulllocationId: string | nullorderDate: string | nullorderTotal: number | nulldiff --git a/packages/database/supabase/migrations/20250124174744_add-sales-order-line-to-jobs.sql b/packages/database/supabase/migrations/20250124174744_add-sales-order-line-to-jobs.sqlnew file mode 100644index 0000000000..67675bdf51--- /dev/null+++ b/packages/database/supabase/migrations/20250124174744_add-sales-order-line-to-jobs.sql@@ -0,0 +1,60 @@++DROP VIEW IF EXISTS "salesOrders";+CREATE OR REPLACE VIEW "salesOrders" WITH(SECURITY_INVOKER=true) AS+ SELECT+ s.*,+ sl."thumbnailPath",+ sl."itemType",+ sl."orderTotal" + COALESCE(ss."shippingCost", 0) AS "orderTotal",+ sl."jobs",+ sl."lines",+ st."name" AS "shippingTermName",+ sp."paymentTermId",+ ss."shippingMethodId",+ ss."receiptRequestedDate",+ ss."receiptPromisedDate",+ ss."dropShipment",+ ss."shippingCost"+ FROM "salesOrder" s+ LEFT JOIN (+ SELECT+ sol."salesOrderId",+ MIN(CASE+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"+ ELSE i."thumbnailPath"+ END) AS "thumbnailPath",+ SUM((1+COALESCE(sol."taxPercent", 0))*(COALESCE(sol."saleQuantity", 0)*(COALESCE(sol."unitPrice", 0)) + COALESCE(sol."shippingCost", 0) + COALESCE(sol."addOnCost", 0))) AS "orderTotal",+ MIN(i."type") AS "itemType",+ ARRAY_AGG(+ CASE+ WHEN j.id IS NOT NULL THEN json_build_object(+ 'id', j.id,+ 'jobId', j."jobId",+ 'status', j."status",+ 'productionQuantity', j."productionQuantity",+ 'quantityComplete', j."quantityComplete",+ 'salesOrderLineId', sol.id,+ 'assignee', j."assignee"+ )+ ELSE NULL+ END+ ) FILTER (WHERE j.id IS NOT NULL) AS "jobs",+ ARRAY_AGG(+ json_build_object(+ 'id', sol.id,+ 'methodType', sol."methodType",+ 'saleQuantity', sol."saleQuantity"+ )+ ) AS "lines"+ FROM "salesOrderLine" sol+ LEFT JOIN "item" i+ ON i."id" = sol."itemId"+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"+ LEFT JOIN "job" j ON j."salesOrderId" = sol."salesOrderId" AND j."salesOrderLineId" = sol."id"+ GROUP BY sol."salesOrderId"+ ) sl ON sl."salesOrderId" = s."id"+ LEFT JOIN "salesOrderShipment" ss ON ss."id" = s."id"+ LEFT JOIN "shippingTerm" st ON st."id" = ss."shippingTermId"+ LEFT JOIN "salesOrderPayment" sp ON sp."id" = s."id";++ALTER TABLE "job" DROP CONSTRAINT "job_quoteLineId_fkey";\ No newline at end of filediff --git a/packages/database/supabase/migrations/20250124211733_thumbnail-fix-on-cards.sql b/packages/database/supabase/migrations/20250124211733_thumbnail-fix-on-cards.sqlnew file mode 100644index 0000000000..eb7a42eeeb--- /dev/null+++ b/packages/database/supabase/migrations/20250124211733_thumbnail-fix-on-cards.sql@@ -0,0 +1,405 @@+DROP FUNCTION IF EXISTS get_assigned_job_operations;+CREATE OR REPLACE FUNCTION get_assigned_job_operations(+ user_id TEXT,+ company_id TEXT+)+RETURNS TABLE (+ "id" TEXT,+ "jobId" TEXT,+ "operationOrder" DOUBLE PRECISION,+ "processId" TEXT,+ "workCenterId" TEXT,+ "description" TEXT,+ "setupTime" NUMERIC(10,2),+ "setupUnit" factor,+ "laborTime" NUMERIC(10,2),+ "laborUnit" factor,+ "machineTime" NUMERIC(10,2),+ "machineUnit" factor,+ "operationOrderType" "methodOperationOrder",+ "jobReadableId" TEXT,+ "jobStatus" "jobStatus",+ "jobDueDate" DATE,+ "jobDeadlineType" "deadlineType",+ "jobCustomerId" TEXT,+ "salesOrderReadableId" TEXT,+ "salesOrderId" TEXT,+ "salesOrderLineId" TEXT,+ "parentMaterialId" TEXT,+ "itemReadableId" TEXT,+ "itemDescription" TEXT,+ "operationStatus" "jobOperationStatus",+ "operationQuantity" NUMERIC(10,2),+ "quantityComplete" NUMERIC(10,2),+ "quantityScrapped" NUMERIC(10,2),+ "thumbnailPath" TEXT,+ "assignee" TEXT,+ "tags" TEXT[]+)+SECURITY INVOKER+AS $$+BEGIN+ RETURN QUERY+ SELECT+ jo."id",+ jo."jobId",+ jo."order" AS "operationOrder",+ jo."processId",+ jo."workCenterId",+ jo."description",+ jo."setupTime",+ jo."setupUnit",+ jo."laborTime",+ jo."laborUnit",+ jo."machineTime",+ jo."machineUnit",+ jo."operationOrder" AS "operationOrderType",+ j."jobId" AS "jobReadableId",+ j."status" AS "jobStatus",+ j."dueDate" AS "jobDueDate",+ j."deadlineType" AS "jobDeadlineType",+ j."customerId" AS "jobCustomerId",+ so."salesOrderId" AS "salesOrderReadableId",+ so."id" AS "salesOrderId",+ j."salesOrderLineId",+ jmm."parentMaterialId",+ i."readableId" as "itemReadableId",+ i."name" as "itemDescription",+ CASE+ WHEN j."status" = 'Paused' THEN 'Paused'+ ELSE jo."status"+ END AS "operationStatus",+ jo."operationQuantity",+ jo."quantityComplete",+ jo."quantityScrapped",+ CASE+ WHEN jmm."parentMaterialId" IS NULL THEN COALESCE(i."thumbnailPath", j_mu."thumbnailPath", i_mu."thumbnailPath")+ ELSE COALESCE(i."thumbnailPath", i_mu."thumbnailPath")+ END as "thumbnailPath",+ jo."assignee",+ jo."tags"+ FROM "jobOperation" jo+ JOIN "job" j ON j.id = jo."jobId"+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id+ LEFT JOIN "item" i ON jmm."itemId" = i.id+ LEFT JOIN "modelUpload" j_mu ON j_mu.id = j."modelUploadId"+ LEFT JOIN "modelUpload" i_mu ON i_mu.id = i."modelUploadId"+ WHERE jo."assignee" = user_id+ AND jo."status" IN ('Todo', 'Ready', 'Waiting', 'In Progress', 'Paused')+ AND j."status" IN ('Ready', 'In Progress', 'Paused')+ AND j."companyId" = company_id+ ORDER BY jo."priority";+END;+$$ LANGUAGE plpgsql;++DROP FUNCTION IF EXISTS get_recent_job_operations_by_employee;+CREATE OR REPLACE FUNCTION get_recent_job_operations_by_employee(+ employee_id TEXT,+ company_id TEXT+)+RETURNS TABLE (+ "id" TEXT,+ "jobId" TEXT,+ "operationOrder" DOUBLE PRECISION,+ "processId" TEXT,+ "workCenterId" TEXT,+ "description" TEXT,+ "setupTime" NUMERIC(10,2),+ "setupUnit" factor,+ "laborTime" NUMERIC(10,2),+ "laborUnit" factor,+ "machineTime" NUMERIC(10,2),+ "machineUnit" factor,+ "operationOrderType" "methodOperationOrder",+ "jobReadableId" TEXT,+ "jobStatus" "jobStatus",+ "jobDueDate" DATE,+ "jobDeadlineType" "deadlineType",+ "jobCustomerId" TEXT,+ "salesOrderReadableId" TEXT,+ "salesOrderId" TEXT,+ "salesOrderLineId" TEXT,+ "parentMaterialId" TEXT,+ "itemReadableId" TEXT,+ "itemDescription" TEXT,+ "operationStatus" "jobOperationStatus",+ "operationQuantity" NUMERIC(10,2),+ "quantityComplete" NUMERIC(10,2),+ "quantityScrapped" NUMERIC(10,2),+ "thumbnailPath" TEXT,+ "assignee" TEXT,+ "tags" TEXT[]+)+SECURITY INVOKER+AS $$+BEGIN+ RETURN QUERY+ WITH recent_production_events AS (+ SELECT "jobOperationId", MAX("endTime") as "endTime"+ FROM "productionEvent"+ WHERE "employeeId" = employee_id AND "companyId" = company_id+ GROUP BY "jobOperationId"+ )+ SELECT+ jo."id",+ jo."jobId",+ jo."order" AS "operationOrder",+ jo."processId",+ jo."workCenterId",+ jo."description",+ jo."setupTime",+ jo."setupUnit",+ jo."laborTime",+ jo."laborUnit",+ jo."machineTime",+ jo."machineUnit",+ jo."operationOrder" AS "operationOrderType",+ j."jobId" AS "jobReadableId",+ j."status" AS "jobStatus",+ j."dueDate" AS "jobDueDate",+ j."deadlineType" AS "jobDeadlineType",+ j."customerId" AS "jobCustomerId",+ so."salesOrderId" AS "salesOrderReadableId",+ so."id" AS "salesOrderId",+ j."salesOrderLineId",+ jmm."parentMaterialId",+ i."readableId" as "itemReadableId",+ i."name" as "itemDescription",+ jo."status" AS "operationStatus",+ jo."operationQuantity",+ jo."quantityComplete",+ jo."quantityScrapped",+ CASE+ WHEN jmm."parentMaterialId" IS NULL THEN COALESCE(i."thumbnailPath", j_mu."thumbnailPath", i_mu."thumbnailPath")+ ELSE COALESCE(i."thumbnailPath", i_mu."thumbnailPath")+ END as "thumbnailPath",+ jo."assignee",+ jo."tags"+ FROM recent_production_events rpe+ JOIN "jobOperation" jo ON jo.id = rpe."jobOperationId"+ JOIN "job" j ON j.id = jo."jobId"+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id+ LEFT JOIN "item" i ON jmm."itemId" = i.id+ LEFT JOIN "modelUpload" j_mu ON j_mu.id = j."modelUploadId"+ LEFT JOIN "modelUpload" i_mu ON i_mu.id = i."modelUploadId"+ ORDER BY rpe."endTime" DESC+ LIMIT 20;+END;+$$ LANGUAGE plpgsql;+++DROP FUNCTION IF EXISTS get_active_job_operations_by_employee;+CREATE OR REPLACE FUNCTION get_active_job_operations_by_employee(+ employee_id TEXT,+ company_id TEXT+)+RETURNS TABLE (+ "id" TEXT,+ "jobId" TEXT,+ "operationOrder" DOUBLE PRECISION,+ "processId" TEXT,+ "workCenterId" TEXT,+ "description" TEXT,+ "setupTime" NUMERIC(10,2),+ "setupUnit" factor,+ "laborTime" NUMERIC(10,2),+ "laborUnit" factor,+ "machineTime" NUMERIC(10,2),+ "machineUnit" factor,+ "operationOrderType" "methodOperationOrder",+ "jobReadableId" TEXT,+ "jobStatus" "jobStatus",+ "jobDueDate" DATE,+ "jobDeadlineType" "deadlineType",+ "jobCustomerId" TEXT,+ "salesOrderReadableId" TEXT,+ "salesOrderId" TEXT,+ "salesOrderLineId" TEXT,+ "parentMaterialId" TEXT,+ "itemReadableId" TEXT,+ "itemDescription" TEXT,+ "operationStatus" "jobOperationStatus",+ "operationQuantity" NUMERIC(10,2),+ "quantityComplete" NUMERIC(10,2),+ "quantityScrapped" NUMERIC(10,2),+ "thumbnailPath" TEXT,+ "assignee" TEXT,+ "tags" TEXT[]+)+SECURITY INVOKER+AS $$+BEGIN+ RETURN QUERY+ WITH active_production_events AS (+ SELECT DISTINCT "jobOperationId"+ FROM "productionEvent"+ WHERE "employeeId" = employee_id AND "endTime" IS NULL AND "companyId" = company_id+ )+ SELECT+ jo."id",+ jo."jobId",+ jo."order" AS "operationOrder",+ jo."processId",+ jo."workCenterId",+ jo."description",+ jo."setupTime",+ jo."setupUnit",+ jo."laborTime",+ jo."laborUnit",+ jo."machineTime",+ jo."machineUnit",+ jo."operationOrder" AS "operationOrderType",+ j."jobId" AS "jobReadableId",+ j."status" AS "jobStatus",+ j."dueDate" AS "jobDueDate",+ j."deadlineType" AS "jobDeadlineType",+ j."customerId" AS "jobCustomerId",+ so."salesOrderId" AS "salesOrderReadableId",+ so."id" AS "salesOrderId",+ j."salesOrderLineId",+ jmm."parentMaterialId",+ i."readableId" as "itemReadableId",+ i."name" as "itemDescription",+ jo."status" AS "operationStatus",+ jo."operationQuantity",+ jo."quantityComplete",+ jo."quantityScrapped",+ CASE+ WHEN jmm."parentMaterialId" IS NULL THEN COALESCE(i."thumbnailPath", j_mu."thumbnailPath", i_mu."thumbnailPath")+ ELSE COALESCE(i."thumbnailPath", i_mu."thumbnailPath")+ END as "thumbnailPath",+ jo."assignee",+ jo."tags"+ FROM "jobOperation" jo+ JOIN "job" j ON j.id = jo."jobId"+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id+ LEFT JOIN "item" i ON jmm."itemId" = i.id+ LEFT JOIN "modelUpload" j_mu ON j_mu.id = j."modelUploadId"+ LEFT JOIN "modelUpload" i_mu ON i_mu.id = i."modelUploadId"+ JOIN active_production_events ape ON ape."jobOperationId" = jo.id;+END;+$$ LANGUAGE plpgsql;+++DROP FUNCTION IF EXISTS get_active_job_operations_by_location;+CREATE OR REPLACE FUNCTION get_active_job_operations_by_location(+ location_id TEXT,+ work_center_ids TEXT[]+)+RETURNS TABLE (+ "id" TEXT,+ "jobId" TEXT,+ "operationOrder" DOUBLE PRECISION,+ "priority" DOUBLE PRECISION,+ "processId" TEXT,+ "workCenterId" TEXT,+ "description" TEXT,+ "setupTime" NUMERIC(10,2),+ "setupUnit" factor,+ "laborTime" NUMERIC(10,2),+ "laborUnit" factor,+ "machineTime" NUMERIC(10,2),+ "machineUnit" factor,+ "operationOrderType" "methodOperationOrder",+ "jobMakeMethodId" TEXT,+ "assignee" TEXT,+ "tags" TEXT[],+ "jobReadableId" TEXT,+ "jobStatus" "jobStatus",+ "jobDueDate" DATE,+ "jobDeadlineType" "deadlineType",+ "jobCustomerId" TEXT,+ "salesOrderReadableId" TEXT,+ "salesOrderId" TEXT,+ "salesOrderLineId" TEXT,+ "parentMaterialId" TEXT,+ "itemReadableId" TEXT,+ "itemDescription" TEXT,+ "operationStatus" "jobOperationStatus",+ "operationQuantity" NUMERIC(10,2),+ "quantityComplete" NUMERIC(10,2),+ "quantityScrapped" NUMERIC(10,2),+ "thumbnailPath" TEXT+)+SECURITY INVOKER+AS $$+BEGIN+ RETURN QUERY+ WITH relevant_jobs AS (+ SELECT+ j."id",+ j."jobId",+ j."status",+ j."dueDate",+ j."deadlineType",+ j."customerId",+ so."salesOrderId" AS "salesOrderReadableId",+ so."id" AS "salesOrderId",+ j."salesOrderLineId",+ mu."thumbnailPath"+ FROM "job" j+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"+ LEFT JOIN "modelUpload" mu ON mu.id = j."modelUploadId"+ WHERE j."locationId" = location_id+ AND (j."status" = 'Ready' OR j."status" = 'In Progress' OR j."status" = 'Paused')+ )+ SELECT+ jo."id",+ jo."jobId",+ jo."order" AS "operationOrder",+ jo."priority",+ jo."processId",+ jo."workCenterId",+ jo."description",+ jo."setupTime",+ jo."setupUnit",+ jo."laborTime",+ jo."laborUnit",+ jo."machineTime",+ jo."machineUnit",+ jo."operationOrder" AS "operationOrderType",+ jo."jobMakeMethodId",+ jo."assignee",+ jo."tags",+ rj."jobId" AS "jobReadableId",+ rj."status" AS "jobStatus",+ rj."dueDate" AS "jobDueDate",+ rj."deadlineType" AS "jobDeadlineType",+ rj."customerId" AS "jobCustomerId",+ rj."salesOrderReadableId",+ rj."salesOrderId",+ rj."salesOrderLineId",+ jmm."parentMaterialId",+ i."readableId" as "itemReadableId",+ i."name" as "itemDescription",+ CASE+ WHEN rj."status" = 'Paused' THEN 'Paused'+ ELSE jo."status"+ END AS "operationStatus",+ jo."operationQuantity",+ jo."quantityComplete",+ jo."quantityScrapped",+ CASE+ WHEN jmm."parentMaterialId" IS NULL THEN COALESCE(i."thumbnailPath", rj."thumbnailPath", mu."thumbnailPath")+ ELSE COALESCE(i."thumbnailPath", mu."thumbnailPath")+ END as "thumbnailPath"+ FROM "jobOperation" jo+ JOIN relevant_jobs rj ON rj.id = jo."jobId"+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id+ LEFT JOIN "item" i ON jmm."itemId" = i.id+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"+ WHERE CASE+ WHEN array_length(work_center_ids, 1) > 0 THEN+ jo."workCenterId" = ANY(work_center_ids) AND jo."status" != 'Done' AND jo."status" != 'Canceled'+ ELSE jo."status" != 'Done' AND jo."status" != 'Canceled'+ END+ ORDER BY jo."priority";+END;+$$ LANGUAGE plpgsql;\ No newline at end of filediff --git a/packages/react/src/Badge.tsx b/packages/react/src/Badge.tsxindex 2d31c17ffb..0328ed8591 100644--- a/packages/react/src/Badge.tsx+++ b/packages/react/src/Badge.tsx@@ -10,7 +10,7 @@ import { LuX } from "react-icons/lu";import { cn } from "./utils/cn";const badgeVariants = cva(- "inline-flex items-center rounded-md px-2.5 py-0.5 h-6 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 uppercase font-bold text-xs truncate tracking-tight",+ "inline-flex items-center rounded-md px-2 py-0.5 pb-px min-h-5.5 font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 uppercase font-bold text-[11px] truncate tracking-tight",{variants: {variant: {@@ -22,13 +22,13 @@ const badgeVariants = cva("bg-destructive text-destructive-foreground shadow:sm dark:shadow hover:bg-destructive/80",outline: "text-foreground",green:- "bg-emerald-600 text-emerald-100 dark:bg-emerald-900/50 dark:text-emerald-400",+ "bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-400",yellow:- "bg-yellow-600 text-yellow-100 dark:bg-yellow-900/50 dark:text-yellow-300",+ "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/50 dark:text-yellow-300",orange:- "bg-orange-600 text-orange-100 dark:bg-orange-900/50 dark:text-orange-300",- red: "bg-red-600 text-red-100 dark:bg-red-900/50 dark:text-red-400",- blue: "bg-blue-600 text-blue-100 dark:bg-blue-900/50 dark:text-blue-400",+ "bg-orange-100 text-orange-800 dark:bg-orange-900/50 dark:text-orange-300",+ red: "bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-400",+ blue: "bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-400",gray: "bg-[#e3e2e080] text-[#32302c] dark:bg-[#373737] dark:text-white hover:bg-[#e3e2e0] dark:hover:bg-[#5a5a5a]",},},