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: show revision suffix on quotes, RFQs, supplier quotes and POs in global search

aashu7e5c79d209d3
diff --git a/packages/jobs/src/inngest/functions/events/search-config.test.ts b/packages/jobs/src/inngest/functions/events/search-config.test.ts
index 0090688b5b..07c73eec50 100644
--- a/packages/jobs/src/inngest/functions/events/search-config.test.ts
+++ b/packages/jobs/src/inngest/functions/events/search-config.test.ts
@@ -127,6 +127,28 @@ describe("lookups", () => {
});
});
+describe("revised documents", () => {
+ // A revision shares its original's number, so without the suffix both read
+ // as the same document and searching the revised id finds nothing.
+ it.each([
+ ["quote", "quoteId"],
+ ["salesRfq", "rfqId"],
+ ["supplierQuote", "supplierQuoteId"],
+ ["purchaseOrder", "purchaseOrderId"]
+ ])("%s titles carry the revision", (table, column) => {
+ const titles = planIndexWrites([
+ event(table, "INSERT", "r0", {
+ id: "r0",
+ [column]: "D-1",
+ revisionId: 0
+ }),
+ event(table, "INSERT", "r1", { id: "r1", [column]: "D-1", revisionId: 1 })
+ ]).upserts.map((upsert) => toIndexRow(upsert, new Map()).title);
+
+ expect(titles).toEqual(["D-1", "D-1-1"]);
+ });
+});
+
describe("search links", () => {
// The search box navigates straight to the stored link, so one that names
// no route is a 404 (sales RFQs were indexed at /x/rfq/<id>).
diff --git a/packages/jobs/src/inngest/functions/events/search-config.ts b/packages/jobs/src/inngest/functions/events/search-config.ts
index 6bdbd3a6f4..9c754df6be 100644
--- a/packages/jobs/src/inngest/functions/events/search-config.ts
+++ b/packages/jobs/src/inngest/functions/events/search-config.ts
@@ -2,6 +2,8 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { withRevisionSuffix } from "@carbon/documents/utils";
+
/**
* A related name copied onto the index row: `field` is set to `table.column`
* of the row whose `matchOn` (default `id`) equals `record[from]`. The read is
@@ -138,7 +140,7 @@ export const SEARCH_ENTITY_CONFIGS: Record<string, SearchEntityConfig> = {
},
purchaseOrder: {
entityType: "purchaseOrder",
- getTitle: (r) => r.purchaseOrderId,
+ getTitle: (r) => withRevisionSuffix(r.purchaseOrderId, r.revisionId),
getDescription: (r) => r.supplierName || "",
getLink: (r) => `/x/purchase-order/${r.id}`,
getTags: (r) => [r.status].filter(Boolean),
@@ -227,7 +229,7 @@ export const SEARCH_ENTITY_CONFIGS: Record<string, SearchEntityConfig> = {
},
quote: {
entityType: "quote",
- getTitle: (r) => r.quoteId,
+ getTitle: (r) => withRevisionSuffix(r.quoteId, r.revisionId),
getDescription: (r) =>
`${r.customerName || ""} ${r.customerReference || ""}`,
getLink: (r) => `/x/quote/${r.id}`,
@@ -248,7 +250,7 @@ export const SEARCH_ENTITY_CONFIGS: Record<string, SearchEntityConfig> = {
},
salesRfq: {
entityType: "salesRfq",
- getTitle: (r) => r.rfqId,
+ getTitle: (r) => withRevisionSuffix(r.rfqId, r.revisionId),
getDescription: (r) => r.customerName || "",
getLink: (r) => `/x/sales-rfq/${r.id}`,
getTags: (r) => [r.status].filter(Boolean),
@@ -288,7 +290,7 @@ export const SEARCH_ENTITY_CONFIGS: Record<string, SearchEntityConfig> = {
},
supplierQuote: {
entityType: "supplierQuote",
- getTitle: (r) => r.supplierQuoteId,
+ getTitle: (r) => withRevisionSuffix(r.supplierQuoteId, r.revisionId),
getDescription: (r) => r.supplierName || "",
getLink: (r) => `/x/supplier-quote/${r.id}`,
getTags: (r) => [r.status].filter(Boolean),