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.

feat: add material type to configurator

Brad Barbin365307b43c08
diff --git a/apps/erp/app/components/Configurator/ConfigurationEditor/ConfigurationEditor.ee.tsx b/apps/erp/app/components/Configurator/ConfigurationEditor/ConfigurationEditor.ee.tsx
index 09bcfba5b6..2964399c8c 100644
--- a/apps/erp/app/components/Configurator/ConfigurationEditor/ConfigurationEditor.ee.tsx
+++ b/apps/erp/app/components/Configurator/ConfigurationEditor/ConfigurationEditor.ee.tsx
@@ -241,14 +241,18 @@ export default function Configurator({
try {
// Create parameters object from the panel
const parametersObj = parameters.reduce((acc, v) => {
- acc[v.name] =
- v.type === "numeric"
- ? Number(v.value)
- : v.type === "boolean"
- ? v.value === "true"
- : v.value;
+ if (v.type === "material") {
+ acc[v.name] = v.value;
+ } else {
+ acc[v.name] =
+ v.type === "numeric"
+ ? Number(v.value)
+ : v.type === "boolean"
+ ? v.value === "true"
+ : v.value;
+ }
return acc;
- }, {} as Record<string, string | number | boolean>);
+ }, {} as Record<string, any>);
// Execute the code
const fn = new Function(
diff --git a/apps/erp/app/components/Configurator/ConfigurationEditor/ParameterPanel.ee.tsx b/apps/erp/app/components/Configurator/ConfigurationEditor/ParameterPanel.ee.tsx
index 9cb173d8da..461dd261be 100644
--- a/apps/erp/app/components/Configurator/ConfigurationEditor/ParameterPanel.ee.tsx
+++ b/apps/erp/app/components/Configurator/ConfigurationEditor/ParameterPanel.ee.tsx
@@ -1,5 +1,5 @@
import { ConfiguratorDataTypeIcon } from "../Icons";
-import type { Parameter } from "../types";
+import type { MaterialValue, Parameter } from "../types";
interface ParameterPanelProps {
parameters: Parameter[];
@@ -10,12 +10,31 @@ export default function ParameterPanel({
parameters,
onChange,
}: ParameterPanelProps) {
- const updateValue = (index: number, value: string) => {
+ const updateValue = (index: number, value: string | MaterialValue) => {
const newParameters = [...parameters];
newParameters[index] = { ...newParameters[index], value };
onChange(newParameters);
};
+ const updateMaterialProperty = (
+ index: number,
+ property: keyof MaterialValue,
+ value: string | null
+ ) => {
+ const newParameters = [...parameters];
+ const param = newParameters[index];
+ if (param.type === "material" && typeof param.value === "object") {
+ newParameters[index] = {
+ ...param,
+ value: {
+ ...(param.value as MaterialValue),
+ [property]: value || null,
+ },
+ };
+ onChange(newParameters);
+ }
+ };
+
return (
<div className="flex-1 p-4 overflow-y-auto text-sm">
<h3 className="text-lg font-semibold mb-4">Parameters</h3>
@@ -31,50 +50,97 @@ export default function ParameterPanel({
{parameters
.sort((a, b) => a.name.localeCompare(b.name))
- .map((parameter, index) => (
- <div
- key={parameter.name}
- className="grid grid-cols-2 border-b last:border-b-0 hover:bg-accent"
- >
- <div className="px-4 py-2 border-r flex items-center gap-2 min-w-[140px]">
- <ConfiguratorDataTypeIcon type={parameter.type} />
- <span className="text-sm font-medium text-foreground">
- {parameter.name}
- </span>
- </div>
- <div className="px-2 py-1">
- {parameter.type === "boolean" ? (
- <select
- value={parameter.value}
- onChange={(e) => updateValue(index, e.target.value)}
- className="w-full h-full px-2 bg-transparent border-0 focus:ring-0"
- >
- <option value="true">true</option>
- <option value="false">false</option>
- </select>
- ) : parameter.type === "list" && parameter.config?.options ? (
- <select
- value={parameter.value}
- onChange={(e) => updateValue(index, e.target.value)}
- className="w-full h-full px-2 bg-transparent border-0 focus:ring-0"
- >
- {parameter.config.options.map((option) => (
- <option key={option} value={option}>
- {option}
- </option>
- ))}
- </select>
- ) : (
- <input
- type={parameter.type === "numeric" ? "number" : "text"}
- value={parameter.value}
- onChange={(e) => updateValue(index, e.target.value)}
- className="w-full h-full px-2 bg-transparent border-0 focus:ring-0"
- />
- )}
+ .map((parameter, index) => {
+ if (parameter.type === "material") {
+ const materialValue = parameter.value as MaterialValue;
+ const materialProperties = [
+ { key: "id", value: materialValue.id },
+ { key: "materialFormId", value: materialValue.materialFormId },
+ {
+ key: "materialSubstanceId",
+ value: materialValue.materialSubstanceId,
+ },
+ { key: "materialTypeId", value: materialValue.materialTypeId },
+ { key: "dimensionId", value: materialValue.dimensionId },
+ { key: "finishId", value: materialValue.finishId },
+ { key: "gradeId", value: materialValue.gradeId },
+ ];
+
+ return materialProperties.map((prop) => (
+ <div
+ key={`${parameter.name}.${prop.key}`}
+ className="grid grid-cols-2 border-b last:border-b-0 hover:bg-accent"
+ >
+ <div className="px-4 py-2 border-r flex items-center gap-2 min-w-[140px] overflow-hidden">
+ <ConfiguratorDataTypeIcon type={parameter.type} />
+ <span className="text-sm font-medium text-foreground truncate">
+ {parameter.name}.{prop.key}
+ </span>
+ </div>
+ <div className="px-2 py-1 overflow-hidden">
+ <input
+ type="text"
+ value={prop.value || ""}
+ onChange={(e) =>
+ updateMaterialProperty(
+ index,
+ prop.key as keyof MaterialValue,
+ e.target.value
+ )
+ }
+ className="w-full h-full px-2 bg-transparent border-0 focus:ring-0 truncate"
+ placeholder={prop.key}
+ />
+ </div>
+ </div>
+ ));
+ }
+
+ return (
+ <div
+ key={parameter.name}
+ className="grid grid-cols-2 border-b last:border-b-0 hover:bg-accent"
+ >
+ <div className="px-4 py-2 border-r flex items-center gap-2 min-w-[140px] overflow-hidden">
+ <ConfiguratorDataTypeIcon type={parameter.type} />
+ <span className="text-sm font-medium text-foreground truncate">
+ {parameter.name}
+ </span>
+ </div>
+ <div className="px-2 py-1 overflow-hidden">
+ {parameter.type === "boolean" ? (
+ <select
+ value={parameter.value as string}
+ onChange={(e) => updateValue(index, e.target.value)}
+ className="w-full h-full px-2 bg-transparent border-0 focus:ring-0 truncate"
+ >
+ <option value="true">true</option>
+ <option value="false">false</option>
+ </select>
+ ) : parameter.type === "list" && parameter.config?.options ? (
+ <select
+ value={parameter.value as string}
+ onChange={(e) => updateValue(index, e.target.value)}
+ className="w-full h-full px-2 bg-transparent border-0 focus:ring-0 truncate"
+ >
+ {parameter.config.options.map((option) => (
+ <option key={option} value={option}>
+ {option}
+ </option>
+ ))}
+ </select>
+ ) : (
+ <input
+ type={parameter.type === "numeric" ? "number" : "text"}
+ value={parameter.value as string}
+ onChange={(e) => updateValue(index, e.target.value)}
+ className="w-full h-full px-2 bg-transparent border-0 focus:ring-0 truncate"
+ />
+ )}
+ </div>
</div>
- </div>
- ))}
+ );
+ })}
</div>
</div>
);
diff --git a/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx b/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
index ab12e397ad..dcee863950 100644
--- a/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
+++ b/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
@@ -2,6 +2,7 @@ import {
Alert,
AlertTitle,
Button,
+ Combobox,
Input,
Label,
Modal,
@@ -31,10 +32,12 @@ import { zfd } from "zod-form-data";
import type {
ConfigurationParameter,
ConfigurationParameterGroup,
+ MaterialConfigurationData,
} from "~/modules/items/types";
+import { useMaterials } from "~/stores/items";
interface FormData {
- [key: string]: string | number | boolean;
+ [key: string]: string | number | boolean | MaterialConfigurationData;
}
interface ParameterFieldProps {
@@ -59,6 +62,10 @@ function getParameterSchema(parameter: ConfigurationParameter) {
});
case "boolean":
return z.boolean();
+ case "material":
+ return z.string({
+ required_error: `${parameter.label} is required`,
+ });
default:
return z.any();
}
@@ -75,6 +82,7 @@ function generateConfigurationSchema(parameters: ConfigurationParameter[]) {
function ParameterField({ parameter }: ParameterFieldProps) {
const { formData, setFormData } = useConfigurator();
+ const materials = useMaterials();
const handleChange = (value: string | number | boolean) => {
setFormData({ ...formData, [parameter.key]: value });
@@ -172,6 +180,28 @@ function ParameterField({ parameter }: ParameterFieldProps) {
</div>
);
+ case "material":
+ return (
+ <div className="space-y-2">
+ <Label
+ className="text-xs text-muted-foreground"
+ htmlFor={parameter.key}
+ >
+ {parameter.label}
+ </Label>
+ <Combobox
+ id={parameter.key}
+ options={materials.map((material) => ({
+ label: material.name,
+ value: material.id,
+ helper: material.readableIdWithRevision,
+ }))}
+ value={formData[parameter.key] as string}
+ onChange={(value) => handleChange(value)}
+ />
+ </div>
+ );
+
default:
return null;
}
diff --git a/apps/erp/app/components/Configurator/Icons.tsx b/apps/erp/app/components/Configurator/Icons.tsx
index ef3a6a5ab7..142f20199e 100644
--- a/apps/erp/app/components/Configurator/Icons.tsx
+++ b/apps/erp/app/components/Configurator/Icons.tsx
@@ -1,5 +1,6 @@
import { cn } from "@carbon/react";
import {
+ LuAtom,
LuCalendar,
LuHash,
LuList,
@@ -29,6 +30,8 @@ export function ConfiguratorDataTypeIcon({
return <LuList className={cn("w-4 h-4 text-orange-600", className)} />;
case "date":
return <LuCalendar className={cn("w-4 h-4 text-red-600", className)} />;
+ case "material":
+ return <LuAtom className={cn("w-4 h-4 text-yellow-600", className)} />;
default:
return null;
}
diff --git a/apps/erp/app/components/Configurator/types.ts b/apps/erp/app/components/Configurator/types.ts
index b30bef0133..60c1aa6ad5 100644
--- a/apps/erp/app/components/Configurator/types.ts
+++ b/apps/erp/app/components/Configurator/types.ts
@@ -12,7 +12,8 @@ export type ConfiguratorDataType =
| "numeric"
| "text"
| "enum"
- | "date";
+ | "date"
+ | "material";
export type BatchPropertyDataType = ConfiguratorDataType | "date";
@@ -20,11 +21,21 @@ export interface ListTypeConfig {
options: string[];
}
+export interface MaterialValue {
+ id: string;
+ materialFormId: string | null;
+ materialSubstanceId: string | null;
+ materialTypeId: string | null;
+ dimensionId: string | null;
+ finishId: string | null;
+ gradeId: string | null;
+}
+
export interface Parameter {
config?: ListTypeConfig;
name: string;
type: ConfiguratorDataType;
- value: string;
+ value: string | MaterialValue;
}
export type ParameterInput = {
@@ -50,4 +61,5 @@ export const typeMap: TypeMap = {
text: "string",
enum: "string",
date: "string",
+ material: "object",
};
diff --git a/apps/erp/app/components/Configurator/utils.ts b/apps/erp/app/components/Configurator/utils.ts
index cb94fda8c5..d08627a816 100644
--- a/apps/erp/app/components/Configurator/utils.ts
+++ b/apps/erp/app/components/Configurator/utils.ts
@@ -6,6 +6,9 @@ import {
type ReturnType,
} from "./types";
+const MATERIAL_TYPE =
+ "{ id: string; materialFormId: string | null; materialSubstanceId: string | null; materialTypeId: string | null; dimensionId: string | null; finishId: string | null; gradeId: string | null; }";
+
export function configureMonaco(monaco: typeof Monaco) {
// Configure JavaScript defaults
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
@@ -24,84 +27,143 @@ export function configureMonaco(monaco: typeof Monaco) {
});
}
+function getParameterTypeString(parameter: Parameter): string {
+ if (parameter.type === "list" && parameter.config?.options) {
+ const unionType = parameter.config.options
+ .map((opt) => `"${opt}"`)
+ .join(" | ");
+ return ` * @param params.${parameter.name}: ${unionType}`;
+ }
+
+ if (parameter.type === "enum") {
+ return ` * @param params.${
+ parameter.name
+ }: ${parameter.config?.options?.join(" | ")}`;
+ }
+
+ if (parameter.type === "material") {
+ return ` * @param params.${parameter.name}: ${MATERIAL_TYPE}`;
+ }
+
+ return ` * @param params.${parameter.name}: ${typeMap[parameter.type]}`;
+}
+
+function getReturnTypeString(returnType: ReturnType): string {
+ if (returnType.type === "list" && returnType.listOptions) {
+ return `Array<${returnType.listOptions
+ .map((opt) => `"${opt}"`)
+ .join(" | ")}>`;
+ }
+
+ if (returnType.type === "enum" && returnType.listOptions) {
+ return returnType.listOptions.map((opt) => `"${opt}"`).join(" | ");
+ }
+
+ if (returnType.type === "material") {
+ return MATERIAL_TYPE;
+ }
+
+ return typeMap[returnType.type];
+}
+
+function getReturnComment(returnType: ReturnType): string {
+ if (returnType.type === "list") {
+ return "an array of predefined values";
+ }
+
+ if (returnType.type === "material") {
+ return "a material object";
+ }
+
+ return `a ${returnType.type} value`;
+}
+
+function getReturnHelperText(returnType: ReturnType): string {
+ if (returnType.helperText) {
+ return returnType.helperText;
+ }
+
+ if (returnType.type === "list") {
+ return `an array containing any of: [${returnType.listOptions
+ ?.map((opt) => `"${opt}"`)
+ .join(", ")}]`;
+ }
+
+ if (returnType.type === "enum" && returnType.listOptions) {
+ return `one of: ${returnType.listOptions
+ .map((opt) => `"${opt}"`)
+ .join(" | ")}`;
+ }
+
+ if (returnType.type === "material") {
+ return "a material object";
+ }
+
+ return `a ${returnType.type} value`;
+}
+
+function getDefaultReturnValue(
+ returnType: ReturnType,
+ defaultValue?: string | number | boolean | string[] | null
+): string {
+ switch (returnType.type) {
+ case "text":
+ return defaultValue ? `"${defaultValue}"` : '"test"';
+ case "numeric":
+ return defaultValue?.toString() ?? "1";
+ case "boolean":
+ return defaultValue?.toString() ?? "true";
+ case "enum":
+ return `"${defaultValue ?? returnType.listOptions?.[0]}"`;
+ case "material":
+ return `{
+ id: "",
+ materialFormId: null,
+ materialSubstanceId: null,
+ materialTypeId: null,
+ dimensionId: null,
+ finishId: null,
+ gradeId: null,
+ }`;
+ case "list":
+ return returnType.listOptions
+ ? `[${returnType.listOptions.map((opt) => `"${opt}"`).join(", ")}]`
+ : "[]";
+ default:
+ return "[]";
+ }
+}
+
export function generateDefaultCode(
params: Parameter[],
returnType: ReturnType,
defaultCode?: string,
defaultValue?: string | number | boolean | string[] | null
): string {
- const parameterTypes = params
- .map((parameter) => {
- if (parameter.type === "list" && parameter.config?.options) {
- const unionType = parameter.config.options
- .map((opt) => `"${opt}"`)
- .join(" | ");
- return ` * @param params.${parameter.name}: ${unionType}`;
- } else if (parameter.type === "enum") {
- return ` * @param params.${
- parameter.name
- }: ${parameter.config?.options?.join(" | ")}`;
- }
- return ` * @param params.${parameter.name}: ${typeMap[parameter.type]}`;
- })
- .join("\n ");
+ const parameterTypes = params.map(getParameterTypeString).join("\n ");
- const returnTypeStr =
- returnType.type === "list" && returnType.listOptions
- ? `Array<${returnType.listOptions.map((opt) => `"${opt}"`).join(" | ")}>`
- : returnType.type === "enum" && returnType.listOptions
- ? returnType.listOptions.map((opt) => `"${opt}"`).join(" | ")
- : typeMap[returnType.type];
+ const returnTypeStr = getReturnTypeString(returnType);
+ const returnComment = getReturnComment(returnType);
+ const returnHelperText = getReturnHelperText(returnType);
+ const defaultReturnValue = getDefaultReturnValue(returnType, defaultValue);
return `
/**
* Configure function that processes the provided params
- * @returns ${
- returnType.type === "list"
- ? "an array of predefined values"
- : `a ${returnType.type} value`
- }
+ * @returns ${returnComment}
${parameterTypes}
**/
function configure(params: Params): ${returnTypeStr} {
- // return ${
- returnType.helperText
- ? returnType.helperText
- : returnType.type === "list"
- ? `an array containing any of: [${returnType.listOptions
- ?.map((opt) => `"${opt}"`)
- .join(", ")}]`
- : returnType.type === "enum" && returnType.listOptions
- ? `one of: ${returnType.listOptions.map((opt) => `"${opt}"`).join(" | ")}`
- : `a ${returnType.type} value`
- }
- ${
- defaultCode
- ? `${defaultCode}`
- : `return ${
- returnType.type === "text"
- ? defaultValue
- ? `"${defaultValue}"`
- : '"test"'
- : returnType.type === "numeric"
- ? defaultValue?.toString() ?? "1"
- : returnType.type === "boolean"
- ? defaultValue?.toString() ?? "true"
- : returnType.type === "enum" && returnType.listOptions
- ? `"${defaultValue ?? returnType.listOptions[0]}"`
- : returnType.listOptions
- ? `[${returnType.listOptions.map((opt) => `"${opt}"`).join(", ")}]`
- : "[]"
- };`
- }
+ // return ${returnHelperText}
+ ${defaultCode ? defaultCode : `return ${defaultReturnValue};`}
}`;
}
export function getDefaultValue(
type: ConfiguratorDataType,
listOptions: string[] | null
-): string {
+): string | import("./types").MaterialValue {
switch (type) {
case "numeric":
return "1";
@@ -110,9 +172,20 @@ export function getDefaultValue(
case "boolean":
return "true";
case "list":
- return listOptions ? listOptions[0] : "";
case "enum":
- return listOptions ? listOptions[0] : "";
+ return listOptions?.[0] ?? "";
+ case "material":
+ return {
+ id: "item_1234567890",
+ materialFormId: "plate",
+ materialSubstanceId: "steel",
+ materialTypeId: null,
+ dimensionId: "plate-1-4",
+ finishId: null,
+ gradeId: "steel-a36",
+ };
+ case "date":
+ return new Date().toISOString();
default:
return "";
}
@@ -124,22 +197,22 @@ export function generateTypeDefinitions(
): string {
const properties = params
.map((parameter) => {
- let typeStr = parameter.type;
+ let typeStr: string;
+
if (parameter.type === "list" && parameter.config?.options) {
- // @ts-expect-error - we know this is a list
typeStr = parameter.config.options.map((opt) => `"${opt}"`).join(" | ");
+ } else if (parameter.type === "material") {
+ typeStr = MATERIAL_TYPE;
+ } else {
+ typeStr = parameter.type;
}
+
const comment = `/** ${parameter.name} - ${parameter.type} parameter */`;
return ` ${comment}\n ${parameter.name}: ${typeStr};`;
})
.join("\n\n");
- const returnTypeStr =
- returnType.type === "list" && returnType.listOptions
- ? `Array<${returnType.listOptions.map((opt) => `"${opt}"`).join(" | ")}>`
- : returnType.type === "enum" && returnType.listOptions
- ? returnType.listOptions.map((opt) => `"${opt}"`).join(" | ")
- : returnType.type;
+ const returnTypeStr = getReturnTypeString(returnType);
return `
declare type Params = {
@@ -154,6 +227,7 @@ ${properties}
declare function configure(params: Params): ${returnTypeStr};
`;
}
+
export function convertTypescriptToJavaScript(code: string): string {
// @ts-expect-error - TypeScript compiler is loaded globally
if (window?.ts) {
diff --git a/apps/erp/app/modules/items/items.models.ts b/apps/erp/app/modules/items/items.models.ts
index 87f85ec4d6..f1238bc7c2 100644
--- a/apps/erp/app/modules/items/items.models.ts
+++ b/apps/erp/app/modules/items/items.models.ts
@@ -21,6 +21,7 @@ export const configurationParameterDataTypes = [
"numeric",
"boolean",
"list",
+ "material",
] as const;
export const itemTrackingTypes = [
diff --git a/apps/erp/app/modules/items/types.ts b/apps/erp/app/modules/items/types.ts
index 8d7c56909e..4783bfc2a1 100644
--- a/apps/erp/app/modules/items/types.ts
+++ b/apps/erp/app/modules/items/types.ts
@@ -35,6 +35,15 @@ import type {
getUnitOfMeasuresList,
} from "./items.service";
+export type MaterialConfigurationData = {
+ materialId?: string;
+ materialSubstanceId?: string;
+ materialFormId?: string;
+ materialTypeId?: string;
+ materialGradeId?: string;
+ materialFinishId?: string;
+};
+
export type ConfigurationParameter = NonNullable<
Awaited<ReturnType<typeof getConfigurationParameters>>["parameters"]
>[number];
diff --git a/apps/erp/app/modules/items/ui/MaterialDimensions/MaterialDimensionsTable.tsx b/apps/erp/app/modules/items/ui/MaterialDimensions/MaterialDimensionsTable.tsx
index 2849d22743..47aeed73e6 100644
--- a/apps/erp/app/modules/items/ui/MaterialDimensions/MaterialDimensionsTable.tsx
+++ b/apps/erp/app/modules/items/ui/MaterialDimensions/MaterialDimensionsTable.tsx
@@ -1,10 +1,11 @@
-import { Badge, MenuIcon, MenuItem } from "@carbon/react";
+import { Badge, Copy, MenuIcon, MenuItem } from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
import {
LuCircleCheck,
LuDessert,
+ LuKeySquare,
LuPencil,
LuShapes,
LuTrash,
@@ -66,7 +67,19 @@ const MaterialDimensionsTable = memo(
icon: <LuDessert />,
},
},
-
+ {
+ accessorKey: "id",
+ header: "ID",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-2">
+ <span className="font-mono text-xs">{row.original.id}</span>
+ <Copy text={row.original.id!} />
+ </div>
+ ),
+ meta: {
+ icon: <LuKeySquare />,
+ },
+ },
{
accessorKey: "companyId",
header: "Standard",
diff --git a/apps/erp/app/modules/items/ui/MaterialFinishes/MaterialFinishesTable.tsx b/apps/erp/app/modules/items/ui/MaterialFinishes/MaterialFinishesTable.tsx
index 47ab0d36ad..f610f078b5 100644
--- a/apps/erp/app/modules/items/ui/MaterialFinishes/MaterialFinishesTable.tsx
+++ b/apps/erp/app/modules/items/ui/MaterialFinishes/MaterialFinishesTable.tsx
@@ -1,4 +1,4 @@
-import { Badge, MenuIcon, MenuItem } from "@carbon/react";
+import { Badge, Copy, MenuIcon, MenuItem } from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
@@ -6,6 +6,7 @@ import {
LuCircleCheck,
LuDessert,
LuGlassWater,
+ LuKeySquare,
LuPencil,
LuTrash,
} from "react-icons/lu";
@@ -67,6 +68,19 @@ const MaterialFinishesTable = memo(
},
},
+ {
+ accessorKey: "id",
+ header: "ID",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-2">
+ <span className="font-mono text-xs">{row.original.id}</span>
+ <Copy text={row.original.id!} />
+ </div>
+ ),
+ meta: {
+ icon: <LuKeySquare />,
+ },
+ },
{
accessorKey: "companyId",
header: "Standard",
diff --git a/apps/erp/app/modules/items/ui/MaterialGrades/MaterialGradesTable.tsx b/apps/erp/app/modules/items/ui/MaterialGrades/MaterialGradesTable.tsx
index a301141519..51f1ce8cea 100644
--- a/apps/erp/app/modules/items/ui/MaterialGrades/MaterialGradesTable.tsx
+++ b/apps/erp/app/modules/items/ui/MaterialGrades/MaterialGradesTable.tsx
@@ -1,4 +1,4 @@
-import { Badge, MenuIcon, MenuItem } from "@carbon/react";
+import { Badge, Copy, MenuIcon, MenuItem } from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
@@ -6,6 +6,7 @@ import {
LuBeef,
LuCircleCheck,
LuGlassWater,
+ LuKeySquare,
LuPencil,
LuTrash,
} from "react-icons/lu";
@@ -66,7 +67,19 @@ const MaterialGradesTable = memo(
icon: <LuBeef />,
},
},
-
+ {
+ accessorKey: "id",
+ header: "ID",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-2">
+ <span className="font-mono text-xs">{row.original.id}</span>
+ <Copy text={row.original.id!} />
+ </div>
+ ),
+ meta: {
+ icon: <LuKeySquare />,
+ },
+ },
{
accessorKey: "companyId",
header: "Standard",
diff --git a/apps/erp/app/modules/items/ui/MaterialShapes/MaterialShapesTable.tsx b/apps/erp/app/modules/items/ui/MaterialShapes/MaterialShapesTable.tsx
index cd6e1ee981..a7087d894e 100644
--- a/apps/erp/app/modules/items/ui/MaterialShapes/MaterialShapesTable.tsx
+++ b/apps/erp/app/modules/items/ui/MaterialShapes/MaterialShapesTable.tsx
@@ -1,4 +1,4 @@
-import { Badge, MenuIcon, MenuItem } from "@carbon/react";
+import { Badge, Copy, MenuIcon, MenuItem } from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
@@ -6,6 +6,7 @@ import {
LuBookMarked,
LuCircleCheck,
LuCode,
+ LuKeySquare,
LuPencil,
LuTrash,
} from "react-icons/lu";
@@ -59,6 +60,19 @@ const MaterialShapesTable = memo(
icon: <LuCode />,
},
},
+ {
+ accessorKey: "id",
+ header: "ID",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-2">
+ <span className="font-mono text-xs">{row.original.id}</span>
+ <Copy text={row.original.id!} />
+ </div>
+ ),
+ meta: {
+ icon: <LuKeySquare />,
+ },
+ },
{
accessorKey: "companyId",
header: "Standard",
diff --git a/apps/erp/app/modules/items/ui/MaterialSubstances/MaterialSubstanceTable.tsx b/apps/erp/app/modules/items/ui/MaterialSubstances/MaterialSubstanceTable.tsx
index 1d5463e63e..6c6957ca25 100644
--- a/apps/erp/app/modules/items/ui/MaterialSubstances/MaterialSubstanceTable.tsx
+++ b/apps/erp/app/modules/items/ui/MaterialSubstances/MaterialSubstanceTable.tsx
@@ -1,4 +1,4 @@
-import { Badge, MenuIcon, MenuItem } from "@carbon/react";
+import { Badge, Copy, MenuIcon, MenuItem } from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
@@ -6,6 +6,7 @@ import {
LuBookMarked,
LuCircleCheck,
LuCode,
+ LuKeySquare,
LuPencil,
LuTrash,
} from "react-icons/lu";
@@ -59,6 +60,19 @@ const MaterialSubstancesTable = memo(
icon: <LuCode />,
},
},
+ {
+ accessorKey: "id",
+ header: "ID",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-2">
+ <span className="font-mono text-xs">{row.original.id}</span>
+ <Copy text={row.original.id!} />
+ </div>
+ ),
+ meta: {
+ icon: <LuKeySquare />,
+ },
+ },
{
accessorKey: "companyId",
header: "Standard",
diff --git a/apps/erp/app/modules/items/ui/MaterialTypes/MaterialTypesTable.tsx b/apps/erp/app/modules/items/ui/MaterialTypes/MaterialTypesTable.tsx
index 5f9d10865e..8b1a1343c3 100644
--- a/apps/erp/app/modules/items/ui/MaterialTypes/MaterialTypesTable.tsx
+++ b/apps/erp/app/modules/items/ui/MaterialTypes/MaterialTypesTable.tsx
@@ -1,10 +1,11 @@
-import { Badge, MenuIcon, MenuItem } from "@carbon/react";
+import { Badge, Copy, MenuIcon, MenuItem } from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
import {
LuCircleCheck,
LuGlassWater,
+ LuKeySquare,
LuPencil,
LuShapes,
LuTag,
@@ -83,6 +84,19 @@ const MaterialTypesTable = memo(({ data, count }: MaterialTypesTableProps) => {
icon: <LuTag />,
},
},
+ {
+ accessorKey: "id",
+ header: "ID",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-2">
+ <span className="font-mono text-xs">{row.original.id}</span>
+ <Copy text={row.original.id!} />
+ </div>
+ ),
+ meta: {
+ icon: <LuKeySquare />,
+ },
+ },
{
accessorKey: "companyId",
header: "Standard",
@@ -110,9 +124,7 @@ const MaterialTypesTable = memo(({ data, count }: MaterialTypesTableProps) => {
!permissions.can("update", "parts") || row.companyId === null
}
onClick={() => {
- navigate(
- `${path.to.materialType(row.id!)}?${params.toString()}`
- );
+ navigate(`${path.to.materialType(row.id!)}?${params.toString()}`);
}}
>
<MenuIcon icon={<LuPencil />} />
@@ -158,4 +170,4 @@ const MaterialTypesTable = memo(({ data, count }: MaterialTypesTableProps) => {
});
MaterialTypesTable.displayName = "MaterialTypesTable";
-export default MaterialTypesTable;
\ No newline at end of file
+export default MaterialTypesTable;
diff --git a/apps/erp/app/modules/items/ui/Parts/ConfigurationParameters.tsx b/apps/erp/app/modules/items/ui/Parts/ConfigurationParameters.tsx
index 68d2e00cd0..d4f68fed0b 100644
--- a/apps/erp/app/modules/items/ui/Parts/ConfigurationParameters.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/ConfigurationParameters.tsx
@@ -911,59 +911,115 @@ function ConfigurableParameter({
</VStack>
</ValidatedForm>
) : (
- <div className="flex flex-1 justify-between items-center w-full">
- <HStack spacing={2} className="w-1/2">
- <IconButton
- aria-label="Reorder"
- icon={<LuGripVertical />}
- variant="ghost"
- {...attributes}
- {...listeners}
- className="cursor-grab"
- />
- <HStack spacing={4} className="flex-1">
- <div className="bg-muted border rounded-full flex items-center justify-center p-2">
- <ConfiguratorDataTypeIcon
- type={parameter.dataType}
- className="w-4 h-4"
- />
- </div>
- <VStack spacing={0}>
- <span className="text-sm font-medium">{parameter.label}</span>
+ <div className="flex flex-col gap-2 w-full">
+ <div className="flex flex-1 justify-between items-center w-full">
+ <HStack spacing={2} className="w-1/2">
+ <IconButton
+ aria-label="Reorder"
+ icon={<LuGripVertical />}
+ variant="ghost"
+ {...attributes}
+ {...listeners}
+ className="cursor-grab"
+ />
+ <HStack spacing={4} className="flex-1">
+ <div className="bg-muted border rounded-full flex items-center justify-center p-2">
+ <ConfiguratorDataTypeIcon
+ type={parameter.dataType}
+ className="w-4 h-4"
+ />
+ </div>
+ <VStack spacing={0}>
+ <span className="text-sm font-medium">{parameter.label}</span>
+ <span className="text-xs text-muted-foreground">
+ {parameter.key}
+ </span>
+ </VStack>
+ </HStack>
+ </HStack>
+ <div className="flex items-center justify-end gap-2">
+ <HStack spacing={2}>
<span className="text-xs text-muted-foreground">
- {parameter.key}
+ {isUpdated ? "Updated" : "Created"} {formatRelativeTime(date)}
</span>
- </VStack>
- </HStack>
- </HStack>
- <div className="flex items-center justify-end gap-2">
- <HStack spacing={2}>
- <span className="text-xs text-muted-foreground">
- {isUpdated ? "Updated" : "Created"} {formatRelativeTime(date)}
- </span>
- <EmployeeAvatar employeeId={person} withName={false} />
- </HStack>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- aria-label="Open menu"
- icon={<LuEllipsisVertical />}
- variant="ghost"
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onClick={disclosure.onOpen}>
- Edit
- </DropdownMenuItem>
- <DropdownMenuItem
- destructive
- onClick={deleteParameterDisclosure.onOpen}
- >
- Delete
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ <EmployeeAvatar employeeId={person} withName={false} />
+ </HStack>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ aria-label="Open menu"
+ icon={<LuEllipsisVertical />}
+ variant="ghost"
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={disclosure.onOpen}>
+ Edit
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ destructive
+ onClick={deleteParameterDisclosure.onOpen}
+ >
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
</div>
+ {parameter.dataType === "material" && (
+ <div className="py-4 px-8 bg-muted/30 rounded-md">
+ <div className="grid grid-cols-1 gap-2">
+ <div>
+ <span className="text-xs text-muted-foreground">ID</span>
+ <div className="text-sm font-mono">{parameter.key}.id</div>
+ </div>
+ <div>
+ <span className="text-xs text-muted-foreground">
+ Material Form
+ </span>
+ <div className="text-sm font-mono">
+ {parameter.key}.materialFormId
+ </div>
+ </div>
+ <div>
+ <span className="text-xs text-muted-foreground">
+ Substance
+ </span>
+ <div className="text-sm font-mono">
+ {parameter.key}.materialSubstanceId
+ </div>
+ </div>
+ <div>
+ <span className="text-xs text-muted-foreground">
+ Dimension
+ </span>
+ <div className="text-sm font-mono">
+ {parameter.key}.dimensionId
+ </div>
+ </div>
+ <div>
+ <span className="text-xs text-muted-foreground">Grade</span>
+ <div className="text-sm font-mono">
+ {parameter.key}.gradeId
+ </div>
+ </div>
+ <div>
+ <span className="text-xs text-muted-foreground">Finish</span>
+ <div className="text-sm font-mono">
+ {parameter.key}.finishId
+ </div>
+ </div>
+ <div>
+ <span className="text-xs text-muted-foreground">
+ Material Type
+ </span>
+ <div className="text-sm font-mono">
+ {parameter.key}.materialTypeId
+ </div>
+ </div>
+ </div>
+ </div>
+ )}
</div>
)}
{deleteParameterDisclosure.isOpen && (
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index f50adbe0f9..015912ec2d 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -14970,6 +14970,9 @@ export default {
{
$ref: "#/parameters/rowFilter.workCenters.overheadRate",
},
+ {
+ $ref: "#/parameters/rowFilter.workCenters.tags",
+ },
{
$ref: "#/parameters/rowFilter.workCenters.locationName",
},
@@ -17103,6 +17106,12 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLines.supplierExtendedPrice",
},
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceLines.taxPercent",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceLines.jobOperationId",
+ },
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLines.unitPrice",
},
@@ -17118,12 +17127,6 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLines.totalAmount",
},
- {
- $ref: "#/parameters/rowFilter.purchaseInvoiceLines.taxPercent",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseInvoiceLines.jobOperationId",
- },
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLines.thumbnailPath",
},
@@ -22006,34 +22009,34 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrderLine.quantityToInvoice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.unitPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.supplierExtendedPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.supplierExtendedPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.taxPercent",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.extendedPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.jobId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.shippingCost",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.jobOperationId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.taxAmount",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.taxPercent",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.jobId",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.unitPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.jobOperationId",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.extendedPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.shippingCost",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.taxAmount",
},
{
$ref: "#/parameters/select",
@@ -22200,34 +22203,34 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrderLine.quantityToInvoice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.unitPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.supplierExtendedPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.supplierExtendedPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.taxPercent",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.extendedPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.jobId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.shippingCost",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.jobOperationId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.taxAmount",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.taxPercent",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.jobId",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.unitPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.jobOperationId",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.extendedPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.shippingCost",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.taxAmount",
},
{
$ref: "#/parameters/preferReturn",
@@ -22348,34 +22351,34 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrderLine.quantityToInvoice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.unitPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.supplierExtendedPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.supplierExtendedPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.taxPercent",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.extendedPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.jobId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.shippingCost",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.jobOperationId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.taxAmount",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.taxPercent",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.jobId",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.unitPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.jobOperationId",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.extendedPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.shippingCost",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.taxAmount",
},
{
$ref: "#/parameters/body.purchaseOrderLine",
@@ -27912,6 +27915,12 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.supplierExtendedPrice",
},
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceLine.taxPercent",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceLine.jobOperationId",
+ },
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.unitPrice",
},
@@ -27927,12 +27936,6 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.totalAmount",
},
- {
- $ref: "#/parameters/rowFilter.purchaseInvoiceLine.taxPercent",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseInvoiceLine.jobOperationId",
- },
{
$ref: "#/parameters/select",
},
@@ -28082,6 +28085,12 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.supplierExtendedPrice",
},
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceLine.taxPercent",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceLine.jobOperationId",
+ },
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.unitPrice",
},
@@ -28097,12 +28106,6 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.totalAmount",
},
- {
- $ref: "#/parameters/rowFilter.purchaseInvoiceLine.taxPercent",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseInvoiceLine.jobOperationId",
- },
{
$ref: "#/parameters/preferReturn",
},
@@ -28206,6 +28209,12 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.supplierExtendedPrice",
},
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceLine.taxPercent",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceLine.jobOperationId",
+ },
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.unitPrice",
},
@@ -28221,12 +28230,6 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseInvoiceLine.totalAmount",
},
- {
- $ref: "#/parameters/rowFilter.purchaseInvoiceLine.taxPercent",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseInvoiceLine.jobOperationId",
- },
{
$ref: "#/parameters/body.purchaseInvoiceLine",
},
@@ -39793,10 +39796,13 @@ export default {
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierTaxAmount",
},
{
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.unitPrice",
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierExtendedPrice",
},
{
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierExtendedPrice",
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxPercent",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.unitPrice",
},
{
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.extendedPrice",
@@ -39807,9 +39813,6 @@ export default {
{
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxAmount",
},
- {
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxPercent",
- },
{
$ref: "#/parameters/select",
},
@@ -39906,10 +39909,13 @@ export default {
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierTaxAmount",
},
{
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.unitPrice",
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierExtendedPrice",
},
{
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierExtendedPrice",
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxPercent",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.unitPrice",
},
{
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.extendedPrice",
@@ -39920,9 +39926,6 @@ export default {
{
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxAmount",
},
- {
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxPercent",
- },
{
$ref: "#/parameters/preferReturn",
},
@@ -39973,10 +39976,13 @@ export default {
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierTaxAmount",
},
{
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.unitPrice",
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierExtendedPrice",
},
{
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.supplierExtendedPrice",
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxPercent",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.unitPrice",
},
{
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.extendedPrice",
@@ -39987,9 +39993,6 @@ export default {
{
$ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxAmount",
},
- {
- $ref: "#/parameters/rowFilter.supplierQuoteLinePrice.taxPercent",
- },
{
$ref: "#/parameters/body.supplierQuoteLinePrice",
},
@@ -40881,6 +40884,9 @@ export default {
{
$ref: "#/parameters/rowFilter.processes.processType",
},
+ {
+ $ref: "#/parameters/rowFilter.processes.tags",
+ },
{
$ref: "#/parameters/rowFilter.processes.workCenters",
},
@@ -45811,34 +45817,34 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrderLines.quantityToInvoice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.unitPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.supplierExtendedPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.supplierExtendedPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.taxPercent",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.extendedPrice",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.jobId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.shippingCost",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.jobOperationId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.taxAmount",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.quantityShipped",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.taxPercent",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.promisedDate",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.jobId",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.unitPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.jobOperationId",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.extendedPrice",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.quantityShipped",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.shippingCost",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLines.promisedDate",
+ $ref: "#/parameters/rowFilter.purchaseOrderLines.taxAmount",
},
{
$ref: "#/parameters/rowFilter.purchaseOrderLines.thumbnailPath",
@@ -62794,7 +62800,7 @@ export default {
properties: {
id: {
description:
- "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -62843,7 +62849,7 @@ export default {
},
supplierLocationId: {
description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -65298,7 +65304,7 @@ export default {
type: "string",
},
dataType: {
- enum: ["text", "numeric", "boolean", "list", "date"],
+ enum: ["text", "numeric", "boolean", "list", "date", "material"],
format: 'public."configurationParameterDataType"',
type: "string",
},
@@ -66378,12 +66384,23 @@ export default {
format: "numeric",
type: "number",
},
+ tags: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
locationName: {
format: "text",
type: "string",
},
processes: {
- format: "jsonb",
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
},
},
type: "object",
@@ -67442,6 +67459,16 @@ export default {
format: "numeric",
type: "number",
},
+ taxPercent: {
+ format: "numeric",
+ type: "number",
+ },
+ jobOperationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `jobOperation.id`.<fk table='jobOperation' column='id'/>",
+ format: "text",
+ type: "string",
+ },
unitPrice: {
format: "numeric",
type: "number",
@@ -67462,16 +67489,6 @@ export default {
format: "numeric",
type: "number",
},
- taxPercent: {
- format: "numeric",
- type: "number",
- },
- jobOperationId: {
- description:
- "Note:\nThis is a Foreign Key to `jobOperation.id`.<fk table='jobOperation' column='id'/>",
- format: "text",
- type: "string",
- },
thumbnailPath: {
format: "text",
type: "string",
@@ -69509,26 +69526,10 @@ export default {
format: "numeric",
type: "number",
},
- unitPrice: {
- format: "numeric",
- type: "number",
- },
supplierExtendedPrice: {
format: "numeric",
type: "number",
},
- extendedPrice: {
- format: "numeric",
- type: "number",
- },
- shippingCost: {
- format: "numeric",
- type: "number",
- },
- taxAmount: {
- format: "numeric",
- type: "number",
- },
taxPercent: {
format: "numeric",
type: "number",
@@ -69553,6 +69554,22 @@ export default {
format: "date",
type: "string",
},
+ unitPrice: {
+ format: "numeric",
+ type: "number",
+ },
+ extendedPrice: {
+ format: "numeric",
+ type: "number",
+ },
+ shippingCost: {
+ format: "numeric",
+ type: "number",
+ },
+ taxAmount: {
+ format: "numeric",
+ type: "number",
+ },
},
type: "object",
},
@@ -72217,6 +72234,16 @@ export default {
format: "numeric",
type: "number",
},
+ taxPercent: {
+ format: "numeric",
+ type: "number",
+ },
+ jobOperationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `jobOperation.id`.<fk table='jobOperation' column='id'/>",
+ format: "text",
+ type: "string",
+ },
unitPrice: {
format: "numeric",
type: "number",
@@ -72237,16 +72264,6 @@ export default {
format: "numeric",
type: "number",
},
- taxPercent: {
- format: "numeric",
- type: "number",
- },
- jobOperationId: {
- description:
- "Note:\nThis is a Foreign Key to `jobOperation.id`.<fk table='jobOperation' column='id'/>",
- format: "text",
- type: "string",
- },
},
type: "object",
},
@@ -77931,27 +77948,27 @@ export default {
format: "numeric",
type: "number",
},
- unitPrice: {
+ supplierExtendedPrice: {
format: "numeric",
type: "number",
},
- supplierExtendedPrice: {
+ taxPercent: {
format: "numeric",
type: "number",
},
- extendedPrice: {
+ unitPrice: {
format: "numeric",
type: "number",
},
- shippingCost: {
+ extendedPrice: {
format: "numeric",
type: "number",
},
- taxAmount: {
+ shippingCost: {
format: "numeric",
type: "number",
},
- taxPercent: {
+ taxAmount: {
format: "numeric",
type: "number",
},
@@ -78007,7 +78024,7 @@ export default {
type: "string",
},
dataType: {
- enum: ["text", "numeric", "boolean", "list", "date"],
+ enum: ["text", "numeric", "boolean", "list", "date", "material"],
format: 'public."configurationParameterDataType"',
type: "string",
},
@@ -78348,8 +78365,19 @@ export default {
format: 'public."processType"',
type: "string",
},
+ tags: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
workCenters: {
- format: "jsonb",
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
},
suppliers: {
format: "jsonb",
@@ -80795,26 +80823,10 @@ export default {
format: "numeric",
type: "number",
},
- unitPrice: {
- format: "numeric",
- type: "number",
- },
supplierExtendedPrice: {
format: "numeric",
type: "number",
},
- extendedPrice: {
- format: "numeric",
- type: "number",
- },
- shippingCost: {
- format: "numeric",
- type: "number",
- },
- taxAmount: {
- format: "numeric",
- type: "number",
- },
taxPercent: {
format: "numeric",
type: "number",
@@ -80839,6 +80851,22 @@ export default {
format: "date",
type: "string",
},
+ unitPrice: {
+ format: "numeric",
+ type: "number",
+ },
+ extendedPrice: {
+ format: "numeric",
+ type: "number",
+ },
+ shippingCost: {
+ format: "numeric",
+ type: "number",
+ },
+ taxAmount: {
+ format: "numeric",
+ type: "number",
+ },
thumbnailPath: {
format: "text",
type: "string",
@@ -83782,7 +83810,7 @@ export default {
],
properties: {
id: {
- default: "public.id('cf'::text)",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -92726,6 +92754,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.workCenters.tags": {
+ name: "tags",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.workCenters.locationName": {
name: "locationName",
required: false,
@@ -93896,6 +93930,18 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.purchaseInvoiceLines.taxPercent": {
+ name: "taxPercent",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.purchaseInvoiceLines.jobOperationId": {
+ name: "jobOperationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.purchaseInvoiceLines.unitPrice": {
name: "unitPrice",
required: false,
@@ -93926,18 +93972,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseInvoiceLines.taxPercent": {
- name: "taxPercent",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.purchaseInvoiceLines.jobOperationId": {
- name: "jobOperationId",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.purchaseInvoiceLines.thumbnailPath": {
name: "thumbnailPath",
required: false,
@@ -96287,62 +96321,62 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.unitPrice": {
- name: "unitPrice",
+ "rowFilter.purchaseOrderLine.supplierExtendedPrice": {
+ name: "supplierExtendedPrice",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.supplierExtendedPrice": {
- name: "supplierExtendedPrice",
+ "rowFilter.purchaseOrderLine.taxPercent": {
+ name: "taxPercent",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.extendedPrice": {
- name: "extendedPrice",
+ "rowFilter.purchaseOrderLine.jobId": {
+ name: "jobId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.shippingCost": {
- name: "shippingCost",
+ "rowFilter.purchaseOrderLine.jobOperationId": {
+ name: "jobOperationId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.taxAmount": {
- name: "taxAmount",
+ "rowFilter.purchaseOrderLine.quantityShipped": {
+ name: "quantityShipped",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.taxPercent": {
- name: "taxPercent",
+ "rowFilter.purchaseOrderLine.promisedDate": {
+ name: "promisedDate",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.jobId": {
- name: "jobId",
+ "rowFilter.purchaseOrderLine.unitPrice": {
+ name: "unitPrice",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.jobOperationId": {
- name: "jobOperationId",
+ "rowFilter.purchaseOrderLine.extendedPrice": {
+ name: "extendedPrice",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.quantityShipped": {
- name: "quantityShipped",
+ "rowFilter.purchaseOrderLine.shippingCost": {
+ name: "shippingCost",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLine.promisedDate": {
- name: "promisedDate",
+ "rowFilter.purchaseOrderLine.taxAmount": {
+ name: "taxAmount",
required: false,
in: "query",
type: "string",
@@ -99275,6 +99309,18 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.purchaseInvoiceLine.taxPercent": {
+ name: "taxPercent",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.purchaseInvoiceLine.jobOperationId": {
+ name: "jobOperationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.purchaseInvoiceLine.unitPrice": {
name: "unitPrice",
required: false,
@@ -99305,18 +99351,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseInvoiceLine.taxPercent": {
- name: "taxPercent",
- required: false,
- in: "query",
- type: "string",
- },
- "rowFilter.purchaseInvoiceLine.jobOperationId": {
- name: "jobOperationId",
- required: false,
- in: "query",
- type: "string",
- },
"body.materialForm": {
name: "materialForm",
description: "materialForm",
@@ -105827,14 +105861,20 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.supplierQuoteLinePrice.unitPrice": {
- name: "unitPrice",
+ "rowFilter.supplierQuoteLinePrice.supplierExtendedPrice": {
+ name: "supplierExtendedPrice",
required: false,
in: "query",
type: "string",
},
- "rowFilter.supplierQuoteLinePrice.supplierExtendedPrice": {
- name: "supplierExtendedPrice",
+ "rowFilter.supplierQuoteLinePrice.taxPercent": {
+ name: "taxPercent",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplierQuoteLinePrice.unitPrice": {
+ name: "unitPrice",
required: false,
in: "query",
type: "string",
@@ -105857,12 +105897,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.supplierQuoteLinePrice.taxPercent": {
- name: "taxPercent",
- required: false,
- in: "query",
- type: "string",
- },
"body.purchaseOrderSuppliers": {
name: "purchaseOrderSuppliers",
description: "purchaseOrderSuppliers",
@@ -106283,6 +106317,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.processes.tags": {
+ name: "tags",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.processes.workCenters": {
name: "workCenters",
required: false,
@@ -109058,62 +109098,62 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.unitPrice": {
- name: "unitPrice",
+ "rowFilter.purchaseOrderLines.supplierExtendedPrice": {
+ name: "supplierExtendedPrice",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.supplierExtendedPrice": {
- name: "supplierExtendedPrice",
+ "rowFilter.purchaseOrderLines.taxPercent": {
+ name: "taxPercent",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.extendedPrice": {
- name: "extendedPrice",
+ "rowFilter.purchaseOrderLines.jobId": {
+ name: "jobId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.shippingCost": {
- name: "shippingCost",
+ "rowFilter.purchaseOrderLines.jobOperationId": {
+ name: "jobOperationId",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.taxAmount": {
- name: "taxAmount",
+ "rowFilter.purchaseOrderLines.quantityShipped": {
+ name: "quantityShipped",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.taxPercent": {
- name: "taxPercent",
+ "rowFilter.purchaseOrderLines.promisedDate": {
+ name: "promisedDate",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.jobId": {
- name: "jobId",
+ "rowFilter.purchaseOrderLines.unitPrice": {
+ name: "unitPrice",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.jobOperationId": {
- name: "jobOperationId",
+ "rowFilter.purchaseOrderLines.extendedPrice": {
+ name: "extendedPrice",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.quantityShipped": {
- name: "quantityShipped",
+ "rowFilter.purchaseOrderLines.shippingCost": {
+ name: "shippingCost",
required: false,
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLines.promisedDate": {
- name: "promisedDate",
+ "rowFilter.purchaseOrderLines.taxAmount": {
+ name: "taxAmount",
required: false,
in: "query",
type: "string",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 2456ee4bf8..6126e61062 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -43916,14 +43916,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -47430,6 +47430,7 @@ export type Database = {
| "boolean"
| "list"
| "date"
+ | "material"
costLedgerType:
| "Direct Cost"
| "Revaluation"
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index 2ebd2b5136..3876c48b23 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -301,6 +301,13 @@ serve(async (req: Request) => {
throw new Error("Failed to get related work centers");
}
+ const hydratedConfiguration = await hydrateConfiguration(
+ client,
+ configuration,
+ itemId,
+ companyId
+ );
+
const [methodTrees, configurationRules] = await Promise.all([
getMethodTree(client, makeMethod.data.id!),
isConfigured
@@ -372,7 +379,7 @@ serve(async (req: Request) => {
const mod = await importTypeScript(
configurationCodeByField[fieldKey]
);
- const result = await mod.configure(configuration);
+ const result = await mod.configure(hydratedConfiguration);
return (result ?? defaultValue) as T;
} catch (err) {
console.error(err);
@@ -517,7 +524,7 @@ serve(async (req: Request) => {
const mod = await importTypeScript(
configurationCodeByField[bopConfigurationKey]
);
- bopConfiguration = await mod.configure(configuration);
+ bopConfiguration = await mod.configure(hydratedConfiguration);
}
if (bopConfiguration) {
@@ -756,7 +763,7 @@ serve(async (req: Request) => {
const mod = await importTypeScript(
configurationCodeByField[bomConfigurationKey]
);
- bomConfiguration = await mod.configure(configuration);
+ bomConfiguration = await mod.configure(hydratedConfiguration);
}
if (bomConfiguration) {
@@ -1179,6 +1186,13 @@ serve(async (req: Request) => {
throw new Error("Failed to get related work centers");
}
+ const hydratedConfiguration = await hydrateConfiguration(
+ client,
+ configuration,
+ itemId,
+ companyId
+ );
+
const [methodTrees] = await Promise.all([
getMethodTree(client, makeMethod.data.id!),
]);
@@ -1243,7 +1257,7 @@ serve(async (req: Request) => {
try {
const code = configurationCodeByField[fieldKey];
const mod = await importTypeScript(code);
- const result = await mod.configure(configuration);
+ const result = await mod.configure(hydratedConfiguration);
return (result ?? defaultValue) as T;
} catch (err) {
@@ -1392,7 +1406,7 @@ serve(async (req: Request) => {
const mod = await importTypeScript(
configurationCodeByField[bopConfigurationKey]
);
- bopConfiguration = await mod.configure(configuration);
+ bopConfiguration = await mod.configure(hydratedConfiguration);
}
if (bopConfiguration) {
@@ -1617,7 +1631,7 @@ serve(async (req: Request) => {
const mod = await importTypeScript(
configurationCodeByField[bomConfigurationKey]
);
- bomConfiguration = await mod.configure(configuration);
+ bomConfiguration = await mod.configure(hydratedConfiguration);
}
if (bomConfiguration) {
@@ -4603,3 +4617,96 @@ async function insertProcedureDataForJobOperation(
.where("id", "=", operationId)
.execute();
}
+
+async function hydrateConfiguration(
+ client: SupabaseClient<Database>,
+ configuration: Record<string, unknown> | undefined,
+ itemId: string | undefined | null,
+ companyId: string
+): Promise<Record<string, unknown> | undefined> {
+ try {
+ if (!configuration || !itemId || Object.keys(configuration).length === 0) {
+ return configuration;
+ }
+
+ const materialParams = await client
+ .from("configurationParameter")
+ .select("key")
+ .eq("itemId", itemId)
+ .eq("companyId", companyId)
+ .eq("dataType", "material");
+
+ if (materialParams.error) return configuration;
+
+ const materialKeys = new Set((materialParams.data ?? []).map((p) => p.key));
+
+ if (materialKeys.size === 0) return configuration;
+
+ const entries = Object.entries(configuration).filter(
+ ([key, value]) =>
+ materialKeys.has(key) && typeof value === "string" && value
+ );
+
+ if (entries.length === 0) return configuration;
+
+ const itemIds = entries.map(([, value]) => value as string);
+
+ // Get items that correspond to the item IDs
+ const items = await client
+ .from("item")
+ .select("id, readableId")
+ .in("id", itemIds)
+ .eq("companyId", companyId);
+
+ if (items.error) return configuration;
+
+ // Create map of itemId to readableId (which is the materialId)
+ const itemIdToMaterialId = new Map(
+ items.data?.map((i) => [i.id, i.readableId]) ?? []
+ );
+
+ const materialIds = items.data?.map((i) => i.readableId) ?? [];
+
+ // Get material details using the readableIds (which are the material IDs)
+ const materials = await client
+ .from("material")
+ .select(
+ "id, materialFormId, materialSubstanceId, materialTypeId, dimensionId, finishId, gradeId"
+ )
+ .in("id", materialIds)
+ .eq("companyId", companyId);
+
+ if (materials.error) return configuration;
+
+ const materialsByMaterialId = new Map(
+ materials.data?.map((m) => [m.id, m]) ?? []
+ );
+
+ const transformed: Record<string, unknown> = { ...configuration };
+
+ for (const [key, value] of entries) {
+ const itemId = value as string;
+ const materialId = itemIdToMaterialId.get(itemId);
+
+ if (materialId) {
+ const material = materialsByMaterialId.get(materialId);
+ if (material) {
+ transformed[key] = {
+ id: itemId,
+ materialFormId: material.materialFormId ?? null,
+ materialSubstanceId: material.materialSubstanceId ?? null,
+ materialTypeId: material.materialTypeId ?? null,
+ dimensionId: material.dimensionId ?? null,
+ finishId: material.finishId ?? null,
+ gradeId: material.gradeId ?? null,
+ };
+ }
+ }
+ }
+
+ return transformed;
+ } catch (err) {
+ console.error(err);
+ return configuration;
+ }
+}
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 2456ee4bf8..6126e61062 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -43916,14 +43916,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -47430,6 +47430,7 @@ export type Database = {
| "boolean"
| "list"
| "date"
+ | "material"
costLedgerType:
| "Direct Cost"
| "Revaluation"
diff --git a/packages/database/supabase/migrations/20250809000000_add-material-configurator-type.sql b/packages/database/supabase/migrations/20250809000000_add-material-configurator-type.sql
new file mode 100644
index 0000000000..9da4f7d3f3
--- /dev/null
+++ b/packages/database/supabase/migrations/20250809000000_add-material-configurator-type.sql
@@ -0,0 +1,3 @@
+-- Add 'material' to the configurationParameterDataType enum
+ALTER TYPE "configurationParameterDataType" ADD VALUE 'material';
+