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: add the ability to do a partial get method
Brad Barbin7ca5ed1fc65e
diff --git a/apps/erp/app/modules/production/production.models.ts b/apps/erp/app/modules/production/production.models.tsindex 29bb271fd4..25c0371d62 100644--- a/apps/erp/app/modules/production/production.models.ts+++ b/apps/erp/app/modules/production/production.models.ts@@ -739,7 +739,13 @@ export const jobMaterialValidatorForReleasedJob = baseMaterialValidatorexport const getJobMethodValidator = z.object({sourceId: z.string().min(1, { message: "Source ID is required" }),- targetId: z.string().min(1, { message: "Please select a source method" })+ targetId: z.string().min(1, { message: "Please select a source method" }),+ billOfMaterial: zfd.checkbox(),+ billOfProcess: zfd.checkbox(),+ parameters: zfd.checkbox(),+ tools: zfd.checkbox(),+ steps: zfd.checkbox(),+ workInstructions: zfd.checkbox()});// export const getJobMaterialMethodValidator = z.object({diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex 1ea9feb724..8104943802 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -2338,6 +2338,14 @@ export async function upsertJobMethod(companyId: string;userId: string;configuration?: Record<string, unknown>;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };}) {const body: {@@ -2347,6 +2355,14 @@ export async function upsertJobMethod(companyId: string;userId: string;configuration?: Record<string, unknown>;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };} = {type,sourceId: jobMethod.sourceId,@@ -2360,6 +2376,11 @@ export async function upsertJobMethod(body.configuration = jobMethod.configuration;}+ // Only add parts if it exists+ if (jobMethod.parts !== undefined) {+ body.parts = jobMethod.parts;+ }+const getMethodResult = await client.functions.invoke("get-method", {body,region: FunctionRegion.UsEast1@@ -2382,6 +2403,14 @@ export async function upsertJobMaterialMakeMethod(companyId: string;userId: string;configuration?: Record<string, unknown>;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };}) {const body: {@@ -2391,6 +2420,14 @@ export async function upsertJobMaterialMakeMethod(companyId: string;userId: string;configuration?: Record<string, unknown>;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };} = {type: "itemToJobMakeMethod",sourceId: jobMaterial.sourceId,@@ -2404,6 +2441,11 @@ export async function upsertJobMaterialMakeMethod(body.configuration = jobMaterial.configuration;}+ // Only add parts if it exists+ if (jobMaterial.parts !== undefined) {+ body.parts = jobMaterial.parts;+ }+const { error } = await client.functions.invoke("get-method", {body,region: FunctionRegion.UsEast1@@ -2426,6 +2468,14 @@ export async function upsertMakeMethodFromJob(targetId: string;companyId: string;userId: string;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };}) {return client.functions.invoke("get-method", {@@ -2434,7 +2484,8 @@ export async function upsertMakeMethodFromJob(sourceId: jobMethod.sourceId,targetId: jobMethod.targetId,companyId: jobMethod.companyId,- userId: jobMethod.userId+ userId: jobMethod.userId,+ parts: jobMethod.parts},region: FunctionRegion.UsEast1});@@ -2447,6 +2498,14 @@ export async function upsertMakeMethodFromJobMethod(targetId: string;companyId: string;userId: string;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };}) {const { error } = await client.functions.invoke("get-method", {@@ -2455,7 +2514,8 @@ export async function upsertMakeMethodFromJobMethod(sourceId: jobMethod.sourceId,targetId: jobMethod.targetId,companyId: jobMethod.companyId,- userId: jobMethod.userId+ userId: jobMethod.userId,+ parts: jobMethod.parts},region: FunctionRegion.UsEast1});diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsxindex 23a20f540b..7f5658c031 100644--- a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx+++ b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx@@ -6,6 +6,10 @@ import {Badge,Button,Checkbox,+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+ cn,HStack,Menubar,MenubarItem,@@ -29,6 +33,7 @@ import {import { labelSizes } from "@carbon/utils";import { useEffect, useState } from "react";import {+ LuChevronRight,LuGitBranch,LuGitFork,LuGitMerge,@@ -342,7 +347,7 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {<ModalBody><Tabs defaultValue="item" className="w-full">{isJobMethod && (- <TabsList className="grid w-full grid-cols-2 my-4">+ <TabsList className="grid w-full grid-cols-2 mb-4"><TabsTrigger value="item"><LuSquareStack className="mr-2" /> Item</TabsTrigger>@@ -395,12 +400,16 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {</AlertTitle></Alert>)}+ <AdvancedSection /></VStack></TabsContent><TabsContent value="quote"><Hidden name="type" value="quoteLine" /><Hidden name="targetId" value={jobId} />- <QuoteLineMethodForm />+ <VStack spacing={4}>+ <QuoteLineMethodForm />+ <AdvancedSection />+ </VStack></TabsContent></Tabs></ModalBody>@@ -516,6 +525,7 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {</AlertTitle></Alert>)}+ <AdvancedSection /></VStack></ModalBody><ModalFooter>@@ -601,4 +611,96 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {);};+function AdvancedSection() {+ const [open, setOpen] = useState(false);+ const [billOfProcess, setBillOfProcess] = useState(true);+ const [parameters, setParameters] = useState(true);+ const [tools, setTools] = useState(true);+ const [steps, setSteps] = useState(true);+ const [workInstructions, setWorkInstructions] = useState(true);++ const processChildren = [+ {+ name: "parameters",+ label: "Parameters",+ checked: parameters,+ onChange: setParameters+ },+ { name: "tools", label: "Tools", checked: tools, onChange: setTools },+ { name: "steps", label: "Steps", checked: steps, onChange: setSteps },+ {+ name: "workInstructions",+ label: "Work Instructions",+ checked: workInstructions,+ onChange: setWorkInstructions+ }+ ];++ return (+ <Collapsible className="w-full" open={open} onOpenChange={setOpen}>+ <CollapsibleTrigger asChild>+ <Button variant="ghost" className="w-full justify-start gap-2 px-0">+ <LuChevronRight+ className={cn("h-4 w-4 transition-transform", open && "rotate-90")}+ />+ Advanced+ </Button>+ </CollapsibleTrigger>+ <CollapsibleContent forceMount className={cn(!open && "hidden")}>+ <VStack spacing={2} className="pt-2">+ <div className="flex items-center space-x-2">+ <Checkbox+ id="billOfMaterial"+ name="billOfMaterial"+ defaultChecked+ />+ <label+ htmlFor="billOfMaterial"+ className="text-sm font-medium leading-none"+ >+ Bill of Material+ </label>+ </div>+ <div className="flex items-center space-x-2">+ <Checkbox+ id="billOfProcess"+ name="billOfProcess"+ checked={billOfProcess}+ onCheckedChange={(checked) => setBillOfProcess(!!checked)}+ />+ <label+ htmlFor="billOfProcess"+ className="text-sm font-medium leading-none"+ >+ Bill of Process+ </label>+ </div>+ <VStack spacing={2} className="pl-6">+ {processChildren.map(({ name, label, checked, onChange }) => (+ <div key={name} className="flex items-center space-x-2">+ <Checkbox+ id={name}+ name={name}+ disabled={!billOfProcess}+ checked={billOfProcess ? checked : false}+ onCheckedChange={(val) => onChange(!!val)}+ />+ <label+ htmlFor={name}+ className={cn(+ "text-sm font-medium leading-none",+ !billOfProcess && "text-muted-foreground"+ )}+ >+ {label}+ </label>+ </div>+ ))}+ </VStack>+ </VStack>+ </CollapsibleContent>+ </Collapsible>+ );+}+export default JobMakeMethodTools;diff --git a/apps/erp/app/modules/sales/sales.models.ts b/apps/erp/app/modules/sales/sales.models.tsindex 9fc2d2df2b..c59e2024ca 100644--- a/apps/erp/app/modules/sales/sales.models.ts+++ b/apps/erp/app/modules/sales/sales.models.ts@@ -124,8 +124,14 @@ export const externalQuoteValidator = z.discriminatedUnion("type", [export const getMethodValidator = z.object({type: z.enum(["item", "quoteLine", "method", "quoteToQuote"]),- sourceId: z.string(),- targetId: z.string()+ sourceId: z.string().min(1, { message: "Please select a source method" }),+ targetId: z.string().min(1, { message: "Please select a target method" }),+ billOfMaterial: zfd.checkbox(),+ billOfProcess: zfd.checkbox(),+ parameters: zfd.checkbox(),+ tools: zfd.checkbox(),+ steps: zfd.checkbox(),+ workInstructions: zfd.checkbox()});export const noQuoteReasonValidator = z.object({diff --git a/apps/erp/app/modules/sales/sales.service.ts b/apps/erp/app/modules/sales/sales.service.tsindex 3a16733ba4..c87342b7ef 100644--- a/apps/erp/app/modules/sales/sales.service.ts+++ b/apps/erp/app/modules/sales/sales.service.ts@@ -115,7 +115,15 @@ export async function copyQuoteLine(return client.functions.invoke<{ copiedId: string }>("get-method", {body: {...payload,- type: "quoteLineToQuoteLine"+ type: "quoteLineToQuoteLine",+ parts: {+ billOfMaterial: payload.billOfMaterial,+ billOfProcess: payload.billOfProcess,+ parameters: payload.parameters,+ tools: payload.tools,+ steps: payload.steps,+ workInstructions: payload.workInstructions+ }},region: FunctionRegion.UsEast1});@@ -1963,6 +1971,14 @@ export async function upsertMakeMethodFromQuoteLine(quoteLineId: string;companyId: string;userId: string;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };}) {return client.functions.invoke("get-method", {@@ -1971,7 +1987,8 @@ export async function upsertMakeMethodFromQuoteLine(sourceId: `${lineMethod.quoteId}:${lineMethod.quoteLineId}`,targetId: lineMethod.itemId,companyId: lineMethod.companyId,- userId: lineMethod.userId+ userId: lineMethod.userId,+ parts: lineMethod.parts},region: FunctionRegion.UsEast1});@@ -1984,6 +2001,14 @@ export async function upsertMakeMethodFromQuoteMethod(targetId: string;companyId: string;userId: string;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };}) {const { error } = await client.functions.invoke("get-method", {@@ -1992,7 +2017,8 @@ export async function upsertMakeMethodFromQuoteMethod(sourceId: quoteMethod.sourceId,targetId: quoteMethod.targetId,companyId: quoteMethod.companyId,- userId: quoteMethod.userId+ userId: quoteMethod.userId,+ parts: quoteMethod.parts},region: FunctionRegion.UsEast1});@@ -2306,6 +2332,14 @@ export async function upsertQuoteLineMethod(companyId: string;userId: string;configuration?: Record<string, unknown>;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };}) {const body: {@@ -2315,6 +2349,14 @@ export async function upsertQuoteLineMethod(companyId: string;userId: string;configuration?: Record<string, unknown>;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };} = {type: "itemToQuoteLine",sourceId: lineMethod.itemId,@@ -2328,6 +2370,11 @@ export async function upsertQuoteLineMethod(body.configuration = lineMethod.configuration;}+ // Only add parts if it exists+ if (lineMethod.parts !== undefined) {+ body.parts = lineMethod.parts;+ }+return client.functions.invoke("get-method", {body,region: FunctionRegion.UsEast1@@ -2376,6 +2423,14 @@ export async function upsertQuoteMaterialMakeMethod(companyId: string;userId: string;configuration?: Record<string, unknown>;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };}) {const body: {@@ -2385,6 +2440,14 @@ export async function upsertQuoteMaterialMakeMethod(companyId: string;userId: string;configuration?: Record<string, unknown>;+ parts?: {+ billOfMaterial: boolean;+ billOfProcess: boolean;+ parameters: boolean;+ tools: boolean;+ steps: boolean;+ workInstructions: boolean;+ };} = {type: "itemToQuoteMakeMethod",sourceId: quoteMethod.sourceId,@@ -2398,6 +2461,11 @@ export async function upsertQuoteMaterialMakeMethod(body.configuration = quoteMethod.configuration;}+ // Only add parts if it exists+ if (quoteMethod.parts !== undefined) {+ body.parts = quoteMethod.parts;+ }+const { error } = await client.functions.invoke("get-method", {body,region: FunctionRegion.UsEast1diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsxindex e619b80189..f030a421e8 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx@@ -6,6 +6,10 @@ import {Badge,Button,Checkbox,+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+ cn,HStack,Menubar,MenubarItem,@@ -27,6 +31,7 @@ import {} from "@carbon/react";import { useEffect, useState } from "react";import {+ LuChevronRight,LuGitBranch,LuGitFork,LuGitMerge,@@ -292,7 +297,7 @@ const QuoteMakeMethodTools = () => {<ModalBody>{isQuoteLineMethod ? (<Tabs defaultValue="item" className="w-full">- <TabsList className="grid w-full grid-cols-2 my-4">+ <TabsList className="grid w-full grid-cols-2 mb-4"><TabsTrigger value="item"><LuSquareStack className="mr-2" /> Item</TabsTrigger>@@ -334,6 +339,7 @@ const QuoteMakeMethodTools = () => {</AlertTitle></Alert>)}+ <AdvancedSection /></VStack></TabsContent><TabsContent value="quote">@@ -376,6 +382,7 @@ const QuoteMakeMethodTools = () => {</AlertTitle></Alert>)}+ <AdvancedSection /></VStack></>)}@@ -488,6 +495,7 @@ const QuoteMakeMethodTools = () => {Include Inactive</label></div>+ <AdvancedSection /></VStack></ModalBody><ModalFooter>@@ -568,4 +576,96 @@ const QuoteMakeMethodTools = () => {);};+function AdvancedSection() {+ const [open, setOpen] = useState(false);+ const [billOfProcess, setBillOfProcess] = useState(true);+ const [parameters, setParameters] = useState(true);+ const [tools, setTools] = useState(true);+ const [steps, setSteps] = useState(true);+ const [workInstructions, setWorkInstructions] = useState(true);++ const processChildren = [+ {+ name: "parameters",+ label: "Parameters",+ checked: parameters,+ onChange: setParameters+ },+ { name: "tools", label: "Tools", checked: tools, onChange: setTools },+ { name: "steps", label: "Steps", checked: steps, onChange: setSteps },+ {+ name: "workInstructions",+ label: "Work Instructions",+ checked: workInstructions,+ onChange: setWorkInstructions+ }+ ];++ return (+ <Collapsible className="w-full" open={open} onOpenChange={setOpen}>+ <CollapsibleTrigger asChild>+ <Button variant="ghost" className="w-full justify-start gap-2 px-0">+ <LuChevronRight+ className={cn("h-4 w-4 transition-transform", open && "rotate-90")}+ />+ Advanced+ </Button>+ </CollapsibleTrigger>+ <CollapsibleContent forceMount className={cn(!open && "hidden")}>+ <VStack spacing={2} className="pt-2">+ <div className="flex items-center space-x-2">+ <Checkbox+ id="billOfMaterial"+ name="billOfMaterial"+ defaultChecked+ />+ <label+ htmlFor="billOfMaterial"+ className="text-sm font-medium leading-none"+ >+ Bill of Material+ </label>+ </div>+ <div className="flex items-center space-x-2">+ <Checkbox+ id="billOfProcess"+ name="billOfProcess"+ checked={billOfProcess}+ onCheckedChange={(checked) => setBillOfProcess(!!checked)}+ />+ <label+ htmlFor="billOfProcess"+ className="text-sm font-medium leading-none"+ >+ Bill of Process+ </label>+ </div>+ <VStack spacing={2} className="pl-6">+ {processChildren.map(({ name, label, checked, onChange }) => (+ <div key={name} className="flex items-center space-x-2">+ <Checkbox+ id={name}+ name={name}+ disabled={!billOfProcess}+ checked={billOfProcess ? checked : false}+ onCheckedChange={(val) => onChange(!!val)}+ />+ <label+ htmlFor={name}+ className={cn(+ "text-sm font-medium leading-none",+ !billOfProcess && "text-muted-foreground"+ )}+ >+ {label}+ </label>+ </div>+ ))}+ </VStack>+ </VStack>+ </CollapsibleContent>+ </Collapsible>+ );+}+export default QuoteMakeMethodTools;diff --git a/apps/erp/app/routes/x+/job+/methods+/get.tsx b/apps/erp/app/routes/x+/job+/methods+/get.tsxindex 5818697d8c..441ab2dcfe 100644--- a/apps/erp/app/routes/x+/job+/methods+/get.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/get.tsx@@ -35,7 +35,15 @@ export async function action({ request }: ActionFunctionArgs) {const jobMethodPayload: any = {...validation.data,companyId,- userId+ userId,+ parts: {+ billOfMaterial: validation.data.billOfMaterial,+ billOfProcess: validation.data.billOfProcess,+ parameters: validation.data.parameters,+ tools: validation.data.tools,+ steps: validation.data.steps,+ workInstructions: validation.data.workInstructions+ }};// Only add configuration if it exists@@ -83,7 +91,15 @@ export async function action({ request }: ActionFunctionArgs) {const makeMethodPayload: any = {...validation.data,companyId,- userId+ userId,+ parts: {+ billOfMaterial: validation.data.billOfMaterial,+ billOfProcess: validation.data.billOfProcess,+ parameters: validation.data.parameters,+ tools: validation.data.tools,+ steps: validation.data.steps,+ workInstructions: validation.data.workInstructions+ }};// Only add configuration if it existsdiff --git a/apps/erp/app/routes/x+/job+/methods+/save.tsx b/apps/erp/app/routes/x+/job+/methods+/save.tsxindex d0a592069e..d6e43ca3ad 100644--- a/apps/erp/app/routes/x+/job+/methods+/save.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/save.tsx@@ -29,7 +29,15 @@ export async function action({ request }: ActionFunctionArgs) {const jobMethod = await upsertMakeMethodFromJob(serviceRole, {...validation.data,companyId,- userId+ userId,+ parts: {+ billOfMaterial: validation.data.billOfMaterial,+ billOfProcess: validation.data.billOfProcess,+ parameters: validation.data.parameters,+ tools: validation.data.tools,+ steps: validation.data.steps,+ workInstructions: validation.data.workInstructions+ }});return {@@ -41,7 +49,15 @@ export async function action({ request }: ActionFunctionArgs) {const makeMethod = await upsertMakeMethodFromJobMethod(serviceRole, {...validation.data,companyId,- userId+ userId,+ parts: {+ billOfMaterial: validation.data.billOfMaterial,+ billOfProcess: validation.data.billOfProcess,+ parameters: validation.data.parameters,+ tools: validation.data.tools,+ steps: validation.data.steps,+ workInstructions: validation.data.workInstructions+ }});if (makeMethod.error) {diff --git a/apps/erp/app/routes/x+/part+/$itemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.tsxindex 9480ae9d11..6ba8c95ab7 100644--- a/apps/erp/app/routes/x+/part+/$itemId.tsx+++ b/apps/erp/app/routes/x+/part+/$itemId.tsx@@ -6,7 +6,11 @@ import {Input,InputGroup,InputLeftElement,- Spinner+ Spinner,+ Tabs,+ TabsContent,+ TabsList,+ TabsTrigger} from "@carbon/react";import { useRouteData } from "@carbon/remix";import { Suspense, useState } from "react";@@ -145,192 +149,353 @@ export default function PartRoute() {<ResizablePanelsexplorer={<div className="flex flex-col h-full">- <HStack className="w-full justify-between flex-shrink-0 p-2 pb-0">- <InputGroup size="sm" className="flex flex-grow">- <InputLeftElement>- <LuSearch className="h-4 w-4" />- </InputLeftElement>- <Input- placeholder="Search..."- value={filterText}- onChange={(e) => setFilterText(e.target.value)}- />- </InputGroup>- {isManufactured && (- <Suspense fallback={null}>- <Await resolve={methodTree}>- {(resolved) =>- resolved ? (- <BoMActions makeMethodId={resolved.makeMethod.id} />- ) : null- }- </Await>- </Suspense>- )}- </HStack>- <div className="flex-1 overflow-y-auto">- {isManufactured && (- <>- <h4 className="text-xxs text-foreground/70 uppercase font-light tracking-wide px-4 pt-2">- Manufacturing- </h4>- <Suspense- fallback={- <div className="flex w-full items-center justify-center p-4">- <Spinner className="h-6 w-6" />- </div>- }- >+ {isManufactured ? (+ <Tabs+ defaultValue="manufacturing"+ className="flex flex-col h-full"+ >+ <div className="px-2 pt-2 flex-shrink-0">+ <TabsList className="grid grid-cols-2 w-full rounded-md">+ <TabsTrigger+ value="manufacturing"+ className="rounded-md"+ >+ Manufacturing+ </TabsTrigger>+ <TabsTrigger value="used-in" className="rounded-md">+ Used In+ </TabsTrigger>+ </TabsList>+ </div>+ <HStack className="w-full justify-between flex-shrink-0 p-2 pb-0">+ <InputGroup size="sm" className="flex flex-grow">+ <InputLeftElement>+ <LuSearch className="h-4 w-4" />+ </InputLeftElement>+ <Input+ placeholder="Search..."+ value={filterText}+ onChange={(e) => setFilterText(e.target.value)}+ />+ </InputGroup>+ <Suspense fallback={null}><Await resolve={methodTree}>{(resolved) =>resolved ? (- <div className="w-full p-2">- <BoMExplorer- itemType="Part"- makeMethod={resolved.makeMethod}- // @ts-ignore- methods={resolved.methods}- methodId={resolved.makeMethod.id}- filterText={filterText}- hideSearch- />- </div>+ <BoMActions+ makeMethodId={resolved.makeMethod.id}+ />) : null}</Await></Suspense>- </>- )}- <h4 className="text-xxs text-foreground/70 uppercase font-light tracking-wide px-4 pt-2">- Used In- </h4>- <Suspense fallback={<UsedInSkeleton />}>- <Await resolve={usedIn}>- {(resolvedUsedIn) => {- const {- issues,- jobMaterials,- jobs,- maintenanceDispatchItems,- methodMaterials,- purchaseOrderLines,- receiptLines,- quoteLines,- quoteMaterials,- salesOrderLines,- shipmentLines,- supplierQuotes- } = resolvedUsedIn;-- const tree: UsedInNode[] = [- {- key: "issues",- name: "Issues",- module: "quality",- children: issues- },- {- key: "jobs",- name: "Jobs",- module: "production",- children: jobs.map((job) => ({- ...job,- methodType: "Make"- }))- },- {- key: "jobMaterials",- name: "Job Materials",- module: "production",- children: jobMaterials- },- {- key: "maintenanceDispatchItems",- name: "Maintenance",- module: "resources",- children: maintenanceDispatchItems- },- {- key: "methodMaterials",- name: "Method Materials",- module: "parts",- // @ts-expect-error- children: methodMaterials- },- {- key: "purchaseOrderLines",- name: "Purchase Orders",- module: "purchasing",- children: purchaseOrderLines.map((po) => ({- ...po,- methodType: "Buy"- }))- },- {- key: "receiptLines",- name: "Receipts",- module: "inventory",- children: receiptLines.map((receipt) => ({- ...receipt,- methodType: "Pick"- }))- },- {- key: "quoteLines",- name: "Quotes",- module: "sales",- children: quoteLines- },- {- key: "quoteMaterials",- name: "Quote Materials",- module: "sales",- children: quoteMaterials?.map((qm) => ({- ...qm,- documentReadableId: qm.documentReadableId ?? ""- }))- },- {- key: "salesOrderLines",- name: "Sales Orders",- module: "sales",- children: salesOrderLines- },- {- key: "shipmentLines",- name: "Shipments",- module: "inventory",- children: shipmentLines.map((shipment) => ({- ...shipment,- methodType: "Shipment"- }))- },- {- key: "supplierQuotes",- name: "Supplier Quotes",- module: "purchasing",- children: supplierQuotes+ </HStack>+ <div className="flex-1 overflow-y-auto">+ <TabsContent value="manufacturing">+ <Suspense+ fallback={+ <div className="flex w-full items-center justify-center p-4">+ <Spinner className="h-6 w-6" />+ </div>}- ];-- return (- <UsedInTree- tree={tree}- revisions={partData.partSummary?.revisions}- itemReadableId={- partData.partSummary?.readableId ?? ""- }- itemReadableIdWithRevision={- partData.partSummary?.readableIdWithRevision ?? ""+ >+ <Await resolve={methodTree}>+ {(resolved) =>+ resolved ? (+ <div className="w-full p-2">+ <BoMExplorer+ itemType="Part"+ makeMethod={resolved.makeMethod}+ // @ts-ignore+ methods={resolved.methods}+ methodId={resolved.makeMethod.id}+ filterText={filterText}+ hideSearch+ />+ </div>+ ) : null}- filterText={filterText}- hideSearch- />- );- }}- </Await>- </Suspense>- </div>+ </Await>+ </Suspense>+ </TabsContent>+ <TabsContent value="used-in">+ <Suspense fallback={<UsedInSkeleton />}>+ <Await resolve={usedIn}>+ {(resolvedUsedIn) => {+ const {+ issues,+ jobMaterials,+ jobs,+ maintenanceDispatchItems,+ methodMaterials,+ purchaseOrderLines,+ receiptLines,+ quoteLines,+ quoteMaterials,+ salesOrderLines,+ shipmentLines,+ supplierQuotes+ } = resolvedUsedIn;++ const tree: UsedInNode[] = [+ {+ key: "issues",+ name: "Issues",+ module: "quality",+ children: issues+ },+ {+ key: "jobs",+ name: "Jobs",+ module: "production",+ children: jobs.map((job) => ({+ ...job,+ methodType: "Make"+ }))+ },+ {+ key: "jobMaterials",+ name: "Job Materials",+ module: "production",+ children: jobMaterials+ },+ {+ key: "maintenanceDispatchItems",+ name: "Maintenance",+ module: "resources",+ children: maintenanceDispatchItems+ },+ {+ key: "methodMaterials",+ name: "Method Materials",+ module: "parts",+ // @ts-expect-error+ children: methodMaterials+ },+ {+ key: "purchaseOrderLines",+ name: "Purchase Orders",+ module: "purchasing",+ children: purchaseOrderLines.map((po) => ({+ ...po,+ methodType: "Buy"+ }))+ },+ {+ key: "receiptLines",+ name: "Receipts",+ module: "inventory",+ children: receiptLines.map((receipt) => ({+ ...receipt,+ methodType: "Pick"+ }))+ },+ {+ key: "quoteLines",+ name: "Quotes",+ module: "sales",+ children: quoteLines+ },+ {+ key: "quoteMaterials",+ name: "Quote Materials",+ module: "sales",+ children: quoteMaterials?.map((qm) => ({+ ...qm,+ documentReadableId:+ qm.documentReadableId ?? ""+ }))+ },+ {+ key: "salesOrderLines",+ name: "Sales Orders",+ module: "sales",+ children: salesOrderLines+ },+ {+ key: "shipmentLines",+ name: "Shipments",+ module: "inventory",+ children: shipmentLines.map((shipment) => ({+ ...shipment,+ methodType: "Shipment"+ }))+ },+ {+ key: "supplierQuotes",+ name: "Supplier Quotes",+ module: "purchasing",+ children: supplierQuotes+ }+ ];++ return (+ <UsedInTree+ tree={tree}+ revisions={partData.partSummary?.revisions}+ itemReadableId={+ partData.partSummary?.readableId ?? ""+ }+ itemReadableIdWithRevision={+ partData.partSummary+ ?.readableIdWithRevision ?? ""+ }+ filterText={filterText}+ hideSearch+ />+ );+ }}+ </Await>+ </Suspense>+ </TabsContent>+ </div>+ </Tabs>+ ) : (+ <>+ <HStack className="w-full justify-between flex-shrink-0 p-2 pb-0">+ <InputGroup size="sm" className="flex flex-grow">+ <InputLeftElement>+ <LuSearch className="h-4 w-4" />+ </InputLeftElement>+ <Input+ placeholder="Search..."+ value={filterText}+ onChange={(e) => setFilterText(e.target.value)}+ />+ </InputGroup>+ </HStack>+ <div className="flex-1 overflow-y-auto">+ <Suspense fallback={<UsedInSkeleton />}>+ <Await resolve={usedIn}>+ {(resolvedUsedIn) => {+ const {+ issues,+ jobMaterials,+ jobs,+ maintenanceDispatchItems,+ methodMaterials,+ purchaseOrderLines,+ receiptLines,+ quoteLines,+ quoteMaterials,+ salesOrderLines,+ shipmentLines,+ supplierQuotes+ } = resolvedUsedIn;++ const tree: UsedInNode[] = [+ {+ key: "issues",+ name: "Issues",+ module: "quality",+ children: issues+ },+ {+ key: "jobs",+ name: "Jobs",+ module: "production",+ children: jobs.map((job) => ({+ ...job,+ methodType: "Make"+ }))+ },+ {+ key: "jobMaterials",+ name: "Job Materials",+ module: "production",+ children: jobMaterials+ },+ {+ key: "maintenanceDispatchItems",+ name: "Maintenance",+ module: "resources",+ children: maintenanceDispatchItems+ },+ {+ key: "methodMaterials",+ name: "Method Materials",+ module: "parts",+ // @ts-expect-error+ children: methodMaterials+ },+ {+ key: "purchaseOrderLines",+ name: "Purchase Orders",+ module: "purchasing",+ children: purchaseOrderLines.map((po) => ({+ ...po,+ methodType: "Buy"+ }))+ },+ {+ key: "receiptLines",+ name: "Receipts",+ module: "inventory",+ children: receiptLines.map((receipt) => ({+ ...receipt,+ methodType: "Pick"+ }))+ },+ {+ key: "quoteLines",+ name: "Quotes",+ module: "sales",+ children: quoteLines+ },+ {+ key: "quoteMaterials",+ name: "Quote Materials",+ module: "sales",+ children: quoteMaterials?.map((qm) => ({+ ...qm,+ documentReadableId:+ qm.documentReadableId ?? ""+ }))+ },+ {+ key: "salesOrderLines",+ name: "Sales Orders",+ module: "sales",+ children: salesOrderLines+ },+ {+ key: "shipmentLines",+ name: "Shipments",+ module: "inventory",+ children: shipmentLines.map((shipment) => ({+ ...shipment,+ methodType: "Shipment"+ }))+ },+ {+ key: "supplierQuotes",+ name: "Supplier Quotes",+ module: "purchasing",+ children: supplierQuotes+ }+ ];++ return (+ <UsedInTree+ tree={tree}+ revisions={partData.partSummary?.revisions}+ itemReadableId={+ partData.partSummary?.readableId ?? ""+ }+ itemReadableIdWithRevision={+ partData.partSummary+ ?.readableIdWithRevision ?? ""+ }+ filterText={filterText}+ hideSearch+ />+ );+ }}+ </Await>+ </Suspense>+ </div>+ </>+ )}</div>}content={diff --git a/apps/erp/app/routes/x+/quote+/methods+/get.tsx b/apps/erp/app/routes/x+/quote+/methods+/get.tsxindex d3c7992c5f..a8418dc599 100644--- a/apps/erp/app/routes/x+/quote+/methods+/get.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/get.tsx@@ -38,7 +38,15 @@ export async function action({ request }: ActionFunctionArgs) {quoteId,quoteLineId,companyId,- userId+ userId,+ parts: {+ billOfMaterial: validation.data.billOfMaterial,+ billOfProcess: validation.data.billOfProcess,+ parameters: validation.data.parameters,+ tools: validation.data.tools,+ steps: validation.data.steps,+ workInstructions: validation.data.workInstructions+ }};// Only add configuration if it exists@@ -82,7 +90,15 @@ export async function action({ request }: ActionFunctionArgs) {const makeMethodPayload: any = {...validation.data,companyId,- userId+ userId,+ parts: {+ billOfMaterial: validation.data.billOfMaterial,+ billOfProcess: validation.data.billOfProcess,+ parameters: validation.data.parameters,+ tools: validation.data.tools,+ steps: validation.data.steps,+ workInstructions: validation.data.workInstructions+ }};// Only add configuration if it existsdiff --git a/apps/erp/app/routes/x+/quote+/methods+/save.tsx b/apps/erp/app/routes/x+/quote+/methods+/save.tsxindex e5adb6ba43..39a66a9887 100644--- a/apps/erp/app/routes/x+/quote+/methods+/save.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/save.tsx@@ -34,7 +34,15 @@ export async function action({ request }: ActionFunctionArgs) {quoteLineId,itemId,companyId,- userId+ userId,+ parts: {+ billOfMaterial: validation.data.billOfMaterial,+ billOfProcess: validation.data.billOfProcess,+ parameters: validation.data.parameters,+ tools: validation.data.tools,+ steps: validation.data.steps,+ workInstructions: validation.data.workInstructions+ }});return {@@ -53,7 +61,15 @@ export async function action({ request }: ActionFunctionArgs) {const makeMethod = await upsertMakeMethodFromQuoteMethod(serviceRole, {...validation.data,companyId,- userId+ userId,+ parts: {+ billOfMaterial: validation.data.billOfMaterial,+ billOfProcess: validation.data.billOfProcess,+ parameters: validation.data.parameters,+ tools: validation.data.tools,+ steps: validation.data.steps,+ workInstructions: validation.data.workInstructions+ }});if (makeMethod.error) {diff --git a/apps/erp/app/routes/x+/tool+/$itemId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.tsxindex dc18d25d1a..835a943321 100644--- a/apps/erp/app/routes/x+/tool+/$itemId.tsx+++ b/apps/erp/app/routes/x+/tool+/$itemId.tsx@@ -6,7 +6,11 @@ import {Input,InputGroup,InputLeftElement,- Spinner+ Spinner,+ Tabs,+ TabsContent,+ TabsList,+ TabsTrigger} from "@carbon/react";import { useRouteData } from "@carbon/remix";import { Suspense, useState } from "react";@@ -141,192 +145,353 @@ export default function ToolRoute() {<ResizablePanelsexplorer={<div className="flex flex-col h-full">- <HStack className="w-full justify-between flex-shrink-0 p-2 pb-0">- <InputGroup size="sm" className="flex flex-grow">- <InputLeftElement>- <LuSearch className="h-4 w-4" />- </InputLeftElement>- <Input- placeholder="Search..."- value={filterText}- onChange={(e) => setFilterText(e.target.value)}- />- </InputGroup>- {isManufactured && (- <Suspense fallback={null}>- <Await resolve={methodTree}>- {(resolved) =>- resolved ? (- <BoMActions makeMethodId={resolved.makeMethod.id} />- ) : null- }- </Await>- </Suspense>- )}- </HStack>- <div className="flex-1 overflow-y-auto">- {isManufactured && (- <>- <h4 className="text-xxs text-foreground/70 uppercase font-light tracking-wide px-4 pt-2">- Manufacturing- </h4>- <Suspense- fallback={- <div className="flex w-full items-center justify-center p-4">- <Spinner className="h-6 w-6" />- </div>- }- >+ {isManufactured ? (+ <Tabs+ defaultValue="manufacturing"+ className="flex flex-col h-full"+ >+ <div className="px-2 pt-2 flex-shrink-0">+ <TabsList className="grid grid-cols-2 w-full rounded-md">+ <TabsTrigger+ value="manufacturing"+ className="rounded-md"+ >+ Manufacturing+ </TabsTrigger>+ <TabsTrigger value="used-in" className="rounded-md">+ Used In+ </TabsTrigger>+ </TabsList>+ </div>+ <HStack className="w-full justify-between flex-shrink-0 p-2 pb-0">+ <InputGroup size="sm" className="flex flex-grow">+ <InputLeftElement>+ <LuSearch className="h-4 w-4" />+ </InputLeftElement>+ <Input+ placeholder="Search..."+ value={filterText}+ onChange={(e) => setFilterText(e.target.value)}+ />+ </InputGroup>+ <Suspense fallback={null}><Await resolve={methodTree}>{(resolved) =>resolved ? (- <div className="w-full p-2">- <BoMExplorer- itemType="Tool"- makeMethod={resolved.makeMethod}- // @ts-ignore- methods={resolved.methods}- methodId={resolved.makeMethod.id}- filterText={filterText}- hideSearch- />- </div>+ <BoMActions+ makeMethodId={resolved.makeMethod.id}+ />) : null}</Await></Suspense>- </>- )}- <h4 className="text-xxs text-foreground/70 uppercase font-light tracking-wide px-4 pt-2">- Used In- </h4>- <Suspense fallback={<UsedInSkeleton />}>- <Await resolve={usedIn}>- {(resolvedUsedIn) => {- const {- issues,- jobMaterials,- jobs,- maintenanceDispatchItems,- methodMaterials,- purchaseOrderLines,- receiptLines,- quoteLines,- quoteMaterials,- salesOrderLines,- shipmentLines,- supplierQuotes- } = resolvedUsedIn;-- const tree: UsedInNode[] = [- {- key: "issues",- name: "Issues",- module: "quality",- children: issues- },- {- key: "jobs",- name: "Jobs",- module: "production",- children: jobs.map((job) => ({- ...job,- methodType: "Make"- }))- },- {- key: "jobMaterials",- name: "Job Materials",- module: "production",- children: jobMaterials- },- {- key: "maintenanceDispatchItems",- name: "Maintenance",- module: "resources",- children: maintenanceDispatchItems- },- {- key: "methodMaterials",- name: "Method Materials",- module: "parts",- // @ts-expect-error- children: methodMaterials- },- {- key: "purchaseOrderLines",- name: "Purchase Orders",- module: "purchasing",- children: purchaseOrderLines.map((po) => ({- ...po,- methodType: "Buy"- }))- },- {- key: "receiptLines",- name: "Receipts",- module: "inventory",- children: receiptLines.map((receipt) => ({- ...receipt,- methodType: "Pick"- }))- },- {- key: "quoteLines",- name: "Quotes",- module: "sales",- children: quoteLines- },- {- key: "quoteMaterials",- name: "Quote Materials",- module: "sales",- children: quoteMaterials?.map((qm) => ({- ...qm,- documentReadableId: qm.documentReadableId ?? ""- }))- },- {- key: "salesOrderLines",- name: "Sales Orders",- module: "sales",- children: salesOrderLines- },- {- key: "shipmentLines",- name: "Shipments",- module: "inventory",- children: shipmentLines.map((shipment) => ({- ...shipment,- methodType: "Shipment"- }))- },- {- key: "supplierQuotes",- name: "Supplier Quotes",- module: "purchasing",- children: supplierQuotes+ </HStack>+ <div className="flex-1 overflow-y-auto">+ <TabsContent value="manufacturing">+ <Suspense+ fallback={+ <div className="flex w-full items-center justify-center p-4">+ <Spinner className="h-6 w-6" />+ </div>}- ];-- return (- <UsedInTree- tree={tree}- revisions={toolData.toolSummary?.revisions}- itemReadableId={- toolData.toolSummary?.readableId ?? ""- }- itemReadableIdWithRevision={- toolData.toolSummary?.readableIdWithRevision ?? ""+ >+ <Await resolve={methodTree}>+ {(resolved) =>+ resolved ? (+ <div className="w-full p-2">+ <BoMExplorer+ itemType="Tool"+ makeMethod={resolved.makeMethod}+ // @ts-ignore+ methods={resolved.methods}+ methodId={resolved.makeMethod.id}+ filterText={filterText}+ hideSearch+ />+ </div>+ ) : null}- filterText={filterText}- hideSearch- />- );- }}- </Await>- </Suspense>- </div>+ </Await>+ </Suspense>+ </TabsContent>+ <TabsContent value="used-in">+ <Suspense fallback={<UsedInSkeleton />}>+ <Await resolve={usedIn}>+ {(resolvedUsedIn) => {+ const {+ issues,+ jobMaterials,+ jobs,+ maintenanceDispatchItems,+ methodMaterials,+ purchaseOrderLines,+ receiptLines,+ quoteLines,+ quoteMaterials,+ salesOrderLines,+ shipmentLines,+ supplierQuotes+ } = resolvedUsedIn;++ const tree: UsedInNode[] = [+ {+ key: "issues",+ name: "Issues",+ module: "quality",+ children: issues+ },+ {+ key: "jobs",+ name: "Jobs",+ module: "production",+ children: jobs.map((job) => ({+ ...job,+ methodType: "Make"+ }))+ },+ {+ key: "jobMaterials",+ name: "Job Materials",+ module: "production",+ children: jobMaterials+ },+ {+ key: "maintenanceDispatchItems",+ name: "Maintenance",+ module: "resources",+ children: maintenanceDispatchItems+ },+ {+ key: "methodMaterials",+ name: "Method Materials",+ module: "parts",+ // @ts-expect-error+ children: methodMaterials+ },+ {+ key: "purchaseOrderLines",+ name: "Purchase Orders",+ module: "purchasing",+ children: purchaseOrderLines.map((po) => ({+ ...po,+ methodType: "Buy"+ }))+ },+ {+ key: "receiptLines",+ name: "Receipts",+ module: "inventory",+ children: receiptLines.map((receipt) => ({+ ...receipt,+ methodType: "Pick"+ }))+ },+ {+ key: "quoteLines",+ name: "Quotes",+ module: "sales",+ children: quoteLines+ },+ {+ key: "quoteMaterials",+ name: "Quote Materials",+ module: "sales",+ children: quoteMaterials?.map((qm) => ({+ ...qm,+ documentReadableId:+ qm.documentReadableId ?? ""+ }))+ },+ {+ key: "salesOrderLines",+ name: "Sales Orders",+ module: "sales",+ children: salesOrderLines+ },+ {+ key: "shipmentLines",+ name: "Shipments",+ module: "inventory",+ children: shipmentLines.map((shipment) => ({+ ...shipment,+ methodType: "Shipment"+ }))+ },+ {+ key: "supplierQuotes",+ name: "Supplier Quotes",+ module: "purchasing",+ children: supplierQuotes+ }+ ];++ return (+ <UsedInTree+ tree={tree}+ revisions={toolData.toolSummary?.revisions}+ itemReadableId={+ toolData.toolSummary?.readableId ?? ""+ }+ itemReadableIdWithRevision={+ toolData.toolSummary+ ?.readableIdWithRevision ?? ""+ }+ filterText={filterText}+ hideSearch+ />+ );+ }}+ </Await>+ </Suspense>+ </TabsContent>+ </div>+ </Tabs>+ ) : (+ <>+ <HStack className="w-full justify-between flex-shrink-0 p-2 pb-0">+ <InputGroup size="sm" className="flex flex-grow">+ <InputLeftElement>+ <LuSearch className="h-4 w-4" />+ </InputLeftElement>+ <Input+ placeholder="Search..."+ value={filterText}+ onChange={(e) => setFilterText(e.target.value)}+ />+ </InputGroup>+ </HStack>+ <div className="flex-1 overflow-y-auto">+ <Suspense fallback={<UsedInSkeleton />}>+ <Await resolve={usedIn}>+ {(resolvedUsedIn) => {+ const {+ issues,+ jobMaterials,+ jobs,+ maintenanceDispatchItems,+ methodMaterials,+ purchaseOrderLines,+ receiptLines,+ quoteLines,+ quoteMaterials,+ salesOrderLines,+ shipmentLines,+ supplierQuotes+ } = resolvedUsedIn;++ const tree: UsedInNode[] = [+ {+ key: "issues",+ name: "Issues",+ module: "quality",+ children: issues+ },+ {+ key: "jobs",+ name: "Jobs",+ module: "production",+ children: jobs.map((job) => ({+ ...job,+ methodType: "Make"+ }))+ },+ {+ key: "jobMaterials",+ name: "Job Materials",+ module: "production",+ children: jobMaterials+ },+ {+ key: "maintenanceDispatchItems",+ name: "Maintenance",+ module: "resources",+ children: maintenanceDispatchItems+ },+ {+ key: "methodMaterials",+ name: "Method Materials",+ module: "parts",+ // @ts-expect-error+ children: methodMaterials+ },+ {+ key: "purchaseOrderLines",+ name: "Purchase Orders",+ module: "purchasing",+ children: purchaseOrderLines.map((po) => ({+ ...po,+ methodType: "Buy"+ }))+ },+ {+ key: "receiptLines",+ name: "Receipts",+ module: "inventory",+ children: receiptLines.map((receipt) => ({+ ...receipt,+ methodType: "Pick"+ }))+ },+ {+ key: "quoteLines",+ name: "Quotes",+ module: "sales",+ children: quoteLines+ },+ {+ key: "quoteMaterials",+ name: "Quote Materials",+ module: "sales",+ children: quoteMaterials?.map((qm) => ({+ ...qm,+ documentReadableId:+ qm.documentReadableId ?? ""+ }))+ },+ {+ key: "salesOrderLines",+ name: "Sales Orders",+ module: "sales",+ children: salesOrderLines+ },+ {+ key: "shipmentLines",+ name: "Shipments",+ module: "inventory",+ children: shipmentLines.map((shipment) => ({+ ...shipment,+ methodType: "Shipment"+ }))+ },+ {+ key: "supplierQuotes",+ name: "Supplier Quotes",+ module: "purchasing",+ children: supplierQuotes+ }+ ];++ return (+ <UsedInTree+ tree={tree}+ revisions={toolData.toolSummary?.revisions}+ itemReadableId={+ toolData.toolSummary?.readableId ?? ""+ }+ itemReadableIdWithRevision={+ toolData.toolSummary+ ?.readableIdWithRevision ?? ""+ }+ filterText={filterText}+ hideSearch+ />+ );+ }}+ </Await>+ </Suspense>+ </div>+ </>+ )}</div>}content={diff --git a/apps/mes/app/components/JobOperation/JobOperation.tsx b/apps/mes/app/components/JobOperation/JobOperation.tsxindex a60ae6d3ef..0e42e15f8e 100644--- a/apps/mes/app/components/JobOperation/JobOperation.tsx+++ b/apps/mes/app/components/JobOperation/JobOperation.tsx@@ -646,37 +646,32 @@ export const JobOperation = ({/></CardHeader><CardContent>- <Heading size="h1">- {operation.jobDueDate- ? formatDate(operation.jobDueDate)- : null}- <VStack className="justify-start" spacing={0}>- <Heading- size="h3"- className={cn(- "w-full truncate",- isOverdue ? "text-red-500" : ""- )}- >- {["ASAP", "No Deadline"].includes(- operation.jobDeadlineType- )- ? operation.jobDeadlineType- : operation.jobDueDate- ? `Due ${formatRelativeTime(- convertDateStringToIsoString(- operation.jobDueDate- )- )}`- : "–"}- </Heading>- <span className="text-muted-foreground text-sm">- {operation.jobDueDate- ? formatDate(operation.jobDueDate)- : null}- </span>- </VStack>- </Heading>+ <VStack className="justify-start" spacing={0}>+ <Heading+ size="h3"+ className={cn(+ "w-full truncate",+ isOverdue ? "text-red-500" : ""+ )}+ >+ {["ASAP", "No Deadline"].includes(+ operation.jobDeadlineType+ )+ ? operation.jobDeadlineType+ : operation.jobDueDate+ ? `Due ${formatRelativeTime(+ convertDateStringToIsoString(+ operation.jobDueDate+ )+ )}`+ : "–"}+ </Heading>+ <span className="text-muted-foreground text-sm">+ {operation.jobDueDate+ ? formatDate(operation.jobDueDate)+ : null}+ </span>+ </VStack></CardContent></Card></div>diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.tsindex 6170047ae2..6be5a7a65d 100644--- a/packages/database/supabase/functions/get-method/index.ts+++ b/packages/database/supabase/functions/get-method/index.ts@@ -397,17 +397,23 @@ serve(async (req: Request) => {await db.transaction().execute(async (trx) => {// Delete existing jobMakeMethod, jobMakeMethodOperation, jobMakeMethodMaterialawait Promise.all([- trx- .deleteFrom("jobMakeMethod")- .where((eb) =>- eb.and([- eb("jobId", "=", jobId),- eb("parentMaterialId", "is not", null),- ])- )- .execute(),- trx.deleteFrom("jobMaterial").where("jobId", "=", jobId).execute(),- trx.deleteFrom("jobOperation").where("jobId", "=", jobId).execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("jobMakeMethod")+ .where((eb) =>+ eb.and([+ eb("jobId", "=", jobId),+ eb("parentMaterialId", "is not", null),+ ])+ )+ .execute()+ : Promise.resolve(),+ parts.billOfMaterial+ ? trx.deleteFrom("jobMaterial").where("jobId", "=", jobId).execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx.deleteFrom("jobOperation").where("jobId", "=", jobId).execute()+ : Promise.resolve(),trx.updateTable("jobMakeMethod").set({ version: makeMethod.data.version ?? 1 })@@ -489,6 +495,9 @@ serve(async (req: Request) => {node.data.materialMakeMethodId}:${node.data.isRoot ? "undefined" : node.data.methodMaterialId}`;+ let methodOperationsToJobOperations: Record<string, string> = {};++ if (parts.billOfProcess) {const relatedOperations = await client.from("methodOperation").select(@@ -597,7 +606,7 @@ serve(async (req: Request) => {processId,op.operationSupplierProcessId),- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},targetQuantity,operationQuantity,companyId,@@ -633,7 +642,6 @@ serve(async (req: Request) => {.filter(Boolean);}- let methodOperationsToJobOperations: Record<string, string> = {};if (jobOperationsInserts?.length > 0) {const operationIds = await trx.insertInto("jobOperation")@@ -655,6 +663,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(methodOperationTool) &&methodOperationTool.length > 0) {@@ -681,6 +690,7 @@ serve(async (req: Request) => {});} else {if (+ parts.parameters &&Array.isArray(methodOperationParameter) &&methodOperationParameter.length > 0) {@@ -705,6 +715,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(methodOperationStep) &&methodOperationStep.length > 0) {@@ -749,7 +760,9 @@ serve(async (req: Request) => {{}) ?? {};}+ } // end if (parts.billOfProcess)+ if (parts.billOfMaterial) {const locationId = job.data?.locationId;const mapMethodMaterialToJobMaterial = async (@@ -980,6 +993,7 @@ serve(async (req: Request) => {.values(pickedOrBoughtMaterials).execute();}+ } // end if (parts.billOfMaterial)}// Start traversal with job quantity as the root's target/parent estimated quantity@@ -1100,14 +1114,18 @@ serve(async (req: Request) => {await db.transaction().execute(async (trx: Transaction) => {// Delete existing jobMakeMethodOperation, jobMakeMethodMaterialawait Promise.all([- trx- .deleteFrom("jobMaterial")- .where("jobMakeMethodId", "=", jobMakeMethodId)- .execute(),- trx- .deleteFrom("jobOperation")- .where("jobMakeMethodId", "=", jobMakeMethodId)- .execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("jobMaterial")+ .where("jobMakeMethodId", "=", jobMakeMethodId)+ .execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx+ .deleteFrom("jobOperation")+ .where("jobMakeMethodId", "=", jobMakeMethodId)+ .execute()+ : Promise.resolve(),trx.updateTable("jobMakeMethod").set({ version: makeMethod.data.version ?? 1 })@@ -1181,7 +1199,7 @@ serve(async (req: Request) => {op.operationSupplierProcessId),tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},targetQuantity,operationQuantity,companyId,@@ -1190,6 +1208,8 @@ serve(async (req: Request) => {})) ?? [];let methodOperationsToJobOperations: Record<string, string> = {};++ if (parts.billOfProcess) {if (jobOperationsInserts?.length > 0) {const operationIds = await trx.insertInto("jobOperation")@@ -1211,6 +1231,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(methodOperationTool) &&methodOperationTool.length > 0) {@@ -1237,6 +1258,7 @@ serve(async (req: Request) => {});} else {if (+ parts.parameters &&Array.isArray(methodOperationParameter) &&methodOperationParameter.length > 0) {@@ -1255,6 +1277,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(methodOperationStep) &&methodOperationStep.length > 0) {@@ -1287,7 +1310,9 @@ serve(async (req: Request) => {{}) ?? {};}+ } // end if (parts.billOfProcess)+ if (parts.billOfMaterial) {const mapMethodMaterialToJobMaterial = async (child: MethodTreeItem) => {@@ -1421,6 +1446,7 @@ serve(async (req: Request) => {.values(pickedOrBoughtMaterials).execute();}+ } // end if (parts.billOfMaterial)}// Start traversal with the parent's estimated quantity@@ -1527,23 +1553,29 @@ serve(async (req: Request) => {await db.transaction().execute(async (trx: Transaction<KyselyDatabase>) => {// Delete existing quoteMakeMethod, quoteMakeMethodOperation, quoteMakeMethodMaterialawait Promise.all([- trx- .deleteFrom("quoteMakeMethod")- .where((eb) =>- eb.and([- eb("quoteLineId", "=", quoteLineId),- eb("parentMaterialId", "is not", null),- ])- )- .execute(),- trx- .deleteFrom("quoteMaterial")- .where("quoteLineId", "=", quoteLineId)- .execute(),- trx- .deleteFrom("quoteOperation")- .where("quoteLineId", "=", quoteLineId)- .execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("quoteMakeMethod")+ .where((eb) =>+ eb.and([+ eb("quoteLineId", "=", quoteLineId),+ eb("parentMaterialId", "is not", null),+ ])+ )+ .execute()+ : Promise.resolve(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("quoteMaterial")+ .where("quoteLineId", "=", quoteLineId)+ .execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx+ .deleteFrom("quoteOperation")+ .where("quoteLineId", "=", quoteLineId)+ .execute()+ : Promise.resolve(),trx.updateTable("quoteMakeMethod").set({ version: makeMethod.data.version ?? 1 })@@ -1590,6 +1622,13 @@ serve(async (req: Request) => {node: MethodTreeItem,parentQuoteMakeMethodId: string | null) {+ let methodOperationsToQuoteOperations: Record<string, string> = {};++ const nodeLevelConfigurationKey = `${+ node.data.materialMakeMethodId+ }:${node.data.isRoot ? "undefined" : node.data.methodMaterialId}`;++ if (parts.billOfProcess) {const relatedOperations = await client.from("methodOperation").select(@@ -1710,17 +1749,13 @@ serve(async (req: Request) => {op.operationSupplierProcessId),tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},companyId,createdBy: userId,customFields: {},});}- const nodeLevelConfigurationKey = `${- node.data.materialMakeMethodId- }:${node.data.isRoot ? "undefined" : node.data.methodMaterialId}`;-const bopConfigurationKey = `billOfProcess:${nodeLevelConfigurationKey}`;let bopConfiguration: string[] | null = null;@@ -1748,7 +1783,6 @@ serve(async (req: Request) => {.filter(Boolean);}- let methodOperationsToQuoteOperations: Record<string, string> = {};if (quoteOperationsInserts?.length > 0) {const operationIds = await trx.insertInto("quoteOperation")@@ -1770,6 +1804,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(methodOperationTool) &&methodOperationTool.length > 0) {@@ -1789,6 +1824,7 @@ serve(async (req: Request) => {if (!procedureId) {if (+ parts.parameters &&Array.isArray(methodOperationParameter) &&methodOperationParameter.length > 0) {@@ -1813,6 +1849,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(methodOperationStep) &&methodOperationStep.length > 0) {@@ -1857,7 +1894,9 @@ serve(async (req: Request) => {{}) ?? {};}+ } // end if (parts.billOfProcess)+ if (parts.billOfMaterial) {const mapMethodMaterialToQuoteMaterial = async (child: MethodTreeItem) => {@@ -2038,6 +2077,7 @@ serve(async (req: Request) => {.values(pickedOrBoughtMaterials).execute();}+ } // end if (parts.billOfMaterial)}await traverseMethod(methodTree, quoteMakeMethod.data.id);@@ -2126,14 +2166,18 @@ serve(async (req: Request) => {await db.transaction().execute(async (trx) => {// Delete existing quoteMakeMethodOperation, quoteMakeMethodMaterialawait Promise.all([- trx- .deleteFrom("quoteMaterial")- .where("quoteMakeMethodId", "=", quoteMakeMethodId)- .execute(),- trx- .deleteFrom("quoteOperation")- .where("quoteMakeMethodId", "=", quoteMakeMethodId)- .execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("quoteMaterial")+ .where("quoteMakeMethodId", "=", quoteMakeMethodId)+ .execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx+ .deleteFrom("quoteOperation")+ .where("quoteMakeMethodId", "=", quoteMakeMethodId)+ .execute()+ : Promise.resolve(),trx.updateTable("quoteMakeMethod").set({ version: makeMethod.data.version ?? 1 })@@ -2214,13 +2258,15 @@ serve(async (req: Request) => {op.operationSupplierProcessId),tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},companyId,createdBy: userId,customFields: {},})) ?? [];let methodOperationsToQuoteOperations: Record<string, string> = {};++ if (parts.billOfProcess) {if (quoteOperationInserts?.length > 0) {const operationIds = await trx.insertInto("quoteOperation")@@ -2242,6 +2288,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(methodOperationTool) &&methodOperationTool.length > 0) {@@ -2261,6 +2308,7 @@ serve(async (req: Request) => {if (!procedureId) {if (+ parts.parameters &&Array.isArray(methodOperationParameter) &&methodOperationParameter.length > 0) {@@ -2279,6 +2327,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(methodOperationStep) &&methodOperationStep.length > 0) {@@ -2311,7 +2360,9 @@ serve(async (req: Request) => {{}) ?? {};}+ } // end if (parts.billOfProcess)+ if (parts.billOfMaterial) {const mapMethodMaterialToQuoteMaterial = (child: MethodTreeItem) => ({@@ -2393,6 +2444,7 @@ serve(async (req: Request) => {.values(pickedOrBoughtMaterials).execute();}+ } // end if (parts.billOfMaterial)}await traverseMethod(methodTree, quoteMakeMethod.data.id);@@ -2544,18 +2596,22 @@ serve(async (req: Request) => {: mm);await Promise.all([- trx- .deleteFrom("methodMaterial")- .where("makeMethodId", "in", makeMethodsToDelete)- .execute(),- trx- .deleteFrom("methodOperation")- .where("makeMethodId", "in", makeMethodsToDelete)- .execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("methodMaterial")+ .where("makeMethodId", "in", makeMethodsToDelete)+ .execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx+ .deleteFrom("methodOperation")+ .where("makeMethodId", "in", makeMethodsToDelete)+ .execute()+ : Promise.resolve(),]);}- if (materialInserts.length > 0) {+ if (parts.billOfMaterial && materialInserts.length > 0) {await trx.insertInto("methodMaterial").values(@@ -2576,6 +2632,7 @@ serve(async (req: Request) => {.execute();}+ if (parts.billOfProcess) {jobOperations.data?.forEach((op) => {operationInserts.push({makeMethodId: op.makeMethodId!,@@ -2596,7 +2653,7 @@ serve(async (req: Request) => {operationLeadTime: op.operationLeadTime ?? 0,operationUnitCost: op.operationUnitCost ?? 0,tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},companyId,createdBy: userId,customFields: {},@@ -2632,6 +2689,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(jobOperationTool) &&jobOperationTool.length > 0) {@@ -2651,6 +2709,7 @@ serve(async (req: Request) => {if (!procedureId) {if (+ parts.parameters &&Array.isArray(jobOperationParameter) &&jobOperationParameter.length > 0) {@@ -2669,6 +2728,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(jobOperationStep) &&jobOperationStep.length > 0) {@@ -2688,6 +2748,7 @@ serve(async (req: Request) => {}}}+ } // end if (parts.billOfProcess)});break;@@ -2835,18 +2896,22 @@ serve(async (req: Request) => {: mm);await Promise.all([- trx- .deleteFrom("methodMaterial")- .where("makeMethodId", "in", makeMethodsToDelete)- .execute(),- trx- .deleteFrom("methodOperation")- .where("makeMethodId", "in", makeMethodsToDelete)- .execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("methodMaterial")+ .where("makeMethodId", "in", makeMethodsToDelete)+ .execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx+ .deleteFrom("methodOperation")+ .where("makeMethodId", "in", makeMethodsToDelete)+ .execute()+ : Promise.resolve(),]);}- if (materialInserts.length > 0) {+ if (parts.billOfMaterial && materialInserts.length > 0) {await trx.insertInto("methodMaterial").values(@@ -2867,6 +2932,7 @@ serve(async (req: Request) => {.execute();}+ if (parts.billOfProcess) {jobOperations.data?.forEach((op) => {operationInserts.push({makeMethodId: op.makeMethodId!,@@ -2888,7 +2954,7 @@ serve(async (req: Request) => {operationUnitCost: op.operationUnitCost ?? 0,operationSupplierProcessId: op.operationSupplierProcessId,tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},companyId,createdBy: userId,customFields: {},@@ -2924,6 +2990,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(jobOperationTool) &&jobOperationTool.length > 0) {@@ -2943,6 +3010,7 @@ serve(async (req: Request) => {if (!procedureId) {if (+ parts.parameters &&Array.isArray(jobOperationParameter) &&jobOperationParameter.length > 0) {@@ -2961,6 +3029,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(jobOperationStep) &&jobOperationStep.length > 0) {@@ -2989,6 +3058,7 @@ serve(async (req: Request) => {}}}+ } // end if (parts.billOfProcess)});break;@@ -3431,18 +3501,22 @@ serve(async (req: Request) => {: mm);await Promise.all([- trx- .deleteFrom("methodMaterial")- .where("makeMethodId", "in", makeMethodsToDelete)- .execute(),- trx- .deleteFrom("methodOperation")- .where("makeMethodId", "in", makeMethodsToDelete)- .execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("methodMaterial")+ .where("makeMethodId", "in", makeMethodsToDelete)+ .execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx+ .deleteFrom("methodOperation")+ .where("makeMethodId", "in", makeMethodsToDelete)+ .execute()+ : Promise.resolve(),]);}- if (materialInserts.length > 0) {+ if (parts.billOfMaterial && materialInserts.length > 0) {await trx.insertInto("methodMaterial").values(@@ -3463,6 +3537,7 @@ serve(async (req: Request) => {.execute();}+ if (parts.billOfProcess) {quoteOperations.data?.forEach((op) => {operationInserts.push({makeMethodId: op.makeMethodId!,@@ -3483,7 +3558,7 @@ serve(async (req: Request) => {operationLeadTime: op.operationLeadTime ?? 0,operationUnitCost: op.operationUnitCost ?? 0,tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},companyId,createdBy: userId,customFields: {},@@ -3519,6 +3594,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(quoteOperationTool) &"eOperationTool.length > 0) {@@ -3538,6 +3614,7 @@ serve(async (req: Request) => {if (!procedureId) {if (+ parts.parameters &&Array.isArray(quoteOperationParameter) &"eOperationParameter.length > 0) {@@ -3556,6 +3633,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(quoteOperationStep) &"eOperationStep.length > 0) {@@ -3575,6 +3653,7 @@ serve(async (req: Request) => {}}}+ } // end if (parts.billOfProcess)});break;@@ -3721,18 +3800,22 @@ serve(async (req: Request) => {: mm);await Promise.all([- trx- .deleteFrom("methodMaterial")- .where("makeMethodId", "in", makeMethodsToDelete)- .execute(),- trx- .deleteFrom("methodOperation")- .where("makeMethodId", "in", makeMethodsToDelete)- .execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("methodMaterial")+ .where("makeMethodId", "in", makeMethodsToDelete)+ .execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx+ .deleteFrom("methodOperation")+ .where("makeMethodId", "in", makeMethodsToDelete)+ .execute()+ : Promise.resolve(),]);}- if (materialInserts.length > 0) {+ if (parts.billOfMaterial && materialInserts.length > 0) {await trx.insertInto("methodMaterial").values(@@ -3753,6 +3836,7 @@ serve(async (req: Request) => {.execute();}+ if (parts.billOfProcess) {quoteOperations.data?.forEach((op) => {operationInserts.push({makeMethodId: op.makeMethodId!,@@ -3773,7 +3857,7 @@ serve(async (req: Request) => {operationLeadTime: op.operationLeadTime ?? 0,operationUnitCost: op.operationUnitCost ?? 0,tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},companyId,createdBy: userId,customFields: {},@@ -3809,6 +3893,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(quoteOperationTool) &"eOperationTool.length > 0) {@@ -3828,6 +3913,7 @@ serve(async (req: Request) => {if (!procedureId) {if (+ parts.parameters &&Array.isArray(quoteOperationParameter) &"eOperationParameter.length > 0) {@@ -3846,6 +3932,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(quoteOperationStep) &"eOperationStep.length > 0) {@@ -3865,6 +3952,7 @@ serve(async (req: Request) => {}}}+ } // end if (parts.billOfProcess)});break;@@ -3970,17 +4058,23 @@ serve(async (req: Request) => {await db.transaction().execute(async (trx) => {// Delete existing jobMakeMethods, jobMaterials, and jobOperations for this jobawait Promise.all([- trx- .deleteFrom("jobMakeMethod")- .where((eb) =>- eb.and([- eb("jobId", "=", jobId),- eb("parentMaterialId", "is not", null),- ])- )- .execute(),- trx.deleteFrom("jobMaterial").where("jobId", "=", jobId).execute(),- trx.deleteFrom("jobOperation").where("jobId", "=", jobId).execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("jobMakeMethod")+ .where((eb) =>+ eb.and([+ eb("jobId", "=", jobId),+ eb("parentMaterialId", "is not", null),+ ])+ )+ .execute()+ : Promise.resolve(),+ parts.billOfMaterial+ ? trx.deleteFrom("jobMaterial").where("jobId", "=", jobId).execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx.deleteFrom("jobOperation").where("jobId", "=", jobId).execute()+ : Promise.resolve(),]);await traverseQuoteMethod(@@ -4131,14 +4225,14 @@ serve(async (req: Request) => {}}- if (jobMaterialInserts.length > 0) {+ if (parts.billOfMaterial && jobMaterialInserts.length > 0) {await trx.insertInto("jobMaterial").values(jobMaterialInserts).execute();}- if (jobMakeMethodInserts.length > 0) {+ if (parts.billOfMaterial && jobMakeMethodInserts.length > 0) {for await (const insert of jobMakeMethodInserts) {await trx.updateTable("jobMakeMethod")@@ -4154,6 +4248,7 @@ serve(async (req: Request) => {});+ if (parts.billOfProcess) {const jobOperationInserts: Database["public"]["Tables"]["jobOperation"]["Insert"][] =quoteOperations.data.map((op) => {// Get quantities for this operation's make method@@ -4183,7 +4278,7 @@ serve(async (req: Request) => {operationLeadTime: op.operationLeadTime ?? 0,operationUnitCost: op.operationUnitCost ?? 0,tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},targetQuantity: opQuantities?.targetQuantity ?? 0,operationQuantity: opQuantities?.totalWithScrap ?? 0,companyId,@@ -4212,6 +4307,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(quoteOperationTool) &"eOperationTool.length > 0) {@@ -4238,6 +4334,7 @@ serve(async (req: Request) => {});} else {if (+ parts.parameters &&Array.isArray(quoteOperationParameter) &"eOperationParameter.length > 0) {@@ -4256,6 +4353,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(quoteOperationStep) &"eOperationStep.length > 0) {@@ -4275,6 +4373,7 @@ serve(async (req: Request) => {}}}+ } // end if (parts.billOfProcess)});break;@@ -4348,25 +4447,31 @@ serve(async (req: Request) => {const quoteMakeMethodIdToQuoteMakeMethodId: Record<string, string> = {};await db.transaction().execute(async (trx) => {- // Delete existing jobMakeMethods, jobMaterials, and jobOperations for this job+ // Delete existing quoteMakeMethods, quoteMaterials, and quoteOperations for this quote lineawait Promise.all([- trx- .deleteFrom("quoteMakeMethod")- .where((eb) =>- eb.and([- eb("quoteLineId", "=", targetQuoteLineId),- eb("parentMaterialId", "is not", null),- ])- )- .execute(),- trx- .deleteFrom("quoteMaterial")- .where("quoteLineId", "=", targetQuoteLineId)- .execute(),- trx- .deleteFrom("quoteOperation")- .where("quoteLineId", "=", targetQuoteLineId)- .execute(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("quoteMakeMethod")+ .where((eb) =>+ eb.and([+ eb("quoteLineId", "=", targetQuoteLineId),+ eb("parentMaterialId", "is not", null),+ ])+ )+ .execute()+ : Promise.resolve(),+ parts.billOfMaterial+ ? trx+ .deleteFrom("quoteMaterial")+ .where("quoteLineId", "=", targetQuoteLineId)+ .execute()+ : Promise.resolve(),+ parts.billOfProcess+ ? trx+ .deleteFrom("quoteOperation")+ .where("quoteLineId", "=", targetQuoteLineId)+ .execute()+ : Promise.resolve(),]);await traverseQuoteMethod(@@ -4426,14 +4531,14 @@ serve(async (req: Request) => {}}- if (quoteMaterialInserts.length > 0) {+ if (parts.billOfMaterial && quoteMaterialInserts.length > 0) {await trx.insertInto("quoteMaterial").values(quoteMaterialInserts).execute();}- if (quoteMakeMethodInserts.length > 0) {+ if (parts.billOfMaterial && quoteMakeMethodInserts.length > 0) {for await (const insert of quoteMakeMethodInserts) {await trx.updateTable("quoteMakeMethod")@@ -4449,6 +4554,7 @@ serve(async (req: Request) => {});+ if (parts.billOfProcess) {const quoteOperationInserts: Database["public"]["Tables"]["quoteOperation"]["Insert"][] =sourceQuoteOperations.data.map((op) => ({quoteId: targetQuoteId,@@ -4478,7 +4584,7 @@ serve(async (req: Request) => {operationUnitCost: op.operationUnitCost ?? 0,overheadRate: op.overheadRate,tags: op.tags ?? [],- workInstruction: op.workInstruction,+ workInstruction: parts.workInstructions ? op.workInstruction : {},companyId,createdBy: userId,customFields: {},@@ -4503,6 +4609,7 @@ serve(async (req: Request) => {} = operation;if (+ parts.tools &&Array.isArray(quoteOperationTool) &"eOperationTool.length > 0) {@@ -4521,6 +4628,7 @@ serve(async (req: Request) => {}if (+ parts.parameters &&Array.isArray(quoteOperationParameter) &"eOperationParameter.length > 0) {@@ -4539,6 +4647,7 @@ serve(async (req: Request) => {}if (+ parts.steps &&Array.isArray(quoteOperationStep) &"eOperationStep.length > 0) {@@ -4557,6 +4666,7 @@ serve(async (req: Request) => {}}}+ } // end if (parts.billOfProcess)});break;