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(items): name the highest Active version in the Draft notice

Raul87135190e376
diff --git a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
index 36b6cb3aeb..e09b1679ac 100644
--- a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
+++ b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
@@ -139,12 +139,13 @@ const MakeMethodTools = ({
makeMethods.find((m) => m.id === activeMethodId) ?? makeMethods[0];
// New jobs take the Active version over any Draft (`activeMakeMethods`), so
- // edits to a Draft reach them only once it is made Active.
+ // edits to a Draft reach them only once it is made Active. Like that view,
+ // take the highest Active version if more than one is Active.
const liveMethod =
activeMethod.status === "Draft"
- ? makeMethods.find(
- (m) => m.status === "Active" && m.id !== activeMethod.id
- )
+ ? makeMethods
+ .filter((m) => m.status === "Active" && m.id !== activeMethod.id)
+ .sort((a, b) => b.version - a.version)[0]
: undefined;
const maxVersion = Math.max(...makeMethods.map((m) => m.version));