Skip to content

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.

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.tsx
index 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.tsx
index 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.tsx
similarity index 73%
rename from apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.buy.$materialId.tsx
rename to apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.buy.$methodId.$materialId.tsx
index 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() {
<QuoteMaterialForm
key={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.tsx
index 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() {
<QuoteMaterialForm
key={material.id}
initialValues={material}
- operations={[]}
+ operations={operations}
/>
<QuoteBillOfProcess
key={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.tsx
similarity index 73%
rename from apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.pick.$materialId.tsx
rename to apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.pick.$methodId.$materialId.tsx
index 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() {
<QuoteMaterialForm
key={materialId}
initialValues={material}
- operations={[]}
+ operations={operations}
/>
</VStack>
);
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 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,