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(items): updateItem refuses an empty readable id too
Raulb87514991485
diff --git a/apps/erp/app/modules/items/items.service.ts b/apps/erp/app/modules/items/items.service.tsindex 1bb964f69b..6e9ea9215d 100644--- a/apps/erp/app/modules/items/items.service.ts+++ b/apps/erp/app/modules/items/items.service.ts@@ -3939,7 +3939,7 @@ export async function updateItem(if (!current.data) {return { data: null, error: ruleError(`${type} ${item.id} not found`) };}- if (readableId && readableId !== current.data.readableId) {+ if (readableId !== undefined && readableId !== current.data.readableId) {return {data: null,error: ruleError(diff --git a/apps/erp/test/items-operations.test.ts b/apps/erp/test/items-operations.test.tsindex efe3008ea3..96e5d86fdb 100644--- a/apps/erp/test/items-operations.test.ts+++ b/apps/erp/test/items-operations.test.ts@@ -336,13 +336,15 @@ describe("updateItem", () => {it("refuses a readable id that differs from the item's, and writes nothing", async () => {const { client, writes } = fakeClient({ item: { readableId: "P-100" } });- const result = await updateItem(contextFor(client), {- ...part,- readableId: "P-200"- });-- expect(result.error).toMatchObject({ category: "rule" });- expect(result.error?.message).toContain("setItemReadableId");+ for (const readableId of ["P-200", ""]) {+ const result = await updateItem(contextFor(client), {+ ...part,+ readableId+ });++ expect(result.error).toMatchObject({ category: "rule" });+ expect(result.error?.message).toContain("setItemReadableId");+ }expect(writes).toHaveLength(0);});