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(sales): don't show a reopened job's line as Completed/Shipped

Sidwebworksdec68c235ab3
diff --git a/packages/utils/src/status.ts b/packages/utils/src/status.ts
index c40d8da69b..4a8e15a5c1 100644
--- a/packages/utils/src/status.ts
+++ b/packages/utils/src/status.ts
@@ -106,8 +106,16 @@ export const getSalesOrderJobStatus = (
(acc, job) => acc + (job.productionQuantity ?? 0),
0
);
+ // A job's quantityComplete persists after the job is reopened, so completion
+ // must be gated on the job actually being in a completed status. Otherwise a
+ // reopened (In Progress) job that still has quantityComplete >= saleQuantity
+ // would keep the line reading "Completed" (or "Shipped").
const totalCompleted = filteredJobs.reduce(
- (acc, job) => acc + job.quantityComplete,
+ (acc, job) =>
+ acc +
+ (["Completed", "Closed"].includes(job.status ?? "")
+ ? job.quantityComplete
+ : 0),
0
);
const totalReleased = filteredJobs.reduce((acc, job) => {