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: quote assembly form ui
Brad Barbin2659520597ee
diff --git a/apps/carbon/app/components/Form/Part.tsx b/apps/carbon/app/components/Form/Part.tsxindex 8801ab1e73..41e0f442e5 100644--- a/apps/carbon/app/components/Form/Part.tsx+++ b/apps/carbon/app/components/Form/Part.tsx@@ -16,9 +16,9 @@ const Part = ({ partReplenishmentSystem, ...props }: PartSelectProps) => {parts.filter((part) => {if (partReplenishmentSystem === "Buy") {- return part.replenishmentSystem === "Buy";+ return ["Buy", "Buy and Make"].includes(partReplenishmentSystem);} else if (partReplenishmentSystem === "Make") {- return part.replenishmentSystem === "Make";+ return ["Make", "Buy and Make"].includes(partReplenishmentSystem);} else {return true;}diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.tsindex 7fa4a3a8c2..d262c52730 100644--- a/apps/carbon/app/modules/sales/sales.models.ts+++ b/apps/carbon/app/modules/sales/sales.models.ts@@ -86,6 +86,21 @@ export const quotationValidator = withZod(}));+export const quotationAssemblyValidator = withZod(+ z.object({+ id: zfd.text(z.string().optional()),+ quoteId: z.string().min(20, { message: "Quote is required" }),+ quoteLineId: z.string().min(20, { message: "Quote line is required" }),+ parentAssemblyId: zfd.text(z.string().optional()),+ partId: z.string().min(1, { message: "Part is required" }),+ description: z.string().min(1, { message: "Description is required" }),+ unitOfMeasureCode: zfd.text(z.string().optional()),+ quantityPerParent: zfd.numeric(+ z.number().min(1, { message: "Quantity is required" })+ ),+ })+);+export const quotationLineValidator = withZod(z.object({id: zfd.text(z.string().optional()),diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsxnew file mode 100644index 0000000000..545b4cab0f--- /dev/null+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx@@ -0,0 +1,172 @@+import {+ Button,+ Card,+ CardContent,+ CardDescription,+ CardFooter,+ CardHeader,+ CardTitle,+ VStack,+ cn,+} from "@carbon/react";+import { useParams } from "@remix-run/react";+import { useState } from "react";+import { BsDownload, BsUpload } from "react-icons/bs";+import { ValidatedForm } from "remix-validated-form";+import {+ Hidden,+ InputControlled,+ Number,+ Part,+ Submit,+} from "~/components/Form";+import { usePermissions } from "~/hooks";+import { useSupabase } from "~/lib/supabase";+import { quotationAssemblyValidator } from "~/modules/sales";+import type { TypeOfValidator } from "~/types/validators";+import { path } from "~/utils/path";++type QuotationAssemblyFormValues = TypeOfValidator<+ typeof quotationAssemblyValidator+>;++type QuotationAssemblyFormProps = {+ initialValues: QuotationAssemblyFormValues;+};++const QuotationAssemblyForm = ({+ initialValues,+}: QuotationAssemblyFormProps) => {+ const permissions = usePermissions();+ const { supabase } = useSupabase();++ const { id: quoteId, lineId } = useParams();+ if (!quoteId) throw new Error("quoteId not found");+ if (!lineId) throw new Error("lineId not found");++ const isEditing = initialValues.id !== undefined;++ const [partData, setPartData] = useState<{+ partId: string;+ description: string;+ uom: string;+ }>({+ partId: initialValues.partId ?? "",+ description: initialValues.description ?? "",+ uom: initialValues.unitOfMeasureCode ?? "",+ });++ const onPartChange = async (partId: string) => {+ if (!supabase) return;+ const [part] = await Promise.all([+ supabase+ .from("part")+ .select("name, replenishmentSystem, unitOfMeasureCode")+ .eq("id", partId)+ .single(),+ ]);++ setPartData({+ partId,+ description: part.data?.name ?? "",+ uom: part.data?.unitOfMeasureCode ?? "",+ });+ };++ return (+ <ValidatedForm+ method="post"+ validator={quotationAssemblyValidator}+ defaultValues={initialValues}+ className="w-full"+ action={+ isEditing+ ? path.to.quoteAssembly(quoteId, lineId, initialValues.id!)+ : path.to.newQuoteAssembly(quoteId, lineId)+ }+ >+ <Card className={cn(!isEditing && "mt-4")}>+ <CardHeader>+ <CardTitle>{partData?.partId || "New Assembly"}</CardTitle>+ {!isEditing && (+ <CardDescription>+ A quote assembly is a collection of operations, materials, and+ subassemblies that are used to build a product.+ </CardDescription>+ )}+ </CardHeader>+ <CardContent>+ <Hidden name="id" />+ <Hidden name="quoteId" />+ <Hidden name="quoteLineId" />+ <Hidden name="parentAssemblyId" />+ <Hidden name="unitOfMeasureCode" value={partData?.uom} />+ <VStack>+ <div className="grid w-full gap-x-8 gap-y-2 grid-cols-1 md:grid-cols-3">+ <VStack>+ <Part+ name="partId"+ label="Part"+ partReplenishmentSystem="Make"+ onChange={(value) => {+ onPartChange(value?.value as string);+ }}+ />+ </VStack>+ <VStack>+ <InputControlled+ name="description"+ label="Description"+ value={partData.description}+ onChange={(newValue) =>+ setPartData((d) => ({ ...d, description: newValue }))+ }+ />+ </VStack>+ <VStack>+ <Number+ name="quantityPerParent"+ label="Quantity per Parent"+ minValue={0}+ />+ {isEditing && (+ <>+ <Button+ isDisabled+ variant="secondary"+ className="w-full"+ leftIcon={<BsDownload />}+ >+ Get Part+ </Button>+ <Button+ isDisabled+ variant="secondary"+ className="w-full"+ leftIcon={<BsUpload />}+ >+ Set Part+ </Button>+ </>+ )}+ </VStack>+ </div>+ </VStack>+ </CardContent>+ <CardFooter>+ <Submit+ isDisabled={+ isEditing+ ? !permissions.can("update", "sales")+ : !permissions.can("create", "sales")+ }+ >+ Save+ </Submit>+ </CardFooter>+ </Card>+ </ValidatedForm>+ );+};++export default QuotationAssemblyForm;diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsxindex f6ecc68268..3369a59d12 100644--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx@@ -43,6 +43,17 @@ const QuotationLineForm = ({ initialValues }: QuotationLineFormProps) => {quotation: Quotation;}>(path.to.quote(id));+ const isEditable = ["Draft", "To Review"].includes(+ routeData?.quotation?.status ?? ""+ );++ const isEditing = initialValues.id !== undefined;+ const isDisabled = !isEditable+ ? true+ : isEditing+ ? !permissions.can("update", "sales")+ : !permissions.can("create", "sales");+const [partData, setPartData] = useState<{partId: string;description: string;@@ -55,17 +66,6 @@ const QuotationLineForm = ({ initialValues }: QuotationLineFormProps) => {uom: initialValues.unitOfMeasureCode ?? "",});- const isEditable = ["Draft", "To Review"].includes(- routeData?.quotation?.status ?? ""- );-- const isEditing = initialValues.id !== undefined;- const isDisabled = !isEditable- ? true- : isEditing- ? !permissions.can("update", "sales")- : !permissions.can("create", "sales");-const onPartChange = async (partId: string) => {if (!supabase) return;const [part] = await Promise.all([diff --git a/apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.assembly.new.tsx b/apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.assembly.new.tsxnew file mode 100644index 0000000000..3dc2e32022--- /dev/null+++ b/apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.assembly.new.tsx@@ -0,0 +1,23 @@+import { useParams } from "@remix-run/react";+import { useUrlParams } from "~/hooks";+import QuotationAssemblyForm from "~/modules/sales/ui/Quotation/QuotationAssemblyForm";++export default function NewQuoteAssembly() {+ const { id: quoteId, lineId } = useParams();+ const [params] = useUrlParams();+ const parentAssemblyId = params.get("parentAssemblyId");++ if (!quoteId) throw new Error("quoteId not found");+ if (!lineId) throw new Error("lineId not found");++ const initialValues = {+ quoteId,+ quoteLineId: lineId,+ parentAssemblyId: parentAssemblyId ?? undefined,+ partId: "",+ description: "",+ quantityPerParent: 1,+ };++ return <QuotationAssemblyForm initialValues={initialValues} />;+}diff --git a/apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.tsx b/apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.details.tsxsimilarity index 100%rename from apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.tsxrename to apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.details.tsxdiff --git a/apps/carbon/app/routes/x+/quote+/$id.lines.delete.$lineId.tsx b/apps/carbon/app/routes/x+/quote+/$id.lines.delete.$lineId.tsxindex f387ef2a9a..5eb287b50d 100644--- a/apps/carbon/app/routes/x+/quote+/$id.lines.delete.$lineId.tsx+++ b/apps/carbon/app/routes/x+/quote+/$id.lines.delete.$lineId.tsx@@ -20,7 +20,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {const quotationLine = await getQuoteLine(client, lineId);if (quotationLine.error) {return redirect(- path.to.quoteLines(id),+ path.to.quote(id),await flash(request,error(quotationLine.error, "Failed to get quotation line")@@ -43,7 +43,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const { error: deleteTypeError } = await deleteQuoteLine(client, lineId);if (deleteTypeError) {return redirect(- path.to.quoteLines(id),+ path.to.quote(id),await flash(request,error(deleteTypeError, "Failed to delete quotation line")@@ -52,7 +52,7 @@ export async function action({ request, params }: ActionFunctionArgs) {}return redirect(- path.to.quoteLines(id),+ path.to.quote(id),await flash(request, success("Successfully deleted quotation line")));}@@ -66,15 +66,13 @@ export default function DeleteQuoteLineRoute() {if (!lineId) throw notFound("Could not find lineId");if (!id) throw notFound("Could not find id");- const onCancel = () => navigate(path.to.quoteLines(id));+ const onCancel = () => navigate(path.to.quote(id));return (<ConfirmDeleteaction={path.to.deleteQuoteLine(id, lineId)}name="Quote Line"- text={`Are you sure you want to delete the quotation line for ${- quotationLine.quantity ?? 0- } ${quotationLine.description ?? ""}? This cannot be undone.`}+ text={`Are you sure you want to delete the quotation line for ${quotationLine.partId}? This cannot be undone.`}onCancel={onCancel}/>);diff --git a/apps/carbon/app/routes/x+/quote+/$id.new.tsx b/apps/carbon/app/routes/x+/quote+/$id.new.tsxindex 7d6b7f0c6d..062e9c3d44 100644--- a/apps/carbon/app/routes/x+/quote+/$id.new.tsx+++ b/apps/carbon/app/routes/x+/quote+/$id.new.tsx@@ -40,7 +40,7 @@ export async function action({ request, params }: ActionFunctionArgs) {if (createQuotationLine.error) {return redirect(- path.to.quoteLines(quoteId),+ path.to.quote(quoteId),await flash(request,error(createQuotationLine.error, "Failed to create quote line.")diff --git a/apps/carbon/app/routes/x+/quote+/$id.tsx b/apps/carbon/app/routes/x+/quote+/$id.tsxindex 12cd40dc27..0533743d5e 100644--- a/apps/carbon/app/routes/x+/quote+/$id.tsx+++ b/apps/carbon/app/routes/x+/quote+/$id.tsx@@ -170,8 +170,8 @@ const data: BillOfMaterialNode[] = [type: "parent",children: [{- id: "cn8g57bau0l38ambhoeg",- label: "P000000002",+ id: "cn9edn5dq0l1fglkrqig",+ label: "P000000001",type: "line",children: [{@@ -300,9 +300,12 @@ const BillOfMaterialItem = ({<Buttonvariant="ghost"className="w-full justify-between text-muted-foreground"+ asChild>- <span>{label}</span>- <IoMdAdd />+ <Link to={path.to.newQuoteAssembly(quoteId, id)}>+ <span>{label}</span>+ <IoMdAdd />+ </Link></Button>);case "materials":diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.tsindex 68a7e3a965..f5bc8eebb1 100644--- a/apps/carbon/app/utils/path.ts+++ b/apps/carbon/app/utils/path.ts@@ -276,6 +276,8 @@ export const path = {newPurchaseOrderLine: (id: string) =>generatePath(`${x}/purchase-order/${id}/lines/new`),newQuote: `${x}/quote/new`,+ newQuoteAssembly: (quoteId: string, lineId: string) =>+ generatePath(`${x}/quote/${quoteId}/lines/${lineId}/assembly/new`),newQuoteLine: (id: string) => generatePath(`${x}/quote/${id}/new`),newQuoteLineQuantity: (id: string, lineId: string) =>generatePath(`${x}/quote/${id}/lines/${lineId}/new`),@@ -362,16 +364,18 @@ export const path = {purchaseOrders: `${x}/purchasing/orders`,purchasing: `${x}/purchasing`,quote: (id: string) => generatePath(`${x}/quote/${id}`),+ quoteAssembly: (quoteId: string, lineId: string, assemblyId: string) =>+ generatePath(+ `${x}/quote/${quoteId}/lines/${lineId}/assembly/${assemblyId}`+ ),quoteDetails: (id: string) => generatePath(`${x}/quote/${id}/details`),quoteExternalDocuments: (id: string) =>generatePath(`${x}/quote/${id}/external`),- quoteFavorite: `${x}/purchasing/orders/favorite`,+ quoteFavorite: `${x}/sales/quotes/favorite`,quoteInternalDocuments: (id: string) =>generatePath(`${x}/quote/${id}/internal`),- quoteLines: (quoteId: string) =>- generatePath(`${x}/quote/${quoteId}/lines`),quoteLine: (quoteId: string, id: string) =>- generatePath(`${x}/quote/${quoteId}/lines/${id}`),+ generatePath(`${x}/quote/${quoteId}/lines/${id}/details`),quoteRelease: (id: string) => generatePath(`${x}/quote/${id}/release`),quotes: `${x}/sales/quotes`,receipt: (id: string) => generatePath(`${x}/inventory/receipts/${id}`),diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 9ef36f7dfa..a96db070fd 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -6882,10 +6882,9 @@ export interface Database {createdBy: string;description: string | null;id: string;- parentModuleId: string | null;+ parentAssemblyId: string | null;partId: string;quantityPerParent: number;- quoteAssemblyId: string;quoteId: string;quoteLineId: string;unitOfMeasureCode: string | null;@@ -6897,10 +6896,9 @@ export interface Database {createdBy: string;description?: string | null;id?: string;- parentModuleId?: string | null;+ parentAssemblyId?: string | null;partId: string;quantityPerParent?: number;- quoteAssemblyId?: string;quoteId: string;quoteLineId: string;unitOfMeasureCode?: string | null;@@ -6912,10 +6910,9 @@ export interface Database {createdBy?: string;description?: string | null;id?: string;- parentModuleId?: string | null;+ parentAssemblyId?: string | null;partId?: string;quantityPerParent?: number;- quoteAssemblyId?: string;quoteId?: string;quoteLineId?: string;unitOfMeasureCode?: string | null;@@ -6942,8 +6939,8 @@ export interface Database {referencedColumns: ["userId"];},{- foreignKeyName: "quoteAssembly_parentModuleId_fkey";- columns: ["parentModuleId"];+ foreignKeyName: "quoteAssembly_parentAssemblyId_fkey";+ columns: ["parentAssemblyId"];referencedRelation: "quoteAssembly";referencedColumns: ["id"];},@@ -7265,7 +7262,7 @@ export interface Database {quantity: number;quoteId: string;quoteLineId: string;- quoteProcessId: string;+ quoteOperationId: string;unitCost: number;unitOfMeasureCode: string | null;updatedAt: string | null;@@ -7280,7 +7277,7 @@ export interface Database {quantity?: number;quoteId: string;quoteLineId: string;- quoteProcessId: string;+ quoteOperationId: string;unitCost?: number;unitOfMeasureCode?: string | null;updatedAt?: string | null;@@ -7295,7 +7292,7 @@ export interface Database {quantity?: number;quoteId?: string;quoteLineId?: string;- quoteProcessId?: string;+ quoteOperationId?: string;unitCost?: number;unitOfMeasureCode?: string | null;updatedAt?: string | null;@@ -7357,9 +7354,9 @@ export interface Database {referencedColumns: ["id"];},{- foreignKeyName: "quoteMaterial_quoteProcessId_fkey";- columns: ["quoteProcessId"];- referencedRelation: "quoteProcess";+ foreignKeyName: "quoteMaterial_quoteOperationId_fkey";+ columns: ["quoteOperationId"];+ referencedRelation: "quoteOperation";referencedColumns: ["id"];},{@@ -7382,7 +7379,7 @@ export interface Database {}];};- quoteProcess: {+ quoteOperation: {Row: {createdAt: string;createdBy: string;@@ -7442,73 +7439,73 @@ export interface Database {};Relationships: [{- foreignKeyName: "quoteProcess_createdBy_fkey";+ foreignKeyName: "quoteOperation_createdBy_fkey";columns: ["createdBy"];referencedRelation: "user";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_createdBy_fkey";+ foreignKeyName: "quoteOperation_createdBy_fkey";columns: ["createdBy"];referencedRelation: "employeeSummary";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_createdBy_fkey";+ foreignKeyName: "quoteOperation_createdBy_fkey";columns: ["createdBy"];referencedRelation: "userDefaults";referencedColumns: ["userId"];},{- foreignKeyName: "quoteProcess_equipmentTypeId_fkey";+ foreignKeyName: "quoteOperation_equipmentTypeId_fkey";columns: ["equipmentTypeId"];referencedRelation: "equipmentType";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_quoteAssemblyId_fkey";+ foreignKeyName: "quoteOperation_quoteAssemblyId_fkey";columns: ["quoteAssemblyId"];referencedRelation: "quoteAssembly";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_quoteId_fkey";+ foreignKeyName: "quoteOperation_quoteId_fkey";columns: ["quoteId"];referencedRelation: "quote";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_quoteId_fkey";+ foreignKeyName: "quoteOperation_quoteId_fkey";columns: ["quoteId"];referencedRelation: "quotes";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_quoteLineId_fkey";+ foreignKeyName: "quoteOperation_quoteLineId_fkey";columns: ["quoteLineId"];referencedRelation: "quoteLine";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_updatedBy_fkey";+ foreignKeyName: "quoteOperation_updatedBy_fkey";columns: ["updatedBy"];referencedRelation: "user";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_updatedBy_fkey";+ foreignKeyName: "quoteOperation_updatedBy_fkey";columns: ["updatedBy"];referencedRelation: "employeeSummary";referencedColumns: ["id"];},{- foreignKeyName: "quoteProcess_updatedBy_fkey";+ foreignKeyName: "quoteOperation_updatedBy_fkey";columns: ["updatedBy"];referencedRelation: "userDefaults";referencedColumns: ["userId"];},{- foreignKeyName: "quoteProcess_workCellTypeId_fkey";+ foreignKeyName: "quoteOperation_workCellTypeId_fkey";columns: ["workCellTypeId"];referencedRelation: "workCellType";referencedColumns: ["id"];diff --git a/packages/database/supabase/migrations/20240206224405_quotes.sql b/packages/database/supabase/migrations/20240206224405_quotes.sqlindex 0ebaab30af..378bf2a14d 100644--- a/packages/database/supabase/migrations/20240206224405_quotes.sql+++ b/packages/database/supabase/migrations/20240206224405_quotes.sql@@ -100,8 +100,7 @@ CREATE TABLE "quoteAssembly" ("id" TEXT NOT NULL DEFAULT xid(),"quoteId" TEXT NOT NULL,"quoteLineId" TEXT NOT NULL,- "quoteAssemblyId" TEXT NOT NULL DEFAULT xid(),- "parentModuleId" TEXT,+ "parentAssemblyId" TEXT,"partId" TEXT NOT NULL,"description" TEXT,"unitOfMeasureCode" TEXT,@@ -114,16 +113,16 @@ CREATE TABLE "quoteAssembly" (CONSTRAINT "quoteAssembly_pkey" PRIMARY KEY ("id"),CONSTRAINT "quoteAssembly_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "quoteAssembly_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteAssembly_parentModuleId_fkey" FOREIGN KEY ("parentModuleId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteAssembly_parentAssemblyId_fkey" FOREIGN KEY ("parentAssemblyId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "quoteAssembly_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quoteAssembly_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE);CREATE INDEX "quoteAssembly_quoteId_idx" ON "quoteAssembly" ("quoteId");CREATE INDEX "quoteAssembly_quoteLineId_idx" ON "quoteAssembly" ("quoteLineId");-CREATE INDEX "quoteAssembly_parentModuleId_idx" ON "quoteAssembly" ("parentModuleId");+CREATE INDEX "quoteAssembly_parentAssemblyId_idx" ON "quoteAssembly" ("parentAssemblyId");-CREATE TABLE "quoteProcess" (+CREATE TABLE "quoteOperation" ("id" TEXT NOT NULL DEFAULT xid(),"quoteId" TEXT NOT NULL,"quoteLineId" TEXT NOT NULL,@@ -142,25 +141,25 @@ CREATE TABLE "quoteProcess" ("updatedAt" TIMESTAMP WITH TIME ZONE,"updatedBy" TEXT,- CONSTRAINT "quoteProcess_pkey" PRIMARY KEY ("id"),- CONSTRAINT "quoteProcess_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteProcess_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteProcess_quoteAssemblyId_fkey" FOREIGN KEY ("quoteAssemblyId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteProcess_workCellTypeId_fkey" FOREIGN KEY ("workCellTypeId") REFERENCES "workCellType" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "quoteProcess_equipmentTypeId_fkey" FOREIGN KEY ("equipmentTypeId") REFERENCES "equipmentType" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "quoteProcess_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "quoteProcess_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE+ CONSTRAINT "quoteOperation_pkey" PRIMARY KEY ("id"),+ CONSTRAINT "quoteOperation_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteOperation_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteOperation_quoteAssemblyId_fkey" FOREIGN KEY ("quoteAssemblyId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteOperation_workCellTypeId_fkey" FOREIGN KEY ("workCellTypeId") REFERENCES "workCellType" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,+ CONSTRAINT "quoteOperation_equipmentTypeId_fkey" FOREIGN KEY ("equipmentTypeId") REFERENCES "equipmentType" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,+ CONSTRAINT "quoteOperation_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,+ CONSTRAINT "quoteOperation_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE);-CREATE INDEX "quoteProcess_quoteId_idx" ON "quoteProcess" ("quoteId");-CREATE INDEX "quoteProcess_quoteLineId_idx" ON "quoteProcess" ("quoteLineId");-CREATE INDEX "quoteProcess_quoteAssemblyId_idx" ON "quoteProcess" ("quoteAssemblyId");+CREATE INDEX "quoteOperation_quoteId_idx" ON "quoteOperation" ("quoteId");+CREATE INDEX "quoteOperation_quoteLineId_idx" ON "quoteOperation" ("quoteLineId");+CREATE INDEX "quoteOperation_quoteAssemblyId_idx" ON "quoteOperation" ("quoteAssemblyId");CREATE TABLE "quoteMaterial" ("id" TEXT NOT NULL DEFAULT xid(),"quoteId" TEXT NOT NULL,"quoteLineId" TEXT NOT NULL,- "quoteProcessId" TEXT NOT NULL,+ "quoteOperationId" TEXT NOT NULL,"partId" TEXT NOT NULL,"description" TEXT NOT NULL,"quantity" NUMERIC(10, 2) NOT NULL DEFAULT 0,@@ -174,7 +173,7 @@ CREATE TABLE "quoteMaterial" (CONSTRAINT "quoteMaterial_pkey" PRIMARY KEY ("id"),CONSTRAINT "quoteMaterial_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "quoteMaterial_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteMaterial_quoteProcessId_fkey" FOREIGN KEY ("quoteProcessId") REFERENCES "quoteProcess" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteMaterial_quoteOperationId_fkey" FOREIGN KEY ("quoteOperationId") REFERENCES "quoteOperation" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "quoteMaterial_partId_fkey" FOREIGN KEY ("partId") REFERENCES "part" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quoteMaterial_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quoteMaterial_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE