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.

Treat user ID as approver in group check

Sidwebworks8f34489a509d
diff --git a/apps/erp/app/modules/shared/shared.service.ts b/apps/erp/app/modules/shared/shared.service.ts
index 35c83538be..495523937a 100644
--- a/apps/erp/app/modules/shared/shared.service.ts
+++ b/apps/erp/app/modules/shared/shared.service.ts
@@ -129,6 +129,12 @@ export async function canApproveRequest(
return false;
}
+ // Check if user ID is directly in approverGroupIds (for individual approvers)
+ if (approverGroupIds.includes(userId)) {
+ return true;
+ }
+
+ // Check if user belongs to any of the approver groups
return approverGroupIds.some((groupId) => userGroupIds.includes(groupId));
});
}
@@ -163,6 +169,12 @@ export async function canApproveRequestInWindow(
return false;
}
+ // Check if user ID is directly in approverGroupIds (for individual approvers)
+ if (approverGroupIds.includes(userId)) {
+ return true;
+ }
+
+ // Check if user belongs to any of the approver groups
const userGroups = await client.rpc("groups_for_user", { uid: userId });
const userGroupIds = userGroups.data || [];
return approverGroupIds.some((groupId) => userGroupIds.includes(groupId));