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 sales order filter to table

Brad Barbinb9c8e31151c3
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
index 87666661d0..32c43a7365 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
@@ -165,6 +165,15 @@ const JobsTable = memo(({ data, count, tags }: JobsTableProps) => {
) : null,
meta: {
icon: <LuBookMarked />,
+ filter: {
+ type: "fetcher",
+ endpoint: path.to.api.salesOrders,
+ transform: (data: { id: string; salesOrderId: string }[] | null) =>
+ data?.map(({ salesOrderId }) => ({
+ value: salesOrderId,
+ label: salesOrderId,
+ })) ?? [],
+ },
},
},
{
diff --git a/apps/erp/app/modules/sales/sales.service.ts b/apps/erp/app/modules/sales/sales.service.ts
index b011ea99ab..db0ac13112 100644
--- a/apps/erp/app/modules/sales/sales.service.ts
+++ b/apps/erp/app/modules/sales/sales.service.ts
@@ -45,7 +45,7 @@ import type {
salesRfqValidator,
selectedLinesValidator,
} from "./sales.models";
-import { Quotation, SalesOrder, SalesRFQ } from "./types";
+import type { Quotation, SalesOrder, SalesRFQ } from "./types";
export async function closeSalesOrder(
client: SupabaseClient<Database>,
@@ -1163,6 +1163,16 @@ export async function getSalesOrders(
return query;
}
+export async function getSalesOrdersList(
+ client: SupabaseClient<Database>,
+ companyId: string
+) {
+ return client
+ .from("salesOrder")
+ .select("id, salesOrderId")
+ .eq("companyId", companyId);
+}
+
export async function getSalesOrderPayment(
client: SupabaseClient<Database>,
salesOrderId: string
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 27951b4f5a..dac40a2e67 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -60,6 +60,7 @@ export const path = {
`${api}/settings/sequence/rollback?table=${table}&currentSequence=${id}`
),
salesKpi: (key: string) => generatePath(`${api}/sales/kpi/${key}`),
+ salesOrders: `${api}/sales/orders`,
scrapReasons: `${api}/production/scrap-reasons`,
sequences: (table: string) => `${api}/settings/sequences?table=${table}`,
serialNumbers: (itemId: string, isReadOnly: boolean) =>