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
refactor: update job order status handling and UI components
naveenkash85c57a771801
diff --git a/apps/erp/app/modules/production/jobOrderStatus.ts b/apps/erp/app/modules/production/jobOrderStatus.tsindex 3a7b376f9e..81361b6313 100644--- a/apps/erp/app/modules/production/jobOrderStatus.ts+++ b/apps/erp/app/modules/production/jobOrderStatus.ts@@ -17,9 +17,6 @@ export type ItemOrderStatus = {// supply-side counterpart to `status`; lets a planned/in-flight job surface a// positive indicator instead of a bare "needs order" dot.supplyJobStatus: JobStatus | null;- // The owning job is Completed — procurement status is moot, so every material- // shows a single "Completed" badge instead of per-material indicators.- jobCompleted: boolean;// This job's full requirement is met from on-hand stock (after priority// allocation) — i.e. the parts are already in inventory, not merely on order.// Lets a fulfilled high-priority job show "in stock" while a lower-priority job@@ -36,7 +33,7 @@ export type JobOrderStatusCategory =| "awaitingApproval"| "onOrder"| "received"- | "completed";+ | "inStock";// Must match the demand window in get_job_quantity_on_hand and the scheduling// sequence.@@ -139,28 +136,12 @@ export function getJobMaterialOrderStatus(shortfall,status,supplyJobStatus,- jobCompleted: false,coveredByOnHand,ordered,received};}-// A uniform "Completed" status for every material of a finished job. Skips the-// PO/supply/shortfall math — procurement state is irrelevant once the job is done.-export function getCompletedJobOrderStatus(): ItemOrderStatus {- return {- needsOrder: false,- shortfall: 0,- status: null,- supplyJobStatus: null,- jobCompleted: true,- coveredByOnHand: false,- ordered: 0,- received: 0- };-}-// The single source of truth for order-status precedence. Both the status filter// and JobOrderStatusBadge derive from this (the badge maps each category to its// icon/label), so they can never disagree. Order of the checks below IS the@@ -168,14 +149,11 @@ export function getCompletedJobOrderStatus(): ItemOrderStatus {export function getJobOrderStatusCategory(status: ItemOrderStatus | undefined): JobOrderStatusCategory | null {- if (status?.jobCompleted) return "completed";-// A still-unmet, priority-adjusted shortfall outranks the supply indicators —// see JobOrderStatusBadge for why.if (status?.needsOrder) return "needsOrder";- // On-hand coverage shares the "completed" category (same green check).- if (status?.coveredByOnHand) return "completed";+ if (status?.coveredByOnHand) return "inStock";switch (status?.status) {case "Planned":diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex 62693d1abf..3d962564f8 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -18,7 +18,6 @@ import type {} from "../shared";import {ACTIVE_JOB_STATUSES,- getCompletedJobOrderStatus,getJobOrderStatusByMaterial,type ItemOrderStatus,type ItemShortfall,@@ -1129,17 +1128,7 @@ export async function getJobOrderStatusMap(Awaited<ReturnType<typeof getJobMaterialsWithQuantityOnHand>>["data"]>): Promise<Record<string, ItemOrderStatus>> {- // A completed job shows a uniform "Completed" badge on every material instead- // of per-material procurement indicators (no PO/supply/shortfall lookups).- if (jobStatus === "Completed") {- const byMaterialId: Record<string, ItemOrderStatus> = {};- for (const material of materials) {- if (!material.id) continue;- byMaterialId[material.id] = getCompletedJobOrderStatus();- }- return byMaterialId;- }-+ // Completed/Draft/Cancelled/Closed jobs show no procurement indicators.if (isJobOrderStatusHidden(jobStatus)) return {};const [purchaseOrderLines, supplyJobLines] = await Promise.all([diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsxindex fb222b0d05..24500c548b 100644--- a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx+++ b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx@@ -207,8 +207,7 @@ const JobMaterialsTable = memo({ value: "awaitingApproval", label: t`Awaiting approval` },{ value: "onOrder", label: t`On order` },{ value: "received", label: t`Pending` },- // `completed` is "In stock" on an active job, "Completed" once done.- { value: "completed", label: t`In stock` }+ { value: "inStock", label: t`In stock` }]}}diff --git a/apps/erp/app/modules/production/ui/Jobs/JobOrderStatus.tsx b/apps/erp/app/modules/production/ui/Jobs/JobOrderStatus.tsxindex a1e67f8b64..fd429c2643 100644--- a/apps/erp/app/modules/production/ui/Jobs/JobOrderStatus.tsx+++ b/apps/erp/app/modules/production/ui/Jobs/JobOrderStatus.tsx@@ -29,14 +29,10 @@ export function JobOrderStatusBadge({const category = getJobOrderStatusCategory(status);switch (category) {- case "completed":+ case "inStock":return badge(<LuCircleCheck className="text-emerald-600" />,- status?.jobCompleted ? (- <Trans>Completed</Trans>- ) : (- <Trans>In stock</Trans>- )+ <Trans>In stock</Trans>);case "needsOrder":return badge(diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.jsonindex 39ffce4aad..36bf835238 100644--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json@@ -1,5 +1,5 @@{- "generated": "2026-06-23T19:28:18.113Z",+ "generated": "2026-06-23T22:34:05.399Z","totalTools": 1214,"modules": 15,"tools": [