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: rfqs to quote flow
Sidwebworksa01d90d2af1c
diff --git a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.convert.tsx b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.convert.tsxindex 29e7a83162..8a4dd440d3 100644--- a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.convert.tsx+++ b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.convert.tsx@@ -4,7 +4,12 @@ import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";-import { convertSalesRfqToQuote } from "~/modules/sales";+import {+ calculatePricesForQuantities,+ convertSalesRfqToQuote,+ resolvePurchaseToOrderPrices,+ resolveQuoteLinePrices+} from "~/modules/sales";import { path } from "~/utils/path";export async function action({ request, params }: ActionFunctionArgs) {@@ -30,8 +35,61 @@ export async function action({ request, params }: ActionFunctionArgs) {);}+ const quoteId = convert.data?.convertedId!;++ // Seed `quoteLinePrice` rows for every new line. The convert function+ // creates the `quoteLine` records (and, for Make to Order, kicks off+ // `get-method itemToQuoteLine` to populate methods/materials), but it+ // never writes any prices — so the new quote opens with empty pricing.+ // The standard "add quote line" path in `$quoteId.new.tsx` calls these+ // same helpers per methodType; mirror that here.+ const newLines = await serviceRole+ .from("quoteLine")+ .select("id, methodType, quantity")+ .eq("quoteId", quoteId);++ if (!newLines.error && newLines.data) {+ await Promise.all(+ newLines.data.map((line) => {+ const quantities = line.quantity ?? [1];+ if (quantities.length === 0) return null;++ switch (line.methodType) {+ case "Make to Order":+ return calculatePricesForQuantities(+ serviceRole,+ quoteId,+ line.id,+ quantities,+ userId+ );+ case "Pull from Inventory":+ return resolveQuoteLinePrices(+ serviceRole,+ companyId,+ quoteId,+ line.id,+ quantities,+ userId+ );+ case "Purchase to Order":+ return resolvePurchaseToOrderPrices(+ serviceRole,+ companyId,+ quoteId,+ line.id,+ quantities,+ userId+ );+ default:+ return null;+ }+ })+ );+ }+throw redirect(- path.to.quoteDetails(convert.data?.convertedId!),+ path.to.quoteDetails(quoteId),await flash(request, success("Successfully converted RFQ to quote")));}