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: use sales order location if no line location exists
Brad Barbin072f79a2653a
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex 00918d6243..46ff1d2d87 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -131,29 +131,18 @@ export async function convertSalesOrderLinesToJobs(const dueDate = line.promisedDate ?? undefined;- // Validate locationId exists if provided- let locationId = line.locationId;- if (locationId) {- const locationExists = await serviceRole+ let locationId = line.locationId ?? salesOrder.data?.locationId;+ if (!locationId) {+ const defaultLocation = await serviceRole.from("location").select("id")- .eq("id", locationId).eq("companyId", companyId)- .single();-- if (locationExists.error) {- // If location doesn't exist, try to get a default location for the company- const defaultLocation = await serviceRole- .from("location")- .select("id")- .eq("companyId", companyId)- .limit(1);-- if (defaultLocation.data) {- locationId = defaultLocation.data?.[0]?.id;- } else {- throw new Error("No location found");- }+ .limit(1);++ if (defaultLocation.data) {+ locationId = defaultLocation.data?.[0]?.id;+ } else {+ throw new Error("No location found");}}