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.

refactor: move readable serial number to it's own column

Brad Barbine495bddc0a63
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index 679552ac83..07a08c8923 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -1610,8 +1610,7 @@ export async function updateJobBatchNumber(
}
})
.eq("id", currentAttributes.data.id)
- .select("id, attributes")
- .order("createdAt", { ascending: false });
+ .select("id, attributes");
}
export async function updateJobStatus(
diff --git a/apps/erp/app/routes/x+/job+/update.tsx b/apps/erp/app/routes/x+/job+/update.tsx
index 918d8bba1d..52d35665c8 100644
--- a/apps/erp/app/routes/x+/job+/update.tsx
+++ b/apps/erp/app/routes/x+/job+/update.tsx
@@ -2,7 +2,7 @@ import { getCarbonServiceRole } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import type { recalculateTask } from "@carbon/jobs/trigger/recalculate";
import { tasks } from "@trigger.dev/sdk";
-import { type ActionFunctionArgs, json } from "react-router";
+import { type ActionFunctionArgs } from "react-router";
import {
calculateJobPriority,
recalculateJobRequirements,
@@ -19,6 +19,8 @@ export async function action({ request }: ActionFunctionArgs) {
const field = formData.get("field");
const value = formData.get("value");
+ console.log({ ids, field, value });
+
if (typeof field !== "string") {
return { error: { message: "Invalid form data" }, data: null };
}
diff --git a/packages/database/supabase/migrations/20251220013724_tracked-entity-readable-id.sql b/packages/database/supabase/migrations/20251220013724_tracked-entity-readable-id.sql
new file mode 100644
index 0000000000..218a9f022b
--- /dev/null
+++ b/packages/database/supabase/migrations/20251220013724_tracked-entity-readable-id.sql
@@ -0,0 +1,7 @@
+ALTER TABLE "trackedEntity" ADD COLUMN "readableId" TEXT;
+
+UPDATE "trackedEntity"
+SET "readableId" = attributes->>'Batch Number'
+WHERE attributes ? 'Batch Number'
+ AND attributes->>'Batch Number' IS NOT NULL
+ AND attributes->>'Batch Number' != '';