Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: company-scoped assigees for sales documents

Brad Barbindc41d0b1ec3d
diff --git a/apps/erp/app/modules/sales/sales.service.ts b/apps/erp/app/modules/sales/sales.service.ts
index f2784160ec..355b1d46dc 100644
--- a/apps/erp/app/modules/sales/sales.service.ts
+++ b/apps/erp/app/modules/sales/sales.service.ts
@@ -899,12 +899,25 @@ export async function getQuoteShipment(
export async function getSalesDocumentsAssignedToMe(
client: SupabaseClient<Database>,
- userId: string
+ userId: string,
+ companyId: string
) {
const [salesOrders, quotes, rfqs] = await Promise.all([
- client.from("salesOrder").select("*").eq("assignee", userId),
- client.from("quote").select("*").eq("assignee", userId),
- client.from("salesRfq").select("*").eq("assignee", userId),
+ client
+ .from("salesOrder")
+ .select("*")
+ .eq("assignee", userId)
+ .eq("companyId", companyId),
+ client
+ .from("quote")
+ .select("*")
+ .eq("assignee", userId)
+ .eq("companyId", companyId),
+ client
+ .from("salesRfq")
+ .select("*")
+ .eq("assignee", userId)
+ .eq("companyId", companyId),
]);
const merged = [