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: storage rules allow `.value` and `.label`

Sidwebworksb7d84a373939
diff --git a/apps/erp/app/modules/storageRules/index.ts b/apps/erp/app/modules/storageRules/index.ts
index d7002a02d7..3ce2e07e0a 100644
--- a/apps/erp/app/modules/storageRules/index.ts
+++ b/apps/erp/app/modules/storageRules/index.ts
@@ -1,4 +1,4 @@
-// ERP-side Custom Rules module. Re-exports cross-app queries from the
+// ERP-side Storage Rules module. Re-exports cross-app queries from the
// `@carbon/ee/storage-rules` package alongside ERP-only admin CRUD + form
// validators.
diff --git a/apps/erp/app/modules/storageRules/storageRules.service.ts b/apps/erp/app/modules/storageRules/storageRules.service.ts
index 812c3b5cd8..f0909a0505 100644
--- a/apps/erp/app/modules/storageRules/storageRules.service.ts
+++ b/apps/erp/app/modules/storageRules/storageRules.service.ts
@@ -1,4 +1,4 @@
-// ERP-only admin CRUD for the Settings → Custom Rules page.
+// ERP-only admin CRUD for the Inventory → Storage Rules page.
// Cross-app queries (assignment loaders, list fetch for tab data, polymorphic
// assign/unassign) live in `@carbon/ee/storage-rules`.
diff --git a/apps/erp/app/modules/storageRules/ui/MessageWithTokens.tsx b/apps/erp/app/modules/storageRules/ui/MessageWithTokens.tsx
index df420dded0..52a8ee4466 100644
--- a/apps/erp/app/modules/storageRules/ui/MessageWithTokens.tsx
+++ b/apps/erp/app/modules/storageRules/ui/MessageWithTokens.tsx
@@ -107,7 +107,7 @@ const BRACES_ICON = <LuBraces />;
// false greens, no missed reds. Inlined rather than re-exported to avoid a
// UI → runtime import cycle.
const TOKEN_RE =
- /\{(condition\[\d+\]\.(?:field|operator|value)|[a-zA-Z_][\w.]*)\}/g;
+ /\{(condition\[\d+\]\.(?:field|operator|value|name)|[a-zA-Z_][\w.]*)\}/g;
// Runtime accepts arbitrary suffixes under `item.customFields.*` via the
// generic dotted-path resolver. Treat any such token as known so the editor
@@ -219,7 +219,11 @@ export default function MessageWithTokens({
},
{
token: `condition[${i}].value`,
- description: "Required value"
+ description: "Required value (raw id/input)"
+ },
+ {
+ token: `condition[${i}].name`,
+ description: "Required value (label)"
}
]
});
diff --git a/apps/erp/app/modules/storageRules/ui/StorageRulesGroups.tsx b/apps/erp/app/modules/storageRules/ui/StorageRulesGroups.tsx
index b53e486665..a18f8b4f50 100644
--- a/apps/erp/app/modules/storageRules/ui/StorageRulesGroups.tsx
+++ b/apps/erp/app/modules/storageRules/ui/StorageRulesGroups.tsx
@@ -316,7 +316,7 @@ const StorageRuleCard = memo(({ rule }: { rule: RuleListItem }) => {
action={path.to.deleteStorageRule(rule.id)}
isOpen={deleteDisclosure.isOpen}
name={`${TARGET_LABEL[rule.targetType]} rule "${rule.name}"`}
- text="Are you sure you want to delete this custom rule? Assignments will also be removed."
+ text="Are you sure you want to delete this storage rule? Assignments will also be removed."
onCancel={deleteDisclosure.onClose}
onSubmit={deleteDisclosure.onClose}
/>
diff --git a/apps/erp/app/modules/storageRules/ui/StorageRulesTable.tsx b/apps/erp/app/modules/storageRules/ui/StorageRulesTable.tsx
index df6d276774..e1fc6ab212 100644
--- a/apps/erp/app/modules/storageRules/ui/StorageRulesTable.tsx
+++ b/apps/erp/app/modules/storageRules/ui/StorageRulesTable.tsx
@@ -164,7 +164,7 @@ const StorageRulesTable = memo(({ data, count }: StorageRulesTableProps) => {
)
}
renderContextMenu={renderContextMenu}
- title={t`Custom Rules`}
+ title={t`Storage Rules`}
/>
);
});
diff --git a/apps/erp/app/modules/storageRules/ui/StorageRulesUpgradeOverlay.tsx b/apps/erp/app/modules/storageRules/ui/StorageRulesUpgradeOverlay.tsx
index bf5467abfe..5c7afe5718 100644
--- a/apps/erp/app/modules/storageRules/ui/StorageRulesUpgradeOverlay.tsx
+++ b/apps/erp/app/modules/storageRules/ui/StorageRulesUpgradeOverlay.tsx
@@ -84,7 +84,7 @@ export default function StorageRulesUpgradeOverlay() {
</UpgradeOverlayIcon>
<UpgradeOverlayContent>
<UpgradeOverlayTitle>
- <Trans>Custom Rules</Trans>
+ <Trans>Storage Rules</Trans>
</UpgradeOverlayTitle>
<UpgradeOverlayDescription>
<Trans>
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
index 789430c3bd..34ce76833e 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-03T15:07:42.524Z",
+ "generated": "2026-06-03T15:49:36.429Z",
"totalTools": 1084,
"modules": 15,
"tools": [
diff --git a/packages/ee/src/storageRules/service.ts b/packages/ee/src/storageRules/service.ts
index 58ffb4b6ce..00912c8e26 100644
--- a/packages/ee/src/storageRules/service.ts
+++ b/packages/ee/src/storageRules/service.ts
@@ -1,4 +1,4 @@
-// Cross-app DB queries for Custom Rules. Both ERP (admin UI, item/storage
+// Cross-app DB queries for Storage Rules. Both ERP (admin UI, item/storage
// surfaces) and MES (workCenter surfaces) import from here.
//
// ERP-only admin CRUD (list/upsert/delete) stays in the ERP module — it
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index b41035c720..47a3c8f029 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -2020,9 +2020,6 @@ msgstr "Benutzerdefiniertes Feld"
msgid "Custom Fields"
msgstr "Benutzerdefinierte Felder"
-msgid "Custom Rules"
-msgstr "Benutzerdefinierte Regeln"
-
msgid "Customer"
msgstr "Kunde"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index 78a7c942b8..14b4648488 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -2020,9 +2020,6 @@ msgstr "Custom Field"
msgid "Custom Fields"
msgstr "Custom Fields"
-msgid "Custom Rules"
-msgstr "Custom Rules"
-
msgid "Customer"
msgstr "Customer"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index e40a40b141..06d2bbb716 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -2020,9 +2020,6 @@ msgstr "Campo Personalizado"
msgid "Custom Fields"
msgstr "Campos Personalizados"
-msgid "Custom Rules"
-msgstr "Reglas Personalizadas"
-
msgid "Customer"
msgstr "Cliente"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index 6ee32b0d6c..a7a7caaf75 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -2020,9 +2020,6 @@ msgstr "Champ personnalisé"
msgid "Custom Fields"
msgstr "Champs personnalisés"
-msgid "Custom Rules"
-msgstr "Règles personnalisées"
-
msgid "Customer"
msgstr "Client"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index 14b14626c0..2bbe8b8a78 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -2020,9 +2020,6 @@ msgstr "कस्टम फील्ड"
msgid "Custom Fields"
msgstr "कस्टम फील्ड्स"
-msgid "Custom Rules"
-msgstr "कस्टम नियम"
-
msgid "Customer"
msgstr "ग्राहक"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 49f4372a5f..38780b83fd 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -2020,9 +2020,6 @@ msgstr "Campo Personalizzato"
msgid "Custom Fields"
msgstr "Campi Personalizzati"
-msgid "Custom Rules"
-msgstr "Regole Personalizzate"
-
msgid "Customer"
msgstr "Cliente"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index 7c21a83a67..fa0a10441b 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -2020,9 +2020,6 @@ msgstr "カスタムフィールド"
msgid "Custom Fields"
msgstr "カスタムフィールド"
-msgid "Custom Rules"
-msgstr "カスタムルール"
-
msgid "Customer"
msgstr "顧客"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index 406b1dc887..0d8c137cd8 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -2020,9 +2020,6 @@ msgstr "Pole niestandardowe"
msgid "Custom Fields"
msgstr "Pola niestandardowe"
-msgid "Custom Rules"
-msgstr "Reguły niestandardowe"
-
msgid "Customer"
msgstr "Klient"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 1eff94f536..c63352a08f 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -2020,9 +2020,6 @@ msgstr "Campo Personalizado"
msgid "Custom Fields"
msgstr "Campos Personalizados"
-msgid "Custom Rules"
-msgstr "Regras Personalizadas"
-
msgid "Customer"
msgstr "Cliente"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 8e9f427269..c03ac97b36 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -2020,9 +2020,6 @@ msgstr "Пользовательское поле"
msgid "Custom Fields"
msgstr "Пользовательские поля"
-msgid "Custom Rules"
-msgstr "Пользовательские правила"
-
msgid "Customer"
msgstr "Клиент"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index 8d3d8d1141..8cb992afd1 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -2020,9 +2020,6 @@ msgstr "自定义字段"
msgid "Custom Fields"
msgstr "自定义字段"
-msgid "Custom Rules"
-msgstr "自定义规则"
-
msgid "Customer"
msgstr "客户"
diff --git a/packages/utils/src/storageRules.test.ts b/packages/utils/src/storageRules.test.ts
index 02aee781ce..278e82f4ce 100644
--- a/packages/utils/src/storageRules.test.ts
+++ b/packages/utils/src/storageRules.test.ts
@@ -299,6 +299,64 @@ describe("interpolateMessage", () => {
it("does not match malformed tokens", () => {
expect(interpolateMessage("{nope", {})).toBe("{nope");
});
+
+ it("condition[N].value renders the raw value, not the label", () => {
+ expect(
+ interpolateMessage(
+ "{condition[0].value}",
+ {},
+ {
+ conditions: [
+ { field: "storageUnit.storageTypeId", op: "eq", value: "cold-id" }
+ ],
+ resolveConditionValue: () => "Cold storage"
+ }
+ )
+ ).toBe("cold-id");
+ });
+
+ it("condition[N].name resolves the value to its label", () => {
+ expect(
+ interpolateMessage(
+ "{condition[0].name}",
+ {},
+ {
+ conditions: [
+ { field: "storageUnit.storageTypeId", op: "eq", value: "cold-id" }
+ ],
+ resolveConditionValue: () => "Cold storage"
+ }
+ )
+ ).toBe("Cold storage");
+ });
+
+ it("condition[N].name falls back to the raw value when unresolved", () => {
+ expect(
+ interpolateMessage(
+ "{condition[0].name}",
+ {},
+ {
+ conditions: [{ field: "transaction.quantity", op: "lt", value: 1000 }]
+ }
+ )
+ ).toBe("1000");
+ });
+
+ it("value and name render em-dash for set/not-set operators", () => {
+ const conditions = [
+ { field: "storageUnit.storageTypeId", op: "isSet" as const }
+ ];
+ expect(
+ interpolateMessage(
+ "{condition[0].value}/{condition[0].name}",
+ {},
+ {
+ conditions,
+ resolveConditionValue: () => "ignored"
+ }
+ )
+ ).toBe("—/—");
+ });
});
describe("evaluateRules", () => {
diff --git a/packages/utils/src/storageRules.ts b/packages/utils/src/storageRules.ts
index 2c26a62269..721d19a64c 100644
--- a/packages/utils/src/storageRules.ts
+++ b/packages/utils/src/storageRules.ts
@@ -1,4 +1,4 @@
-// Custom Rules evaluator. AST → JIT-compiled closure with LRU cache.
+// Storage Rules evaluator. AST → JIT-compiled closure with LRU cache.
// Used server-side on transactions (receipt, shipment, stock transfer,
// inventory adjustment, place, pick, operation start/finish, material
// issue/receive) to enforce per-entity validation/guideline rules.
@@ -342,9 +342,9 @@ export const __storageRulesCacheSize = (): number => cache.size;
// ---------------------------------------------------------------------------
const TOKEN_RE =
- /\{(condition\[\d+\]\.(?:field|operator|value)|[a-zA-Z_][\w.]*)\}/g;
+ /\{(condition\[\d+\]\.(?:field|operator|value|name)|[a-zA-Z_][\w.]*)\}/g;
-const CONDITION_TOKEN_RE = /^condition\[(\d+)\]\.(field|operator|value)$/;
+const CONDITION_TOKEN_RE = /^condition\[(\d+)\]\.(field|operator|value|name)$/;
const OPERATOR_LABELS: Record<Operator, string> = {
eq: "equals",
@@ -384,7 +384,7 @@ export const interpolateMessage = (
const condMatch = CONDITION_TOKEN_RE.exec(raw);
if (condMatch) {
const idx = Number(condMatch[1]);
- const prop = condMatch[2] as "field" | "operator" | "value";
+ const prop = condMatch[2] as "field" | "operator" | "value" | "name";
const cond = conditions?.[idx];
if (!cond) return "—";
switch (prop) {
@@ -393,6 +393,14 @@ export const interpolateMessage = (
case "operator":
return OPERATOR_LABELS[cond.op] ?? cond.op;
case "value":
+ // Raw stored id / input value, no label resolution. Use `.name`
+ // for the human-readable label.
+ if (cond.op === "isSet" || cond.op === "isNotSet") return "—";
+ return formatConditionValue(cond.value);
+ case "name":
+ // Human-readable label for the value (e.g. id → name via the
+ // field's value-options loader). Falls back to the raw value when
+ // no resolver is supplied or the id has no matching label.
if (cond.op === "isSet" || cond.op === "isNotSet") return "—";
if (resolveConditionValue) {
const resolved = resolveConditionValue(cond, idx);