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: close production events automatically when completing an operation

Brad Barbin376b30a0ae1d
diff --git a/apps/mes/app/services/operations.service.ts b/apps/mes/app/services/operations.service.ts
index 0202dd0d41..bc73b721e7 100644
--- a/apps/mes/app/services/operations.service.ts
+++ b/apps/mes/app/services/operations.service.ts
@@ -17,6 +17,18 @@ export async function finishJobOperation(
userId: string;
}
) {
+ const closeProductionEvents = await client
+ .from("productionEvent")
+ .update({
+ endTime: new Date().toISOString(),
+ updatedBy: args.userId,
+ })
+ .eq("jobOperationId", args.jobOperationId);
+
+ if (closeProductionEvents.error) {
+ return closeProductionEvents;
+ }
+
return client
.from("jobOperation")
.update({