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.

- UI and functionality improvements

Gaurav Bhattdc791b32932d
diff --git a/apps/erp/app/components/ImportCSVModal/FieldMappings.tsx b/apps/erp/app/components/ImportCSVModal/FieldMappings.tsx
index b2dc90b6a0..b33f8e67c2 100644
--- a/apps/erp/app/components/ImportCSVModal/FieldMappings.tsx
+++ b/apps/erp/app/components/ImportCSVModal/FieldMappings.tsx
@@ -432,7 +432,14 @@ function EnumMappingStep({
if (error) {
toast.error(error.message);
} else {
- setOptions(data.map((item) => ({ label: item.name, value: item.id })));
+ // Use email as label when present (employees) so auto-match keys on
+ // email; falls back to name for lookups without an email column.
+ setOptions(
+ data.map((item) => ({
+ label: item.email ?? item.name,
+ value: item.id
+ }))
+ );
}
}
}, [enumData, carbon, company.id]);
@@ -444,6 +451,25 @@ function EnumMappingStep({
}
}, [enumData, carbon, company.id, fetchOptions]);
+ // Auto-match CSV values to options once when options become available.
+ // Ref guard prevents clobbering user edits on re-render.
+ const autoMatchedRef = useRef(false);
+ // biome-ignore lint/correctness/useExhaustiveDependencies: one-shot effect
+ useEffect(() => {
+ if (autoMatchedRef.current) return;
+ if (options.length === 0 || uniqueValues.length === 0) return;
+
+ const lookup = new Map(
+ options.map((o) => [o.label.toLowerCase().trim(), o.value])
+ );
+ for (const csvValue of uniqueValues) {
+ if (mappings[csvValue]) continue;
+ const matched = lookup.get(csvValue.toLowerCase().trim());
+ if (matched) onEnumMappingChange(name, csvValue, matched);
+ }
+ autoMatchedRef.current = true;
+ }, [options, mappedColumn]);
+
return (
<div>
<div className="grid grid-cols-2 gap-4">
diff --git a/apps/erp/app/components/ImportCSVModal/ImportCSVModal.tsx b/apps/erp/app/components/ImportCSVModal/ImportCSVModal.tsx
index 4424d0f15a..a3e6b73af9 100644
--- a/apps/erp/app/components/ImportCSVModal/ImportCSVModal.tsx
+++ b/apps/erp/app/components/ImportCSVModal/ImportCSVModal.tsx
@@ -1,12 +1,11 @@
import { Hidden, ValidatedForm } from "@carbon/form";
-import { Button, Modal, ModalContent, ModalFooter, toast } from "@carbon/react";
-import Papa from "papaparse";
-import { useCallback, useEffect, useState } from "react";
+import { Modal, ModalContent, toast } from "@carbon/react";
+import { useEffect, useState } from "react";
import { flushSync } from "react-dom";
import { useFetcher } from "react-router";
import { z } from "zod";
-import { fieldMappings, importSchemas } from "~/modules/shared";
+import { type fieldMappings, importSchemas } from "~/modules/shared";
import type { action } from "~/routes/x+/shared+/import.$tableId";
import { path } from "~/utils/path";
import { AnimatedSizeContainer } from "../AnimatedSizeContainer";
@@ -58,19 +57,6 @@ export const ImportCSVModal = ({ table, onClose }: ImportCSVModalProps) => {
}
}, [file, fileColumns, page]);
- const downloadTemplate = useCallback(() => {
- const mapping = fieldMappings[table];
- const headers = Object.values(mapping).map((field) => field.label);
- const csv = Papa.unparse({ fields: headers, data: [] });
- const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
- const url = URL.createObjectURL(blob);
- const link = document.createElement("a");
- link.href = url;
- link.download = `${table}-template.csv`;
- link.click();
- URL.revokeObjectURL(url);
- }, [table]);
-
return (
<Modal
open
@@ -80,7 +66,7 @@ export const ImportCSVModal = ({ table, onClose }: ImportCSVModalProps) => {
}
}}
>
- <ModalContent>
+ <ModalContent onInteractOutside={(e) => e.preventDefault()}>
<div className="relative">
<AnimatedSizeContainer height>
<ImportCsvContext.Provider
@@ -135,13 +121,6 @@ export const ImportCSVModal = ({ table, onClose }: ImportCSVModalProps) => {
</ImportCsvContext.Provider>
</AnimatedSizeContainer>
</div>
- {page === ImportCSVPage.UploadCSV && (
- <ModalFooter>
- <Button variant="secondary" onClick={downloadTemplate}>
- Download Template
- </Button>
- </ModalFooter>
- )}
</ModalContent>
</Modal>
);
diff --git a/apps/erp/app/components/ImportCSVModal/UploadCSV.tsx b/apps/erp/app/components/ImportCSVModal/UploadCSV.tsx
index ab7ecb79c4..71b09d1e97 100644
--- a/apps/erp/app/components/ImportCSVModal/UploadCSV.tsx
+++ b/apps/erp/app/components/ImportCSVModal/UploadCSV.tsx
@@ -1,5 +1,6 @@
import { useCarbon } from "@carbon/auth";
import {
+ Button,
cn,
ModalBody,
ModalDescription,
@@ -11,11 +12,12 @@ import {
import { Trans, useLingui } from "@lingui/react/macro";
import { nanoid } from "nanoid";
import Papa from "papaparse";
-import { useState } from "react";
+import { useCallback, useState } from "react";
import { flushSync } from "react-dom";
import { useDropzone } from "react-dropzone";
+import { LuDownload, LuFileSpreadsheet } from "react-icons/lu";
import { useUser } from "~/hooks/useUser";
-import type { importSchemas } from "~/modules/shared";
+import { fieldMappings, type importSchemas } from "~/modules/shared";
import { useCsvContext } from "./useCsvContext";
export const UploadCSV = ({ table }: { table: keyof typeof importSchemas }) => {
@@ -28,6 +30,44 @@ export const UploadCSV = ({ table }: { table: keyof typeof importSchemas }) => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
+ const downloadTemplate = useCallback(() => {
+ const mapping = fieldMappings[table];
+ const fields = Object.values(mapping) as Array<{
+ label: string;
+ required?: boolean;
+ type: "string" | "boolean" | "enum" | "numeric";
+ enumData?: {
+ description?: string;
+ options?: readonly string[];
+ fetcher?: unknown;
+ };
+ }>;
+ const headers = fields.map((f) => f.label);
+ // Hint row: helps users see required-ness + valid values at a glance.
+ // It's a CSV data row (CSV has no comment syntax) — users overwrite it
+ // before re-uploading.
+ const hints = fields.map((f) => {
+ const prefix = f.required ? "REQUIRED" : "optional";
+ if (f.type === "enum" && f.enumData?.options) {
+ return `${prefix} — one of: ${f.enumData.options.join(" | ")}`;
+ }
+ if (f.type === "enum" && f.enumData?.fetcher) {
+ return `${prefix} — ${f.enumData.description ?? "see your configured options"}`;
+ }
+ if (f.type === "boolean") return `${prefix} — true | false`;
+ if (f.type === "numeric") return `${prefix} — number`;
+ return prefix;
+ });
+ const csv = Papa.unparse({ fields: headers, data: [hints] });
+ const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement("a");
+ link.href = url;
+ link.download = `${table}-template.csv`;
+ link.click();
+ URL.revokeObjectURL(url);
+ }, [table]);
+
const processFile = async (file: File) => {
if (!file) {
setFileColumns(null);
@@ -144,10 +184,33 @@ export const UploadCSV = ({ table }: { table: keyof typeof importSchemas }) => {
</ModalDescription>
</ModalHeader>
<ModalBody>
+ <div className="mt-1 mb-4 flex items-center justify-between gap-4 rounded-md border bg-muted/40 px-4 py-3">
+ <div className="flex min-w-0 items-center gap-3">
+ <div className="flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-md border bg-background">
+ <LuFileSpreadsheet className="h-4 w-4 text-muted-foreground" />
+ </div>
+ <div className="flex min-w-0 flex-col">
+ <span className="text-sm font-medium">
+ <Trans>Need the right columns?</Trans>
+ </span>
+ <span className="text-xs text-muted-foreground">
+ <Trans>Hints in the first row</Trans>
+ </span>
+ </div>
+ </div>
+ <Button
+ variant="secondary"
+ size="md"
+ leftIcon={<LuDownload />}
+ onClick={downloadTemplate}
+ >
+ <Trans>Download template</Trans>
+ </Button>
+ </div>
<div
{...getRootProps()}
className={cn(
- "w-full border-2 border-dashed h-[200px] rounded-md mt-8 mb-8 flex items-center justify-center text-muted-foreground hover:border-primary hover:text-foreground cursor-pointer focus-visible:border-primary focus-visible:text-foreground hover:bg-primary/5 focus-visible:outline-none",
+ "w-full border-2 border-dashed h-[200px] rounded-md mb-8 flex items-center justify-center text-muted-foreground hover:border-primary hover:text-foreground cursor-pointer focus-visible:border-primary focus-visible:text-foreground hover:bg-primary/5 focus-visible:outline-none",
isDragActive
? "border-primary text-foreground bg-primary/5"
: "border-muted",
diff --git a/apps/erp/app/components/RealtimeDataProvider.tsx b/apps/erp/app/components/RealtimeDataProvider.tsx
index 697f4d8c1f..cd32fac5c6 100644
--- a/apps/erp/app/components/RealtimeDataProvider.tsx
+++ b/apps/erp/app/components/RealtimeDataProvider.tsx
@@ -120,14 +120,19 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
name: string;
website: string;
supplierStatus: string;
- }>(carbon, "supplier", "id, name, website, supplierStatus", (query) =>
- query.eq("companyId", companyId).order("name")
+ readableId: string | null;
+ }>(
+ carbon,
+ "supplier",
+ "id, name, website, supplierStatus, readableId",
+ (query) => query.eq("companyId", companyId).order("name")
),
fetchAllFromTable<{
id: string;
name: string;
website: string;
- }>(carbon, "customer", "id, name, website", (query) =>
+ readableId: string | null;
+ }>(carbon, "customer", "id, name, website, readableId", (query) =>
query.eq("companyId", companyId).order("name")
),
fetchAllFromTable<{
diff --git a/apps/erp/app/modules/purchasing/purchasing.models.ts b/apps/erp/app/modules/purchasing/purchasing.models.ts
index e594311251..e341ac7c59 100644
--- a/apps/erp/app/modules/purchasing/purchasing.models.ts
+++ b/apps/erp/app/modules/purchasing/purchasing.models.ts
@@ -298,6 +298,7 @@ export const selectedLinesValidator = z.record(z.string(), selectedLineSchema);
export const supplierValidator = z.object({
id: zfd.text(z.string().optional()),
+ readableId: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }),
supplierStatus: z.preprocess(
(val) => (val === "" ? undefined : val),
@@ -313,6 +314,7 @@ export const supplierValidator = z.object({
export const supplierApprovalValidator = z.object({
id: zfd.text(z.string().optional()),
+ readableId: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }),
supplierStatus: z.enum(supplierStatusType, {
errorMap: (issue, ctx) => ({
diff --git a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierForm.tsx b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
index 9420f9fe51..74b76a714f 100644
--- a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
@@ -23,6 +23,7 @@ import {
Employee,
Hidden,
Input,
+ SequenceOrCustomId,
Submit,
SupplierContact,
SupplierStatus,
@@ -117,6 +118,15 @@ const SupplierForm = ({
: "grid-cols-1 md:grid-cols-2"
)}
>
+ {isEditing ? (
+ <Input name="readableId" label={t`Supplier ID`} />
+ ) : (
+ <SequenceOrCustomId
+ name="readableId"
+ label={t`Supplier ID`}
+ table="supplier"
+ />
+ )}
<Input autoFocus={!isEditing} name="name" label={t`Name`} />
<SupplierStatus
name="supplierStatus"
diff --git a/apps/erp/app/modules/purchasing/ui/Supplier/SuppliersTable.tsx b/apps/erp/app/modules/purchasing/ui/Supplier/SuppliersTable.tsx
index 86dac80584..b7c97182f9 100644
--- a/apps/erp/app/modules/purchasing/ui/Supplier/SuppliersTable.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Supplier/SuppliersTable.tsx
@@ -14,6 +14,7 @@ import {
LuCalendar,
LuEuro,
LuGlobe,
+ LuHash,
LuPencil,
LuPhone,
LuPrinter,
@@ -63,6 +64,18 @@ const SuppliersTable = memo(({ data, count, tags }: SuppliersTableProps) => {
const customColumns = useCustomColumns<Supplier>("supplier");
const columns = useMemo<ColumnDef<Supplier>[]>(() => {
const defaultColumns: ColumnDef<Supplier>[] = [
+ {
+ accessorKey: "readableId",
+ header: t`ID`,
+ cell: ({ row }) => (
+ <span className="font-mono text-xs text-muted-foreground">
+ {row.original.readableId ?? ""}
+ </span>
+ ),
+ meta: {
+ icon: <LuHash />
+ }
+ },
{
accessorKey: "name",
header: t`Name`,
diff --git a/apps/erp/app/modules/sales/sales.models.ts b/apps/erp/app/modules/sales/sales.models.ts
index 6b7538b53a..ddd2c5e4ef 100644
--- a/apps/erp/app/modules/sales/sales.models.ts
+++ b/apps/erp/app/modules/sales/sales.models.ts
@@ -64,6 +64,7 @@ export const customerLocationValidator = z.object({
export const customerValidator = z.object({
id: zfd.text(z.string().optional()),
+ readableId: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }),
customerStatusId: zfd.text(z.string().optional()),
customerTypeId: zfd.text(z.string().optional()),
diff --git a/apps/erp/app/modules/sales/ui/Customer/CustomerForm.tsx b/apps/erp/app/modules/sales/ui/Customer/CustomerForm.tsx
index f61903071a..eec687e109 100644
--- a/apps/erp/app/modules/sales/ui/Customer/CustomerForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Customer/CustomerForm.tsx
@@ -27,6 +27,7 @@ import {
Hidden,
Input,
Number,
+ SequenceOrCustomId,
Submit
} from "~/components/Form";
import { usePermissions } from "~/hooks";
@@ -112,6 +113,15 @@ const CustomerForm = ({
: "grid-cols-1 md:grid-cols-2"
)}
>
+ {isEditing ? (
+ <Input name="readableId" label={t`Customer ID`} />
+ ) : (
+ <SequenceOrCustomId
+ name="readableId"
+ label={t`Customer ID`}
+ table="customer"
+ />
+ )}
<Input name="name" label={t`Name`} autoFocus={!isEditing} />
<CustomerStatus
diff --git a/apps/erp/app/modules/sales/ui/Customers/CustomersTable.tsx b/apps/erp/app/modules/sales/ui/Customers/CustomersTable.tsx
index e27d601bc1..295c3f25c8 100644
--- a/apps/erp/app/modules/sales/ui/Customers/CustomersTable.tsx
+++ b/apps/erp/app/modules/sales/ui/Customers/CustomersTable.tsx
@@ -14,6 +14,7 @@ import {
LuCalendar,
LuEuro,
LuGlobe,
+ LuHash,
LuPencil,
LuPhone,
LuPrinter,
@@ -69,6 +70,18 @@ const CustomersTable = memo(
const customColumns = useCustomColumns<Customer>("customer");
const columns = useMemo<ColumnDef<Customer>[]>(() => {
const defaultColumns: ColumnDef<Customer>[] = [
+ {
+ accessorKey: "readableId",
+ header: t`ID`,
+ cell: ({ row }) => (
+ <span className="font-mono text-xs text-muted-foreground">
+ {row.original.readableId ?? ""}
+ </span>
+ ),
+ meta: {
+ icon: <LuHash />
+ }
+ },
{
accessorKey: "name",
header: t`Name`,
diff --git a/apps/erp/app/modules/shared/imports.models.ts b/apps/erp/app/modules/shared/imports.models.ts
index 8fa979011b..e9aa45963e 100644
--- a/apps/erp/app/modules/shared/imports.models.ts
+++ b/apps/erp/app/modules/shared/imports.models.ts
@@ -15,6 +15,12 @@ const itemTrackingTypes = [
"Serial",
"Batch"
] as const;
+const supplierStatusTypes = [
+ "Active",
+ "Inactive",
+ "Pending",
+ "Rejected"
+] as const;
export const fieldMappings = {
customer: {
@@ -33,14 +39,53 @@ export const fieldMappings = {
required: false,
type: "enum",
enumData: {
- description: "The account manager of the customer",
+ description:
+ "The account manager — match by employee email (e.g. [email protected])",
fetcher: async (
client: SupabaseClient<Database>,
companyId: string
) => {
return client
.from("employees")
- .select("id, name, avatarUrl")
+ .select("id, name, email, avatarUrl")
+ .eq("companyId", companyId)
+ .order("name");
+ }
+ }
+ },
+ customerStatusId: {
+ label: "Status",
+ required: false,
+ type: "enum",
+ enumData: {
+ description:
+ "The status of the customer (from your configured statuses)",
+ fetcher: async (
+ client: SupabaseClient<Database>,
+ companyId: string
+ ) => {
+ return client
+ .from("customerStatus")
+ .select("id, name")
+ .eq("companyId", companyId)
+ .order("name");
+ }
+ }
+ },
+ customerTypeId: {
+ label: "Type",
+ required: false,
+ type: "enum",
+ enumData: {
+ description:
+ "The category/type of the customer (from your configured types)",
+ fetcher: async (
+ client: SupabaseClient<Database>,
+ companyId: string
+ ) => {
+ return client
+ .from("customerType")
+ .select("id, name")
.eq("companyId", companyId)
.order("name");
}
@@ -140,14 +185,45 @@ export const fieldMappings = {
required: false,
type: "enum",
enumData: {
- description: "The account manager of the customer",
+ description:
+ "The account manager — match by employee email (e.g. [email protected])",
fetcher: async (
client: SupabaseClient<Database>,
companyId: string
) => {
return client
.from("employees")
- .select("id, name, avatarUrl")
+ .select("id, name, email, avatarUrl")
+ .eq("companyId", companyId)
+ .order("name");
+ }
+ }
+ },
+ supplierStatus: {
+ label: "Status",
+ required: false,
+ type: "enum",
+ enumData: {
+ default: "",
+ description:
+ "The status of the supplier — one of: Active, Inactive, Pending, Rejected",
+ options: supplierStatusTypes
+ }
+ },
+ supplierTypeId: {
+ label: "Type",
+ required: false,
+ type: "enum",
+ enumData: {
+ description:
+ "The category/type of the supplier (from your configured types)",
+ fetcher: async (
+ client: SupabaseClient<Database>,
+ companyId: string
+ ) => {
+ return client
+ .from("supplierType")
+ .select("id, name")
.eq("companyId", companyId)
.order("name");
}
@@ -254,15 +330,10 @@ export const fieldMappings = {
default: "0"
},
name: {
- label: "Short Description",
+ label: "Description",
required: true,
type: "string"
},
- description: {
- label: "Long Description",
- required: false,
- type: "string"
- },
active: {
label: "Active",
required: false,
@@ -348,15 +419,10 @@ export const fieldMappings = {
default: "0"
},
name: {
- label: "Short Description",
+ label: "Description",
required: true,
type: "string"
},
- description: {
- label: "Long Description",
- required: false,
- type: "string"
- },
active: {
label: "Active",
required: false,
@@ -442,15 +508,10 @@ export const fieldMappings = {
default: "0"
},
name: {
- label: "Short Description",
+ label: "Description",
required: true,
type: "string"
},
- description: {
- label: "Long Description",
- required: false,
- type: "string"
- },
active: {
label: "Active",
required: false,
@@ -536,15 +597,10 @@ export const fieldMappings = {
default: "0"
},
name: {
- label: "Short Description",
+ label: "Description",
required: true,
type: "string"
},
- description: {
- label: "Long Description",
- required: false,
- type: "string"
- },
active: {
label: "Active",
required: false,
@@ -630,15 +686,10 @@ export const fieldMappings = {
default: "0"
},
name: {
- label: "Short Description",
+ label: "Description",
required: true,
type: "string"
},
- description: {
- label: "Long Description",
- required: false,
- type: "string"
- },
active: {
label: "Active",
required: false,
@@ -977,6 +1028,14 @@ export const importSchemas: Record<
.string()
.optional()
.describe("The id of the account manager of the customer"),
+ customerStatusId: z
+ .string()
+ .optional()
+ .describe("The id of the customer's status"),
+ customerTypeId: z
+ .string()
+ .optional()
+ .describe("The id of the customer's type/category"),
phone: z.string().optional().describe("The phone number of the customer"),
fax: z.string().optional().describe("The fax number of the customer"),
taxId: z
@@ -1047,6 +1106,14 @@ export const importSchemas: Record<
.string()
.optional()
.describe("The id of the account manager of the supplier"),
+ supplierStatus: z
+ .string()
+ .optional()
+ .describe("The status of the supplier"),
+ supplierTypeId: z
+ .string()
+ .optional()
+ .describe("The id of the supplier's type/category"),
phone: z.string().optional().describe("The phone number of the supplier"),
fax: z.string().optional().describe("The fax number of the supplier"),
taxId: z
@@ -1122,11 +1189,7 @@ export const importSchemas: Record<
name: z
.string()
.min(1, { message: "Name is required" })
- .describe("The short description of the part"),
- description: z
- .string()
- .optional()
- .describe("The long description of the part"),
+ .describe("The description of the part"),
active: z.string().optional().describe("Whether the part is active"),
unitOfMeasureCode: z
.string()
@@ -1161,11 +1224,7 @@ export const importSchemas: Record<
name: z
.string()
.min(1, { message: "Name is required" })
- .describe("The short description of the tool"),
- description: z
- .string()
- .optional()
- .describe("The long description of the tool"),
+ .describe("The description of the tool"),
active: z.string().optional().describe("Whether the tool is active"),
unitOfMeasureCode: z
.string()
@@ -1200,11 +1259,7 @@ export const importSchemas: Record<
name: z
.string()
.min(1, { message: "Name is required" })
- .describe("The short description of the fixture"),
- description: z
- .string()
- .optional()
- .describe("The long description of the fixture"),
+ .describe("The description of the fixture"),
active: z.string().optional().describe("Whether the fixture is active"),
unitOfMeasureCode: z
.string()
@@ -1239,11 +1294,7 @@ export const importSchemas: Record<
name: z
.string()
.min(1, { message: "Name is required" })
- .describe("The short description of the part"),
- description: z
- .string()
- .optional()
- .describe("The long description of the part"),
+ .describe("The description of the part"),
active: z.string().optional().describe("Whether the part is active"),
unitOfMeasureCode: z
.string()
@@ -1278,11 +1329,7 @@ export const importSchemas: Record<
name: z
.string()
.min(1, { message: "Name is required" })
- .describe("The short description of the material"),
- description: z
- .string()
- .optional()
- .describe("The long description of the material"),
+ .describe("The description of the material"),
active: z.string().optional().describe("Whether the material is active"),
materialSubstanceId: z
.string()
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.details.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.details.tsx
index 03f2503db8..89a54c85c8 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.details.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.details.tsx
@@ -60,6 +60,7 @@ export default function SupplierEditRoute() {
if (!routeData?.supplier) return null;
const initialValues = {
+ ...routeData.supplier,
id: routeData?.supplier?.id ?? undefined,
name: routeData?.supplier?.name ?? "",
supplierTypeId: routeData?.supplier?.supplierTypeId ?? undefined,
diff --git a/apps/erp/app/stores/customers.ts b/apps/erp/app/stores/customers.ts
index 38d80bbe0b..c3a64bc9c6 100644
--- a/apps/erp/app/stores/customers.ts
+++ b/apps/erp/app/stores/customers.ts
@@ -2,5 +2,10 @@ import { atom } from "nanostores";
import { useNanoStore } from "~/hooks";
import type { ListItem } from "~/types";
-const $customersStore = atom<(ListItem & { website?: string | null })[]>([]);
+const $customersStore = atom<
+ (ListItem & {
+ website?: string | null;
+ readableId?: string | null;
+ })[]
+>([]);
export const useCustomers = () => useNanoStore($customersStore, "customers");
diff --git a/apps/erp/app/stores/suppliers.ts b/apps/erp/app/stores/suppliers.ts
index f9ca8c1f47..23212c3e60 100644
--- a/apps/erp/app/stores/suppliers.ts
+++ b/apps/erp/app/stores/suppliers.ts
@@ -3,6 +3,10 @@ import { useNanoStore } from "~/hooks";
import type { ListItem } from "~/types";
const $suppliersStore = atom<
- (ListItem & { website?: string | null; supplierStatus?: string | null })[]
+ (ListItem & {
+ website?: string | null;
+ supplierStatus?: string | null;
+ readableId?: string | null;
+ })[]
>([]);
export const useSuppliers = () => useNanoStore($suppliersStore, "suppliers");
diff --git a/apps/erp/app/types/index.ts b/apps/erp/app/types/index.ts
index 23726ce6f8..37dd6e243b 100644
--- a/apps/erp/app/types/index.ts
+++ b/apps/erp/app/types/index.ts
@@ -27,6 +27,7 @@ export type FormActionData = Promise<ValidationErrorResponseData | Result>;
export type ListItem = {
id: string;
name: string;
+ email?: string;
};
export type ModelUpload = {
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 9fb8a4104b..51ef2b29aa 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -1899,6 +1899,45 @@ export type Database = {
}
Relationships: []
}
+ auditLog_NS5Wm1Sh7DdquQ12z8wUPd: {
+ Row: {
+ actorId: string | null
+ createdAt: string
+ diff: Json | null
+ entityId: string
+ entityType: string
+ id: string
+ metadata: Json | null
+ operation: string
+ recordId: string | null
+ tableName: string
+ }
+ Insert: {
+ actorId?: string | null
+ createdAt?: string
+ diff?: Json | null
+ entityId: string
+ entityType: string
+ id?: string
+ metadata?: Json | null
+ operation: string
+ recordId?: string | null
+ tableName: string
+ }
+ Update: {
+ actorId?: string | null
+ createdAt?: string
+ diff?: Json | null
+ entityId?: string
+ entityType?: string
+ id?: string
+ metadata?: Json | null
+ operation?: string
+ recordId?: string | null
+ tableName?: string
+ }
+ Relationships: []
+ }
auditLogArchive: {
Row: {
archivePath: string
@@ -4430,6 +4469,7 @@ export type Database = {
logo: string | null
name: string
phone: string | null
+ readableId: string | null
salesContactId: string | null
tags: string[] | null
taxPercent: number
@@ -4455,6 +4495,7 @@ export type Database = {
logo?: string | null
name: string
phone?: string | null
+ readableId?: string | null
salesContactId?: string | null
tags?: string[] | null
taxPercent?: number
@@ -4480,6 +4521,7 @@ export type Database = {
logo?: string | null
name?: string
phone?: string | null
+ readableId?: string | null
salesContactId?: string | null
tags?: string[] | null
taxPercent?: number
@@ -36107,7 +36149,49 @@ export type Database = {
},
]
}
- searchIndex_CYj9v111oXXm6PX9ZD6Yn2: {
+ searchIndex_NS5Wm1Sh7DdquQ12z8wUPd: {
+ Row: {
+ createdAt: string
+ description: string | null
+ entityId: string
+ entityType: string
+ id: number
+ link: string
+ metadata: Json | null
+ searchVector: unknown
+ tags: string[] | null
+ title: string
+ updatedAt: string | null
+ }
+ Insert: {
+ createdAt?: string
+ description?: string | null
+ entityId: string
+ entityType: string
+ id?: number
+ link: string
+ metadata?: Json | null
+ searchVector?: unknown
+ tags?: string[] | null
+ title: string
+ updatedAt?: string | null
+ }
+ Update: {
+ createdAt?: string
+ description?: string | null
+ entityId?: string
+ entityType?: string
+ id?: number
+ link?: string
+ metadata?: Json | null
+ searchVector?: unknown
+ tags?: string[] | null
+ title?: string
+ updatedAt?: string | null
+ }
+ Relationships: []
+ }
+ searchIndex_X9wBhevBUjpWSP5uHVTCAe: {
Row: {
createdAt: string
description: string | null
@@ -38581,6 +38665,7 @@ export type Database = {
name: string
phone: string | null
purchasingContactId: string | null
+ readableId: string | null
supplierStatus:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -38608,6 +38693,7 @@ export type Database = {
name: string
phone?: string | null
purchasingContactId?: string | null
+ readableId?: string | null
supplierStatus?:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -38635,6 +38721,7 @@ export type Database = {
name?: string
phone?: string | null
purchasingContactId?: string | null
+ readableId?: string | null
supplierStatus?:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -47071,6 +47158,7 @@ export type Database = {
name: string | null
orderCount: number | null
phone: string | null
+ readableId: string | null
salesContactId: string | null
status: string | null
tags: string[] | null
@@ -51382,14 +51470,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -52873,14 +52961,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -56291,7 +56379,7 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["shipmentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -56305,7 +56393,7 @@ export type Database = {
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["shipmentCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -59156,6 +59244,7 @@ export type Database = {
partCount: number | null
phone: string | null
purchasingContactId: string | null
+ readableId: string | null
status: Database["public"]["Enums"]["supplierStatusType"] | null
supplierTypeId: string | null
tags: string[] | null
diff --git a/packages/database/supabase/functions/import-csv/index.ts b/packages/database/supabase/functions/import-csv/index.ts
index 973c9cea62..5f75a6eb91 100644
--- a/packages/database/supabase/functions/import-csv/index.ts
+++ b/packages/database/supabase/functions/import-csv/index.ts
@@ -37,10 +37,168 @@ const importCsvValidator = z.object({
const EXTERNAL_ID_KEY = "csv";
/**
- * Build a map of CSV external IDs → entity IDs from the externalIntegrationMapping table.
+ * Fallback CSV parser used when std/csv rejects a row-length mismatch.
+ * Handles RFC-4180 quoting but tolerates uneven row widths (extra cells
+ * dropped, missing cells become "").
+ */
+function parsePermissiveCsv(text: string): Record<string, string>[] {
+ // Tokenize the full text into a 2D array of cells, respecting quoted fields
+ // that may span commas and newlines.
+ const rows: string[][] = [];
+ let row: string[] = [];
+ let field = "";
+ let inQuotes = false;
+ for (let i = 0; i < text.length; i++) {
+ const c = text[i];
+ if (inQuotes) {
+ if (c === '"') {
+ if (text[i + 1] === '"') {
+ field += '"';
+ i++;
+ } else {
+ inQuotes = false;
+ }
+ } else {
+ field += c;
+ }
+ } else if (c === '"') {
+ inQuotes = true;
+ } else if (c === ",") {
+ row.push(field);
+ field = "";
+ } else if (c === "\n" || c === "\r") {
+ // \r\n: consume the \n that follows
+ if (c === "\r" && text[i + 1] === "\n") i++;
+ row.push(field);
+ field = "";
+ // Skip blank rows that arise from trailing newlines
+ if (row.length > 1 || (row.length === 1 && row[0] !== "")) {
+ rows.push(row);
+ }
+ row = [];
+ } else {
+ field += c;
+ }
+ }
+ // Trailing field / row (no terminating newline)
+ if (field !== "" || row.length > 0) {
+ row.push(field);
+ if (row.length > 1 || (row.length === 1 && row[0] !== "")) {
+ rows.push(row);
+ }
+ }
+
+ if (rows.length === 0) return [];
+ const headers = rows[0];
+ return rows.slice(1).map((r) => {
+ const obj: Record<string, string> = {};
+ for (let i = 0; i < headers.length; i++) {
+ obj[headers[i]] = r[i] ?? "";
+ }
+ return obj;
+ });
+}
+
+type CsvEntityType =
+ | "customer"
+ | "supplier"
+ | "item"
+ | "contact"
+ | "workCenter"
+ | "process";
+
+/**
+ * Look up the ids that still exist in the entity table. Done as a typed
+ * switch so each Kysely query is fully type-checked — avoids `as any` casts
+ * that bypass the generated DB types.
+ */
+async function fetchLiveEntityIds(
+ entityType: CsvEntityType,
+ ids: string[]
+): Promise<Set<string>> {
+ if (ids.length === 0) return new Set();
+ let rows: { id: string }[];
+ switch (entityType) {
+ case "customer":
+ rows = await db
+ .selectFrom("customer")
+ .select(["id"])
+ .where("id", "in", ids)
+ .execute();
+ break;
+ case "supplier":
+ rows = await db
+ .selectFrom("supplier")
+ .select(["id"])
+ .where("id", "in", ids)
+ .execute();
+ break;
+ case "item":
+ rows = await db
+ .selectFrom("item")
+ .select(["id"])
+ .where("id", "in", ids)
+ .execute();
+ break;
+ case "contact":
+ rows = await db
+ .selectFrom("contact")
+ .select(["id"])
+ .where("id", "in", ids)
+ .execute();
+ break;
+ case "workCenter":
+ rows = await db
+ .selectFrom("workCenter")
+ .select(["id"])
+ .where("id", "in", ids)
+ .execute();
+ break;
+ case "process":
+ rows = await db
+ .selectFrom("process")
+ .select(["id"])
+ .where("id", "in", ids)
+ .execute();
+ break;
+ }
+ return new Set(rows.map((r) => r.id));
+}
+
+/**
+ * Build a name → id map for an entity table, scoped to a company. Used as a
+ * fallback dedup key when the CSV's Unique ID has no externalIntegrationMapping
+ * row yet (e.g., the entity was created in-app, then a CSV with the same name
+ * is imported). Without this, the INSERT would fail the per-company name
+ * uniqueness constraint (supplier_name_unique / customer_name_unique).
+ */
+async function getNameMap(
+ entityType: "supplier" | "customer",
+ cId: string
+): Promise<Map<string, string>> {
+ const rows =
+ entityType === "supplier"
+ ? await db
+ .selectFrom("supplier")
+ .select(["id", "name"])
+ .where("companyId", "=", cId)
+ .execute()
+ : await db
+ .selectFrom("customer")
+ .select(["id", "name"])
+ .where("companyId", "=", cId)
+ .execute();
+ return new Map(rows.map((r) => [r.name, r.id]));
+}
+
+/**
+ * Build a map of CSV external IDs → entity IDs from externalIntegrationMapping.
+ * Filters orphan mappings (rows whose entityId points at a deleted entity)
+ * so re-imports cleanly take the INSERT path instead of failing the
+ * subsequent supplierTax/customerTax upsert with a 23503 FK error.
*/
async function getCsvExternalIdMap(
- entityType: string,
+ entityType: CsvEntityType,
cId: string
): Promise<Map<string, string>> {
const result = await db
@@ -51,22 +209,47 @@ async function getCsvExternalIdMap(
.where("companyId", "=", cId)
.execute();
+ const candidates = result.filter(
+ (r): r is typeof r & { externalId: string; entityId: string } =>
+ r.externalId !== null && r.entityId !== null
+ );
+
+ if (candidates.length === 0) return new Map();
+
+ const liveIds = await fetchLiveEntityIds(
+ entityType,
+ candidates.map((r) => r.entityId)
+ );
+
return new Map(
- result
- .filter(
- (r): r is typeof r & { externalId: string } => r.externalId !== null
- )
+ candidates
+ .filter((r) => liveIds.has(r.entityId))
.map((r) => [r.externalId, r.entityId])
);
}
+/**
+ * Convert empty-string values to undefined. Kysely drops undefined keys from
+ * the INSERT, so the column gets its DB default (NULL). Empty CSV cells would
+ * otherwise become literal "" and fail FK or enum constraints.
+ */
+function nullifyEmptyStrings<T extends Record<string, unknown>>(
+ obj: T
+): Partial<T> {
+ const out: Record<string, unknown> = {};
+ for (const [k, v] of Object.entries(obj)) {
+ out[k] = v === "" ? undefined : v;
+ }
+ return out as Partial<T>;
+}
+
/**
* Upsert CSV external ID mappings into the externalIntegrationMapping table.
* Uses ON CONFLICT to handle re-imports idempotently.
*/
async function upsertCsvMappings(
trx: typeof db,
- entityType: string,
+ entityType: CsvEntityType,
mappings: Array<{ entityId: string; externalId: string }>,
cId: string,
userId: string
@@ -90,11 +273,16 @@ async function upsertCsvMappings(
updatedAt: now,
}))
)
+ // On conflict (orphan mapping with same csv id but stale entityId),
+ // repoint entityId to the freshly-inserted entity. The .where() matches
+ // the partial unique index's predicate, required by Postgres for
+ // arbitration on partial indexes (42P10 otherwise).
.onConflict((oc) =>
oc
- .columns(["entityType", "entityId", "integration", "companyId"])
+ .columns(["integration", "externalId", "entityType", "companyId"])
+ .where("allowDuplicateExternalId", "=", false)
.doUpdateSet((eb) => ({
- externalId: eb.ref("excluded.externalId"),
+ entityId: eb.ref("excluded.entityId"),
updatedAt: eb.ref("excluded.updatedAt"),
}))
)
@@ -104,7 +292,6 @@ async function upsertCsvMappings(
async function upsertTaxIdentifiers(
trx: typeof db,
table: "customerTax" | "supplierTax",
- fkColumn: "customerId" | "supplierId",
records: Array<{ entityId: string; taxId: string | null | undefined }>,
cId: string,
userId: string
@@ -112,22 +299,41 @@ async function upsertTaxIdentifiers(
if (records.length === 0) return;
const now = new Date().toISOString();
- // deno-lint-ignore no-explicit-any -- generated DB types lag this branch-local migration.
- await (trx as any)
- .insertInto(table)
+ if (table === "customerTax") {
+ await trx
+ .insertInto("customerTax")
+ .values(
+ records.map((r) => ({
+ customerId: r.entityId,
+ taxId: r.taxId ?? null,
+ companyId: cId,
+ updatedAt: now,
+ updatedBy: userId,
+ }))
+ )
+ .onConflict((oc) =>
+ oc.column("customerId").doUpdateSet({
+ taxId: sql`excluded."taxId"`,
+ updatedAt: now,
+ updatedBy: userId,
+ })
+ )
+ .execute();
+ return;
+ }
+ await trx
+ .insertInto("supplierTax")
.values(
- records.map((record) => ({
- [fkColumn]: record.entityId,
- taxId: record.taxId ?? null,
+ records.map((r) => ({
+ supplierId: r.entityId,
+ taxId: r.taxId ?? null,
companyId: cId,
updatedAt: now,
updatedBy: userId,
}))
)
- .onConflict(
- // deno-lint-ignore no-explicit-any -- Kysely conflict builder type is unavailable after the cast above.
- (oc: any) =>
- oc.column(fkColumn).doUpdateSet({
+ .onConflict((oc) =>
+ oc.column("supplierId").doUpdateSet({
taxId: sql`excluded."taxId"`,
updatedAt: now,
updatedBy: userId,
@@ -162,8 +368,6 @@ serve(async (req: Request) => {
userId,
});
- console.log({ enumMappings });
-
const client = await getSupabaseServiceRole(
req.headers.get("Authorization"),
req.headers.get("carbon-key") ?? "",
@@ -177,10 +381,17 @@ serve(async (req: Request) => {
const csvText = new TextDecoder().decode(
new Uint8Array(await csvFile.data.arrayBuffer())
);
- const parsedCsv = parse(csvText, { skipFirstRow: true }) as Record<
- string,
- string
- >[];
+ // std/csv is strict on row-length mismatches; fall back to the
+ // permissive parser for real-world CSVs with quoting/comma issues.
+ let parsedCsv: Record<string, string>[];
+ try {
+ parsedCsv = parse(csvText, {
+ skipFirstRow: true,
+ lazyQuotes: true,
+ }) as Record<string, string>[];
+ } catch (_strictErr) {
+ parsedCsv = parsePermissiveCsv(csvText);
+ }
let mappedRecords = parsedCsv.map((row) => {
const record: Record<string, string> = {};
@@ -222,7 +433,13 @@ serve(async (req: Request) => {
switch (table) {
case "customer": {
const externalIdMap = await getCsvExternalIdMap("customer", companyId);
+ const nameMap = await getNameMap("customer", companyId);
const customerIds = new Set();
+ // Tracks names queued for INSERT in this batch so a second CSV row
+ // with the same name doesn't trip the (name, companyId) unique
+ // constraint at flush time. The customer table enforces one record
+ // per name per company, so duplicates within the CSV collapse.
+ const namesQueuedForInsert = new Set<string>();
await db.transaction().execute(async (trx) => {
const customerInserts: Database["public"]["Tables"]["customer"]["Insert"][] =
@@ -239,6 +456,13 @@ serve(async (req: Request) => {
entityId: string;
taxId: string | null | undefined;
}> = [];
+ // Updates matched by name (no pre-existing csv mapping). After the
+ // updates run, we add csv mappings for these so the next import takes
+ // the externalIdMap path directly.
+ const csvIdsForNameMatchedUpdates: Array<{
+ entityId: string;
+ externalId: string;
+ }> = [];
const isCustomerValid = (
record: Record<string, string>
@@ -248,24 +472,41 @@ serve(async (req: Request) => {
for (const record of mappedRecords) {
const { id, taxId, ...rest } = record;
- if (externalIdMap.has(id)) {
- const existingEntityId = externalIdMap.get(id)!;
+ const matchedByCsvId = externalIdMap.get(id);
+ const matchedByName =
+ matchedByCsvId === undefined && rest.name
+ ? nameMap.get(rest.name)
+ : undefined;
+ const existingEntityId = matchedByCsvId ?? matchedByName;
+
+ if (existingEntityId !== undefined) {
if (isCustomerValid(rest) && !customerIds.has(id)) {
customerIds.add(id);
customerUpdates.push({
id: existingEntityId,
data: {
- ...rest,
+ ...nullifyEmptyStrings(rest),
updatedAt: new Date().toISOString(),
updatedBy: userId,
},
});
customerTaxUpdates.push({ entityId: existingEntityId, taxId });
+ if (matchedByCsvId === undefined) {
+ csvIdsForNameMatchedUpdates.push({
+ entityId: existingEntityId,
+ externalId: id,
+ });
+ }
}
} else if (isCustomerValid(rest) && !customerIds.has(id)) {
+ if (namesQueuedForInsert.has(rest.name)) continue;
customerIds.add(id);
+ namesQueuedForInsert.add(rest.name);
customerInserts.push({
- ...rest,
+ ...nullifyEmptyStrings(rest),
+ // Use the CSV's Unique ID as the readableId; trigger no-ops
+ // when readableId is non-null.
+ readableId: id,
companyId,
createdAt: new Date().toISOString(),
createdBy: userId,
@@ -290,7 +531,7 @@ serve(async (req: Request) => {
await upsertCsvMappings(
trx,
"customer",
- inserted.map((row: { id?: string }, i: number) => ({
+ inserted.map((row, i) => ({
entityId: row.id!,
externalId: csvIdsForInserts[i],
})),
@@ -300,8 +541,7 @@ serve(async (req: Request) => {
await upsertTaxIdentifiers(
trx,
"customerTax",
- "customerId",
- inserted.map((row: { id?: string }, i: number) => ({
+ inserted.map((row, i) => ({
entityId: row.id!,
taxId: customerTaxForInserts[i]?.taxId,
})),
@@ -320,18 +560,28 @@ serve(async (req: Request) => {
await upsertTaxIdentifiers(
trx,
"customerTax",
- "customerId",
customerTaxUpdates,
companyId,
userId
);
}
+ if (csvIdsForNameMatchedUpdates.length > 0) {
+ await upsertCsvMappings(
+ trx,
+ "customer",
+ csvIdsForNameMatchedUpdates,
+ companyId,
+ userId
+ );
+ }
});
break;
}
case "supplier": {
const externalIdMap = await getCsvExternalIdMap("supplier", companyId);
+ const nameMap = await getNameMap("supplier", companyId);
const supplierIds = new Set();
+ const namesQueuedForInsert = new Set<string>();
await db.transaction().execute(async (trx) => {
const supplierInserts: Database["public"]["Tables"]["supplier"]["Insert"][] =
@@ -348,6 +598,10 @@ serve(async (req: Request) => {
entityId: string;
taxId: string | null | undefined;
}> = [];
+ const csvIdsForNameMatchedUpdates: Array<{
+ entityId: string;
+ externalId: string;
+ }> = [];
const isSupplierValid = (
record: Record<string, string>
@@ -357,24 +611,41 @@ serve(async (req: Request) => {
for (const record of mappedRecords) {
const { id, taxId, ...rest } = record;
- if (externalIdMap.has(id) && !supplierIds.has(id)) {
+ const matchedByCsvId = externalIdMap.get(id);
+ const matchedByName =
+ matchedByCsvId === undefined && rest.name
+ ? nameMap.get(rest.name)
+ : undefined;
+ const existingEntityId = matchedByCsvId ?? matchedByName;
+
+ if (existingEntityId !== undefined && !supplierIds.has(id)) {
supplierIds.add(id);
- const existingEntityId = externalIdMap.get(id)!;
if (isSupplierValid(rest)) {
supplierUpdates.push({
id: existingEntityId,
data: {
- ...rest,
+ ...nullifyEmptyStrings(rest),
updatedAt: new Date().toISOString(),
updatedBy: userId,
},
});
supplierTaxUpdates.push({ entityId: existingEntityId, taxId });
+ if (matchedByCsvId === undefined) {
+ csvIdsForNameMatchedUpdates.push({
+ entityId: existingEntityId,
+ externalId: id,
+ });
+ }
}
} else if (isSupplierValid(rest) && !supplierIds.has(id)) {
+ if (namesQueuedForInsert.has(rest.name)) continue;
supplierIds.add(id);
+ namesQueuedForInsert.add(rest.name);
supplierInserts.push({
- ...rest,
+ ...nullifyEmptyStrings(rest),
+ // Use the CSV's Unique ID as the readableId; trigger no-ops
+ // when readableId is non-null.
+ readableId: id,
companyId,
createdAt: new Date().toISOString(),
createdBy: userId,
@@ -399,7 +670,7 @@ serve(async (req: Request) => {
await upsertCsvMappings(
trx,
"supplier",
- inserted.map((row: { id?: string }, i: number) => ({
+ inserted.map((row, i) => ({
entityId: row.id!,
externalId: csvIdsForInserts[i],
})),
@@ -409,8 +680,7 @@ serve(async (req: Request) => {
await upsertTaxIdentifiers(
trx,
"supplierTax",
- "supplierId",
- inserted.map((row: { id?: string }, i: number) => ({
+ inserted.map((row, i) => ({
entityId: row.id!,
taxId: supplierTaxForInserts[i]?.taxId,
})),
@@ -429,12 +699,20 @@ serve(async (req: Request) => {
await upsertTaxIdentifiers(
trx,
"supplierTax",
- "supplierId",
supplierTaxUpdates,
companyId,
userId
);
}
+ if (csvIdsForNameMatchedUpdates.length > 0) {
+ await upsertCsvMappings(
+ trx,
+ "supplier",
+ csvIdsForNameMatchedUpdates,
+ companyId,
+ userId
+ );
+ }
});
break;
}
diff --git a/packages/database/supabase/functions/lib/seed.data.ts b/packages/database/supabase/functions/lib/seed.data.ts
index 50478e397c..f5a0f4d8d0 100644
--- a/packages/database/supabase/functions/lib/seed.data.ts
+++ b/packages/database/supabase/functions/lib/seed.data.ts
@@ -345,6 +345,24 @@ export const sequences = [
next: 0,
size: 6,
step: 1
+ },
+ {
+ table: "supplier",
+ name: "Supplier",
+ prefix: "SUP",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "customer",
+ name: "Customer",
+ prefix: "CUS",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
}
] as const;
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 9fb8a4104b..51ef2b29aa 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -1899,6 +1899,45 @@ export type Database = {
}
Relationships: []
}
+ auditLog_NS5Wm1Sh7DdquQ12z8wUPd: {
+ Row: {
+ actorId: string | null
+ createdAt: string
+ diff: Json | null
+ entityId: string
+ entityType: string
+ id: string
+ metadata: Json | null
+ operation: string
+ recordId: string | null
+ tableName: string
+ }
+ Insert: {
+ actorId?: string | null
+ createdAt?: string
+ diff?: Json | null
+ entityId: string
+ entityType: string
+ id?: string
+ metadata?: Json | null
+ operation: string
+ recordId?: string | null
+ tableName: string
+ }
+ Update: {
+ actorId?: string | null
+ createdAt?: string
+ diff?: Json | null
+ entityId?: string
+ entityType?: string
+ id?: string
+ metadata?: Json | null
+ operation?: string
+ recordId?: string | null
+ tableName?: string
+ }
+ Relationships: []
+ }
auditLogArchive: {
Row: {
archivePath: string
@@ -4430,6 +4469,7 @@ export type Database = {
logo: string | null
name: string
phone: string | null
+ readableId: string | null
salesContactId: string | null
tags: string[] | null
taxPercent: number
@@ -4455,6 +4495,7 @@ export type Database = {
logo?: string | null
name: string
phone?: string | null
+ readableId?: string | null
salesContactId?: string | null
tags?: string[] | null
taxPercent?: number
@@ -4480,6 +4521,7 @@ export type Database = {
logo?: string | null
name?: string
phone?: string | null
+ readableId?: string | null
salesContactId?: string | null
tags?: string[] | null
taxPercent?: number
@@ -36107,7 +36149,49 @@ export type Database = {
},
]
}
- searchIndex_CYj9v111oXXm6PX9ZD6Yn2: {
+ searchIndex_NS5Wm1Sh7DdquQ12z8wUPd: {
+ Row: {
+ createdAt: string
+ description: string | null
+ entityId: string
+ entityType: string
+ id: number
+ link: string
+ metadata: Json | null
+ searchVector: unknown
+ tags: string[] | null
+ title: string
+ updatedAt: string | null
+ }
+ Insert: {
+ createdAt?: string
+ description?: string | null
+ entityId: string
+ entityType: string
+ id?: number
+ link: string
+ metadata?: Json | null
+ searchVector?: unknown
+ tags?: string[] | null
+ title: string
+ updatedAt?: string | null
+ }
+ Update: {
+ createdAt?: string
+ description?: string | null
+ entityId?: string
+ entityType?: string
+ id?: number
+ link?: string
+ metadata?: Json | null
+ searchVector?: unknown
+ tags?: string[] | null
+ title?: string
+ updatedAt?: string | null
+ }
+ Relationships: []
+ }
+ searchIndex_X9wBhevBUjpWSP5uHVTCAe: {
Row: {
createdAt: string
description: string | null
@@ -38581,6 +38665,7 @@ export type Database = {
name: string
phone: string | null
purchasingContactId: string | null
+ readableId: string | null
supplierStatus:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -38608,6 +38693,7 @@ export type Database = {
name: string
phone?: string | null
purchasingContactId?: string | null
+ readableId?: string | null
supplierStatus?:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -38635,6 +38721,7 @@ export type Database = {
name?: string
phone?: string | null
purchasingContactId?: string | null
+ readableId?: string | null
supplierStatus?:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -47071,6 +47158,7 @@ export type Database = {
name: string | null
orderCount: number | null
phone: string | null
+ readableId: string | null
salesContactId: string | null
status: string | null
tags: string[] | null
@@ -51382,14 +51470,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -52873,14 +52961,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -56291,7 +56379,7 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["shipmentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -56305,7 +56393,7 @@ export type Database = {
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["shipmentCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -59156,6 +59244,7 @@ export type Database = {
partCount: number | null
phone: string | null
purchasingContactId: string | null
+ readableId: string | null
status: Database["public"]["Enums"]["supplierStatusType"] | null
supplierTypeId: string | null
tags: string[] | null
diff --git a/packages/database/supabase/migrations/20260521120000_supplier-customer-readable-id.sql b/packages/database/supabase/migrations/20260521120000_supplier-customer-readable-id.sql
new file mode 100644
index 0000000000..74a63d2ad9
--- /dev/null
+++ b/packages/database/supabase/migrations/20260521120000_supplier-customer-readable-id.sql
@@ -0,0 +1,226 @@
+-- Add a first-class human-readable identifier to supplier and customer.
+--
+-- Existing rows keep readableId = NULL until they're either re-imported via
+-- CSV (importer sets readableId = CSV Unique ID) or edited in-app (form has
+-- a SequenceOrCustomId input). The csv mapping rows in
+-- externalIntegrationMapping remain the dedup key for re-imports.
+
+ALTER TABLE "supplier" ADD COLUMN IF NOT EXISTS "readableId" TEXT;
+ALTER TABLE "customer" ADD COLUMN IF NOT EXISTS "readableId" TEXT;
+
+-- Partial unique index: NULL allowed (in-app-created entities have no
+-- natural readableId), but non-NULL values must be unique per company.
+CREATE UNIQUE INDEX IF NOT EXISTS "supplier_readableId_companyId_unique"
+ ON "supplier" ("companyId", "readableId")
+ WHERE "readableId" IS NOT NULL;
+
+CREATE UNIQUE INDEX IF NOT EXISTS "customer_readableId_companyId_unique"
+ ON "customer" ("companyId", "readableId")
+ WHERE "readableId" IS NOT NULL;
+
+-- Seed default sequences for every existing company so that supplier and
+-- customer get auto-generated readableIds (SUP-000001, CUS-000001, etc.)
+-- matching the convention used by purchaseOrder/quote/salesOrder.
+-- Note: get_next_sequence() formats as: prefix + zero-padded(size) + suffix.
+INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step", "companyId", "updatedBy")
+SELECT 'supplier', 'Supplier', 'SUP', NULL, 0, 6, 1, c.id, 'system'
+FROM "company" c
+ON CONFLICT ("table", "companyId") DO NOTHING;
+
+INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step", "companyId", "updatedBy")
+SELECT 'customer', 'Customer', 'CUS', NULL, 0, 6, 1, c.id, 'system'
+FROM "company" c
+ON CONFLICT ("table", "companyId") DO NOTHING;
+
+-- BEFORE INSERT trigger: auto-fill readableId via get_next_sequence when
+-- the caller didn't provide one. This means ALL insertion paths (in-app
+-- creation, CSV import where the user didn't map Unique ID, future code)
+-- get a readableId for free without per-call boilerplate.
+CREATE OR REPLACE FUNCTION set_supplier_readable_id_on_insert()
+RETURNS TRIGGER AS $$
+BEGIN
+ IF NEW."readableId" IS NULL OR NEW."readableId" = '' THEN
+ -- Only fire if a sequence row exists for this company. If not, leave
+ -- readableId NULL — that's the safe default.
+ IF EXISTS (
+ SELECT 1 FROM "sequence"
+ WHERE "table" = 'supplier' AND "companyId" = NEW."companyId"
+ ) THEN
+ NEW."readableId" := get_next_sequence('supplier', NEW."companyId");
+ END IF;
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+CREATE OR REPLACE FUNCTION set_customer_readable_id_on_insert()
+RETURNS TRIGGER AS $$
+BEGIN
+ IF NEW."readableId" IS NULL OR NEW."readableId" = '' THEN
+ IF EXISTS (
+ SELECT 1 FROM "sequence"
+ WHERE "table" = 'customer' AND "companyId" = NEW."companyId"
+ ) THEN
+ NEW."readableId" := get_next_sequence('customer', NEW."companyId");
+ END IF;
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+DROP TRIGGER IF EXISTS set_supplier_readable_id ON "supplier";
+CREATE TRIGGER set_supplier_readable_id
+ BEFORE INSERT ON "supplier"
+ FOR EACH ROW
+ EXECUTE PROCEDURE set_supplier_readable_id_on_insert();
+
+DROP TRIGGER IF EXISTS set_customer_readable_id ON "customer";
+CREATE TRIGGER set_customer_readable_id
+ BEFORE INSERT ON "customer"
+ FOR EACH ROW
+ EXECUTE PROCEDURE set_customer_readable_id_on_insert();
+
+-- Recreate the suppliers and customers views to expose readableId.
+-- Postgres views freeze their column manifest at CREATE time, so adding a
+-- column to the base table does not propagate without a DROP/CREATE cycle.
+
+DROP VIEW IF EXISTS "suppliers";
+CREATE OR REPLACE VIEW "suppliers" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ s.id,
+ s."readableId",
+ s.name,
+ s."supplierTypeId",
+ s."supplierStatus" as "status",
+ stx."taxId",
+ s."accountManagerId",
+ s.logo,
+ s.assignee,
+ s."companyId",
+ s."createdAt",
+ s."createdBy",
+ s."updatedAt",
+ s."updatedBy",
+ s."customFields",
+ s."currencyCode",
+ stx."vatNumber",
+ stx."eori",
+ s.website,
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL OR eim."metadata" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'supplier' AND eim."entityId" = s.id
+ ) AS "externalId",
+ s.tags,
+ s."taxPercent",
+ s."purchasingContactId",
+ s.embedding,
+ s."defaultCc",
+ st.name AS "type",
+ po.count AS "orderCount",
+ p.count AS "partCount",
+ pc."workPhone" AS "phone",
+ pc.fax AS "fax"
+ FROM "supplier" s
+ LEFT JOIN "supplierTax" stx ON stx."supplierId" = s.id
+ LEFT JOIN "supplierType" st ON st.id = s."supplierTypeId"
+ LEFT JOIN (
+ SELECT
+ "supplierId",
+ COUNT(*) AS "count"
+ FROM "purchaseOrder"
+ GROUP BY "supplierId"
+ ) po ON po."supplierId" = s.id
+ LEFT JOIN (
+ SELECT
+ "supplierId",
+ COUNT(*) AS "count"
+ FROM "supplierPart"
+ GROUP BY "supplierId"
+ ) p ON p."supplierId" = s.id
+ LEFT JOIN (
+ SELECT DISTINCT ON (sc."supplierId")
+ sc."supplierId" AS id,
+ co."workPhone",
+ co."fax"
+ FROM "supplierContact" sc
+ JOIN "contact" co
+ ON co.id = sc."contactId"
+ ORDER BY sc."supplierId", sc.id
+ ) pc
+ ON pc.id = s.id;
+
+DROP VIEW IF EXISTS "customers";
+CREATE OR REPLACE VIEW "customers" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ c.id,
+ c."readableId",
+ c.name,
+ c."customerTypeId",
+ c."customerStatusId",
+ ctx."taxId",
+ c."accountManagerId",
+ c.logo,
+ c.assignee,
+ c."taxPercent",
+ c."tags",
+ c.website,
+ c."companyId",
+ c."createdAt",
+ c."createdBy",
+ c."updatedAt",
+ c."updatedBy",
+ c."customFields",
+ c."currencyCode",
+ c."salesContactId",
+ c."defaultCc",
+ ctx."vatNumber",
+ ctx."eori",
+ (
+ SELECT COALESCE(
+ jsonb_object_agg(
+ eim."integration",
+ CASE
+ WHEN eim."metadata" IS NOT NULL THEN eim."metadata"
+ ELSE to_jsonb(eim."externalId")
+ END
+ ) FILTER (WHERE eim."externalId" IS NOT NULL OR eim."metadata" IS NOT NULL),
+ '{}'::jsonb
+ )
+ FROM "externalIntegrationMapping" eim
+ WHERE eim."entityType" = 'customer' AND eim."entityId" = c.id
+ ) AS "externalId",
+ ct.name AS "type",
+ cs.name AS "status",
+ so.count AS "orderCount",
+ pc."workPhone" AS "phone",
+ pc."fax" AS "fax"
+ FROM "customer" c
+ LEFT JOIN "customerTax" ctx ON ctx."customerId" = c.id
+ LEFT JOIN "customerType" ct ON ct.id = c."customerTypeId"
+ LEFT JOIN "customerStatus" cs ON cs.id = c."customerStatusId"
+ LEFT JOIN (
+ SELECT
+ "customerId",
+ COUNT(*) AS "count"
+ FROM "salesOrder"
+ GROUP BY "customerId"
+ ) so ON so."customerId" = c.id
+ LEFT JOIN (
+ SELECT DISTINCT ON (cc."customerId")
+ cc."customerId",
+ co."workPhone",
+ co."fax"
+ FROM "customerContact" cc
+ INNER JOIN "contact" co ON co.id = cc."contactId"
+ ORDER BY cc."customerId"
+ ) pc ON pc."customerId" = c.id;
diff --git a/packages/database/supabase/migrations/20260605120000_supplier-customer-readable-id-required.sql b/packages/database/supabase/migrations/20260605120000_supplier-customer-readable-id-required.sql
new file mode 100644
index 0000000000..29b81c6501
--- /dev/null
+++ b/packages/database/supabase/migrations/20260605120000_supplier-customer-readable-id-required.sql
@@ -0,0 +1,46 @@
+-- Tighten supplier.readableId and customer.readableId to NOT NULL.
+--
+-- Follow-up to 20260521120000_supplier-customer-readable-id.sql, which
+-- introduced the column as nullable so the deploy could land without
+-- disturbing existing rows. By the time this migration runs, the trigger +
+-- form + importer paths have had time to populate readableId for any rows
+-- users care about. Anything still NULL gets a sequence-generated id here
+-- so we can lock the column down to NOT NULL.
+--
+-- Run only after verifying:
+-- 1. The auto-fill trigger on supplier/customer is firing for new inserts
+-- (check a few recent rows: SELECT "readableId" FROM supplier ORDER
+-- BY "createdAt" DESC LIMIT 10 — should all be non-NULL).
+-- 2. The SequenceOrCustomId form input is wired up in production.
+-- 3. CSV import is setting readableId on new entities.
+
+-- Defensive: re-seed any missing sequences. The 20260521120000 migration
+-- already did this for companies present at that time, but a company
+-- created via some bypass path between then and now might be missing the
+-- sequence row, which would cause get_next_sequence() below to raise.
+INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step", "companyId", "updatedBy")
+SELECT 'supplier', 'Supplier', 'SUP', NULL, 0, 6, 1, c.id, 'system'
+FROM "company" c
+ON CONFLICT ("table", "companyId") DO NOTHING;
+
+INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step", "companyId", "updatedBy")
+SELECT 'customer', 'Customer', 'CUS', NULL, 0, 6, 1, c.id, 'system'
+FROM "company" c
+ON CONFLICT ("table", "companyId") DO NOTHING;
+
+-- Backfill any remaining NULL readableIds using the per-company sequence.
+-- Each row's UPDATE triggers one get_next_sequence() call, which atomically
+-- increments the sequence's "next" counter and returns the formatted value.
+-- The partial unique index on (companyId, readableId) WHERE readableId IS
+-- NOT NULL guarantees no collisions with values already present.
+UPDATE "supplier"
+SET "readableId" = get_next_sequence('supplier', "companyId")
+WHERE "readableId" IS NULL;
+
+UPDATE "customer"
+SET "readableId" = get_next_sequence('customer', "companyId")
+WHERE "readableId" IS NULL;
+
+-- All rows now have a value. Lock the column down.
+ALTER TABLE "supplier" ALTER COLUMN "readableId" SET NOT NULL;
+ALTER TABLE "customer" ALTER COLUMN "readableId" SET NOT NULL;
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index 017ca882a0..d808b29198 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -2493,6 +2493,9 @@ msgstr "Herunterladen"
msgid "Download CSV"
msgstr "CSV herunterladen"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "Entwurf"
@@ -3620,6 +3623,9 @@ msgstr "Spalten ausblenden, fixieren und neu anordnen"
msgid "Higher priority wins ties and applies first for markups"
msgstr "Höhere Priorität gewinnt bei Gleichständen und wird zuerst für Aufschläge angewendet"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "Verlauf"
@@ -4629,6 +4635,9 @@ msgstr "Navigieren"
msgid "NCRs by Type"
msgstr "NCRs nach Typ"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "Negative Anpassung"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index 2a8ad6aa43..ef8fd7bac1 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -2493,6 +2493,9 @@ msgstr "Download"
msgid "Download CSV"
msgstr "Download CSV"
+msgid "Download template"
+msgstr "Download template"
+
msgid "Draft"
msgstr "Draft"
@@ -3620,6 +3623,9 @@ msgstr "Hide, pin and reorder columns"
msgid "Higher priority wins ties and applies first for markups"
msgstr "Higher priority wins ties and applies first for markups"
+msgid "Hints in the first row"
+msgstr "Hints in the first row"
+
msgid "History"
msgstr "History"
@@ -4629,6 +4635,9 @@ msgstr "Navigate"
msgid "NCRs by Type"
msgstr "NCRs by Type"
+msgid "Need the right columns?"
+msgstr "Need the right columns?"
+
msgid "Negative Adjustment"
msgstr "Negative Adjustment"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index e68d3824b4..d95870089e 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -2493,6 +2493,9 @@ msgstr "Descargar"
msgid "Download CSV"
msgstr "Descargar CSV"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "Borrador"
@@ -3620,6 +3623,9 @@ msgstr "Ocultar, anclar y reordenar columnas"
msgid "Higher priority wins ties and applies first for markups"
msgstr "Mayor prioridad gana empates y se aplica primero para márgenes"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "Historial"
@@ -4629,6 +4635,9 @@ msgstr "Navegar"
msgid "NCRs by Type"
msgstr "NCR por Tipo"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "Ajuste Negativo"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index ca8cca36fc..478322c790 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -2493,6 +2493,9 @@ msgstr "Télécharger"
msgid "Download CSV"
msgstr "Télécharger CSV"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "Brouillon"
@@ -3620,6 +3623,9 @@ msgstr "Masquer, épingler et réorganiser les c
msgid "Higher priority wins ties and applies first for markups"
msgstr "La priorité plus élevée gagne les égalités et s'applique en premier pour les majorations"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "Historique"
@@ -4629,6 +4635,9 @@ msgstr "Naviguer"
msgid "NCRs by Type"
msgstr "NCRs par type"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "Ajustement Négatif"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index 697b6de328..8d39a5916b 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -2493,6 +2493,9 @@ msgstr "डाà¤Ã
msgid "Download CSV"
msgstr "CSV डाउनलोड करें"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "ड्राफ्ट"
@@ -3620,6 +3623,9 @@ msgstr "कॉà
msgid "Higher priority wins ties and applies first for markups"
msgstr "उच्च प्राथमिकता टाई जीतती है और मार्कअप के लिए पहले लागू होती है"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "इतिहास"
@@ -4629,6 +4635,9 @@ msgstr "नेàÂ
msgid "NCRs by Type"
msgstr "प्रकार के अनुसार NCR"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "नकारात्मक समायोजन"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 0e215758eb..9e455f3607 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -2493,6 +2493,9 @@ msgstr "Scarica"
msgid "Download CSV"
msgstr "Scarica CSV"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "Bozza"
@@ -3620,6 +3623,9 @@ msgstr "Nascondi, fissa e riordina le colonne"
msgid "Higher priority wins ties and applies first for markups"
msgstr "La priorità più alta vince i pareggi e si applica per prima per i ricarichi"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "Cronologia"
@@ -4629,6 +4635,9 @@ msgstr "Naviga"
msgid "NCRs by Type"
msgstr "NCR per tipo"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "Rettifica Negativa"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index be6f8021a8..e25cf529c3 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -2493,6 +2493,9 @@ msgstr "ダウÃ
msgid "Download CSV"
msgstr "CSVをダウンロード"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "下書き"
@@ -3620,6 +3623,9 @@ msgstr "列ã‚â€
msgid "Higher priority wins ties and applies first for markups"
msgstr "優先度が高いほど同点を制し、マークアップに最初に適用されます"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "履歴"
@@ -4629,6 +4635,9 @@ msgstr "ナビÃ
msgid "NCRs by Type"
msgstr "タイプ別NCR"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "負の調整"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index b657ca7eb2..bb3315064f 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -2493,6 +2493,9 @@ msgstr "Pobierz"
msgid "Download CSV"
msgstr "Pobierz CSV"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "Wersja robocza"
@@ -3620,6 +3623,9 @@ msgstr "Ukryj, przypnij i zmieÅ„ kolejnoÃ…â
msgid "Higher priority wins ties and applies first for markups"
msgstr "Wyższy priorytet wygrywa remisy i jest stosowany jako pierwszy dla marż"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "Historia"
@@ -4629,6 +4635,9 @@ msgstr "Nawiguj"
msgid "NCRs by Type"
msgstr "NCRy wg typu"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "Ujemna Korekta"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 7e3cccc069..644d94e51f 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -2493,6 +2493,9 @@ msgstr "Baixar"
msgid "Download CSV"
msgstr "Baixar CSV"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "Rascunho"
@@ -3620,6 +3623,9 @@ msgstr "Ocultar, fixar e reordenar colunas"
msgid "Higher priority wins ties and applies first for markups"
msgstr "Prioridade mais alta vence empates e se aplica primeiro para margens"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "Histórico"
@@ -4629,6 +4635,9 @@ msgstr "Navegar"
msgid "NCRs by Type"
msgstr "NCRs por Tipo"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "Ajuste Negativo"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 7c4f1c6fa2..d7d6ac3bc0 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -2493,6 +2493,9 @@ msgstr "СкаÑââ‚
msgid "Download CSV"
msgstr "Загрузить CSV"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "Черновик"
@@ -3620,6 +3623,9 @@ msgstr "СкрÑ
msgid "Higher priority wins ties and applies first for markups"
msgstr "Более высокий приоритет выигрывает при равенстве и применяется первым для наценок"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "История"
@@ -4629,6 +4635,9 @@ msgstr "НавиÃ
msgid "NCRs by Type"
msgstr "NCRs по типам"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "Отрицательная корректировка"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index 37ab797e79..24a45e23f4 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -2493,6 +2493,9 @@ msgstr "下载"
msgid "Download CSV"
msgstr "下载 CSV"
+msgid "Download template"
+msgstr ""
+
msgid "Draft"
msgstr "草稿"
@@ -3620,6 +3623,9 @@ msgstr "隐藏ãÃ
msgid "Higher priority wins ties and applies first for markups"
msgstr "更高的优先级在平局时获胜,并首先应用于加价"
+msgid "Hints in the first row"
+msgstr ""
+
msgid "History"
msgstr "历史"
@@ -4629,6 +4635,9 @@ msgstr "导航"
msgid "NCRs by Type"
msgstr "按类型分类的不符合项"
+msgid "Need the right columns?"
+msgstr ""
+
msgid "Negative Adjustment"
msgstr "负调整"