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: adding made part to bom

Brad Barbin5f078cce78c6
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
index ac2d48add2..385a203686 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
@@ -65,9 +65,25 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
if (data.methodType === "Make") {
+ const materialMakeMethod = await serviceRole
+ .from("jobMaterialWithMakeMethodId")
+ .select("*")
+ .eq("id", jobMaterialId)
+ .single();
+ if (materialMakeMethod.error) {
+ return json(
+ {
+ id: null,
+ },
+ await flash(
+ request,
+ error(materialMakeMethod.error, "Failed to get material make method")
+ )
+ );
+ }
const makeMethod = await upsertJobMaterialMakeMethod(serviceRole, {
sourceId: data.itemId,
- targetId: jobMaterialId,
+ targetId: materialMakeMethod.data?.jobMaterialMakeMethodId!,
companyId,
userId,
});
diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
index 16a5741295..1686167102 100644
--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
@@ -68,11 +68,27 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
if (data.methodType === "Make") {
+ const materialMakeMethod = await serviceRole
+ .from("quoteMaterialWithMakeMethodId")
+ .select("*")
+ .eq("id", quoteMaterialId)
+ .single();
+ if (materialMakeMethod.error) {
+ return json(
+ {
+ id: null,
+ },
+ await flash(
+ request,
+ error(materialMakeMethod.error, "Failed to get material make method")
+ )
+ );
+ }
const makeMethod = await upsertQuoteMaterialMakeMethod(serviceRole, {
- ...data,
- quoteMaterialId,
+ sourceId: data.itemId,
+ targetId: materialMakeMethod.data?.quoteMaterialMakeMethodId!,
companyId,
- createdBy: userId,
+ userId,
});
if (makeMethod.error) {