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(production): number a Consumed entity at serial completion only when it holds one unit

Raul9b35dcd74539
diff --git a/apps/erp/app/modules/inventory/inventory.service.ts b/apps/erp/app/modules/inventory/inventory.service.ts
index b80ce9c9fc..bee691679c 100644
--- a/apps/erp/app/modules/inventory/inventory.service.ts
+++ b/apps/erp/app/modules/inventory/inventory.service.ts
@@ -23520,10 +23520,12 @@ export async function issueMaterial(
// First-touch numbering (serialNumberTiming = 'production'). A no-op
// for a unit already numbered, which is every unit under the default
- // timing.
+ // timing. A Consumed entity is not cut to one unit below, so it is
+ // numbered only when it already holds one.
await sequence.assignSerialNumberIfMissing(trx, {
trackedEntityId,
- companyId
+ companyId,
+ onlyIfSingleUnit: trackedEntity.status === "Consumed"
});
if (trackedEntity.status !== "Consumed") {