Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: include operations in quote material form
Brad Barbin3bbec2a26e3f
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsxindex db90bfceb9..8aa7ba1f95 100644--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx@@ -186,6 +186,7 @@ function getNodePath(node: FlatTreeItem<QuoteMethod>) {node.data.quoteId,node.data.quoteLineId,node.data.methodType.toLowerCase(),+ node.data.quoteMakeMethodId,node.data.methodMaterialId);}diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsxindex b2d239fa24..86364a4f14 100644--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx@@ -137,6 +137,7 @@ const QuoteMaterialForm = ({quoteId,lineId,initialValues.methodType.toLowerCase(),+ initialValues.quoteMakeMethodId,initialValues.id!);if (diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.buy.$materialId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.buy.$methodId.$materialId.tsxsimilarity index 73%rename from apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.buy.$materialId.tsxrename to apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.buy.$methodId.$materialId.tsxindex f385a7a161..5f12b3e438 100644--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.buy.$materialId.tsx+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.buy.$methodId.$materialId.tsx@@ -2,7 +2,11 @@ import { VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect, useLoaderData, useParams } from "@remix-run/react";-import { getQuoteMaterial, QuoteMaterialForm } from "~/modules/sales";+import {+ getQuoteMaterial,+ getQuoteOperationsByMethodId,+ QuoteMaterialForm,+} from "~/modules/sales";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -12,12 +16,16 @@ export async function loader({ request, params }: LoaderFunctionArgs) {view: "parts",});- const { quoteId, lineId, materialId } = params;+ const { quoteId, lineId, methodId, materialId } = params;if (!quoteId) throw new Error("Could not find quoteId");if (!lineId) throw new Error("Could not find lineId");+ if (!methodId) throw new Error("Could not find methodId");if (!materialId) throw new Error("Could not find materialId");- const [material] = await Promise.all([getQuoteMaterial(client, materialId)]);+ const [material, operations] = await Promise.all([+ getQuoteMaterial(client, materialId),+ getQuoteOperationsByMethodId(client, methodId),+ ]);if (material.error) {throw redirect(@@ -46,11 +54,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {unitCost: material.data.unitCost ?? 0,unitOfMeasureCode: material.data.unitOfMeasureCode ?? "",},+ operations:+ operations.data?.map((o) => ({+ ...o,+ description: o.description ?? "",+ equipmentTypeId: o.equipmentTypeId ?? undefined,+ quoteMakeMethodId: o.quoteMakeMethodId ?? methodId,+ })) ?? [],});}export default function QuoteMaterialBuyPage() {- const { material } = useLoaderData<typeof loader>();+ const { material, operations } = useLoaderData<typeof loader>();const { materialId } = useParams();if (!materialId) throw new Error("Could not find materialId");@@ -60,7 +75,7 @@ export default function QuoteMaterialBuyPage() {<QuoteMaterialFormkey={materialId}initialValues={material}- operations={[]}+ operations={operations}/></VStack>);diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsxindex af538ab8a1..a8475ab77f 100644--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx@@ -107,7 +107,7 @@ export default function QuoteMakeMethodRoute() {<QuoteMaterialFormkey={material.id}initialValues={material}- operations={[]}+ operations={operations}/><QuoteBillOfProcesskey={JSON.stringify(operations)}diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.pick.$materialId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.pick.$methodId.$materialId.tsxsimilarity index 73%rename from apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.pick.$materialId.tsxrename to apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.pick.$methodId.$materialId.tsxindex fff1178f93..1cbcd2df25 100644--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.pick.$materialId.tsx+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.pick.$methodId.$materialId.tsx@@ -2,7 +2,11 @@ import { VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect, useLoaderData, useParams } from "@remix-run/react";-import { getQuoteMaterial, QuoteMaterialForm } from "~/modules/sales";+import {+ getQuoteMaterial,+ getQuoteOperationsByMethodId,+ QuoteMaterialForm,+} from "~/modules/sales";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -12,12 +16,16 @@ export async function loader({ request, params }: LoaderFunctionArgs) {view: "parts",});- const { quoteId, lineId, materialId } = params;+ const { quoteId, lineId, methodId, materialId } = params;if (!quoteId) throw new Error("Could not find quoteId");if (!lineId) throw new Error("Could not find lineId");+ if (!methodId) throw new Error("Could not find methodId");if (!materialId) throw new Error("Could not find materialId");- const [material] = await Promise.all([getQuoteMaterial(client, materialId)]);+ const [material, operations] = await Promise.all([+ getQuoteMaterial(client, materialId),+ getQuoteOperationsByMethodId(client, methodId),+ ]);if (material.error) {throw redirect(@@ -46,11 +54,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {unitCost: material.data.unitCost ?? 0,unitOfMeasureCode: material.data.unitOfMeasureCode ?? "",},+ operations:+ operations.data?.map((o) => ({+ ...o,+ description: o.description ?? "",+ equipmentTypeId: o.equipmentTypeId ?? undefined,+ quoteMakeMethodId: o.quoteMakeMethodId ?? methodId,+ })) ?? [],});}export default function QuoteMaterialPickPage() {- const { material } = useLoaderData<typeof loader>();+ const { material, operations } = useLoaderData<typeof loader>();const { materialId } = useParams();if (!materialId) throw new Error("Could not find materialId");@@ -60,7 +75,7 @@ export default function QuoteMaterialPickPage() {<QuoteMaterialFormkey={materialId}initialValues={material}- operations={[]}+ operations={operations}/></VStack>);diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.tsindex a4326dabae..8d872f4a63 100644--- a/apps/carbon/app/utils/path.ts+++ b/apps/carbon/app/utils/path.ts@@ -564,8 +564,12 @@ export const path = {quoteId: string,lineId: string,methodType: string,+ methodId: string,id: string- ) => generatePath(`${x}/quote/${quoteId}/${lineId}/${methodType}/${id}`),+ ) =>+ generatePath(+ `${x}/quote/${quoteId}/${lineId}/${methodType}/${methodId}/${id}`+ ),quoteLineMaterialMake: (quoteId: string,lineId: string,