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: quality module and navigation

Brad Barbinbb040f9fec15
diff --git a/apps/erp/app/hooks/useModules.tsx b/apps/erp/app/hooks/useModules.tsx
index 6635e50107..de8f0b945e 100644
--- a/apps/erp/app/hooks/useModules.tsx
+++ b/apps/erp/app/hooks/useModules.tsx
@@ -3,6 +3,7 @@ import {
LuCrown,
LuFactory,
LuFiles,
+ LuFolderCheck,
LuLandmark,
LuSettings,
LuShield,
@@ -49,13 +50,12 @@ export function useModules() {
to: path.to.purchasing,
icon: LuShoppingCart,
},
-
- // {
- // permission: "messages",
- // name: "Messaging",
- // to: path.to.messaging,
- // icon: BiMessage,
- // },
+ {
+ permission: "quality",
+ name: "Quality",
+ to: path.to.quality,
+ icon: LuFolderCheck,
+ },
{
permission: "accounting",
name: "Accounting",
diff --git a/apps/erp/app/modules/quality/index.ts b/apps/erp/app/modules/quality/index.ts
new file mode 100644
index 0000000000..81feefa273
--- /dev/null
+++ b/apps/erp/app/modules/quality/index.ts
@@ -0,0 +1,3 @@
+export * from "./quality.models";
+export * from "./quality.service";
+export * from "./types";
diff --git a/apps/erp/app/modules/quality/quality.models.ts b/apps/erp/app/modules/quality/quality.models.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/apps/erp/app/modules/quality/quality.service.ts b/apps/erp/app/modules/quality/quality.service.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/apps/erp/app/modules/quality/types.ts b/apps/erp/app/modules/quality/types.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/apps/erp/app/modules/quality/ui/useQualitySubmodules.tsx b/apps/erp/app/modules/quality/ui/useQualitySubmodules.tsx
new file mode 100644
index 0000000000..c25ef4eafb
--- /dev/null
+++ b/apps/erp/app/modules/quality/ui/useQualitySubmodules.tsx
@@ -0,0 +1,105 @@
+import {
+ LuCircleGauge,
+ LuCircleHelp,
+ LuClipboardList,
+ LuDraftingCompass,
+ LuOctagonX,
+ LuSearchCheck,
+ LuShieldX,
+ LuSpellCheck,
+} from "react-icons/lu";
+import { usePermissions } from "~/hooks";
+import { useSavedViews } from "~/hooks/useSavedViews";
+import type { AuthenticatedRouteGroup } from "~/types";
+
+const inventoryRoutes: AuthenticatedRouteGroup[] = [
+ {
+ name: "Manage",
+ routes: [
+ {
+ name: "Quality Plans",
+ to: "#",
+ icon: <LuClipboardList />,
+ },
+ {
+ name: "Issues",
+ to: "#",
+ icon: <LuShieldX />,
+ table: "qualityIssue",
+ },
+ {
+ name: "Corrective Actions",
+ to: "#",
+ icon: <LuSpellCheck />,
+ table: "correctiveAction",
+ },
+ {
+ name: "Inspections",
+ to: "#",
+ icon: <LuSearchCheck />,
+ table: "inspection",
+ },
+ ],
+ },
+ {
+ name: "Gauges",
+ routes: [
+ {
+ name: "Gauges",
+ to: "#",
+ icon: <LuDraftingCompass />,
+ },
+ {
+ name: "Calibrations",
+ to: "#",
+ icon: <LuCircleGauge />,
+ },
+ ],
+ },
+ {
+ name: "Configure",
+ routes: [
+ {
+ name: "Cause Codes",
+ to: "#",
+ icon: <LuCircleHelp />,
+ },
+ {
+ name: "Non-Conformance Codes",
+ to: "#",
+ icon: <LuOctagonX />,
+ },
+ ],
+ },
+];
+export default function useAccountingSubmodules() {
+ const permissions = usePermissions();
+ const { addSavedViewsToRoutes } = useSavedViews();
+
+ return {
+ groups: inventoryRoutes
+ .filter((group) => {
+ const filteredRoutes = group.routes.filter((route) => {
+ if (route.role) {
+ return permissions.is(route.role);
+ } else {
+ return true;
+ }
+ });
+
+ return filteredRoutes.length > 0;
+ })
+ .map((group) => ({
+ ...group,
+ routes: group.routes
+ .filter((route) => {
+ if (route.role) {
+ return permissions.is(route.role);
+ } else {
+ return true;
+ }
+ })
+ .map(addSavedViewsToRoutes),
+ })),
+ };
+}
diff --git a/apps/erp/app/routes/x+/quality+/_index.tsx b/apps/erp/app/routes/x+/quality+/_index.tsx
new file mode 100644
index 0000000000..ead3db7abf
--- /dev/null
+++ b/apps/erp/app/routes/x+/quality+/_index.tsx
@@ -0,0 +1,3 @@
+export default function QualityDashboard() {
+ return null;
+}
diff --git a/apps/erp/app/routes/x+/quality+/_layout.tsx b/apps/erp/app/routes/x+/quality+/_layout.tsx
new file mode 100644
index 0000000000..3396c577f9
--- /dev/null
+++ b/apps/erp/app/routes/x+/quality+/_layout.tsx
@@ -0,0 +1,37 @@
+import { VStack } from "@carbon/react";
+import { Outlet } from "@remix-run/react";
+import type { MetaFunction } from "@vercel/remix";
+import { GroupedContentSidebar } from "~/components/Layout";
+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
+import useQualitySubmodules from "~/modules/quality/ui/useQualitySubmodules";
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
+
+export const meta: MetaFunction = () => {
+ return [{ title: "Carbon | Quality" }];
+};
+
+export const handle: Handle = {
+ breadcrumb: "Quality",
+ to: path.to.quality,
+ module: "quality",
+};
+
+export const config = {
+ runtime: "nodejs",
+};
+
+export default function QualityRoute() {
+ const { groups } = useQualitySubmodules();
+
+ return (
+ <CollapsibleSidebarProvider>
+ <div className="grid grid-cols-[auto_1fr] w-full h-full">
+ <GroupedContentSidebar groups={groups} />
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
+ </div>
+ </CollapsibleSidebarProvider>
+ );
+}
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 936e58fc55..b338c94b71 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -324,6 +324,7 @@ export const path = {
convertSupplierQuoteToOrder: (id: string) =>
generatePath(`${x}/supplier-quote/${id}/convert`),
currency: (id: string) => generatePath(`${x}/accounting/currencies/${id}`),
+ correctiveActions: `${x}/quality/corrective-actions`,
currencies: `${x}/accounting/currencies`,
customer: (id: string) => generatePath(`${x}/customer/${id}`),
customerDetails: (id: string) =>
@@ -550,6 +551,7 @@ export const path = {
holiday: (id: string) => generatePath(`${x}/people/holidays/${id}`),
holidays: `${x}/people/holidays`,
import: (tableId: string) => generatePath(`${x}/shared/import/${tableId}`),
+ inspections: `${x}/quality/inspections`,
integration: (id: string) =>
generatePath(`${x}/settings/integrations/${id}`),
integrationDeactivate: (id: string) =>
@@ -787,6 +789,7 @@ export const path = {
newUom: `${x}/items/uom/new`,
newWorkCenter: `${x}/resources/work-centers/new`,
newWebhook: `${x}/settings/webhooks/new`,
+ nonConformances: `${x}/quality/non-conformances`,
noQuoteReasons: `${x}/sales/no-quote-reasons`,
noQuoteReason: (id: string) =>
generatePath(`${x}/sales/no-quote-reasons/${id}`),
@@ -871,6 +874,7 @@ export const path = {
purchaseOrders: `${x}/purchasing/orders`,
purchasing: `${x}/purchasing`,
purchasingSettings: `${x}/settings/purchasing`,
+ quality: `${x}/quality`,
quote: (id: string) => generatePath(`${x}/quote/${id}`),
quoteAssembly: (quoteId: string, lineId: string, assemblyId: string) =>
generatePath(
diff --git a/packages/database/supabase/migrations/20250325103806_quality-module.sql b/packages/database/supabase/migrations/20250325103806_quality-module.sql
new file mode 100644
index 0000000000..d6ca221e36
--- /dev/null
+++ b/packages/database/supabase/migrations/20250325103806_quality-module.sql
@@ -0,0 +1,32 @@
+ALTER TYPE module ADD VALUE 'Quality';
+DROP VIEW IF EXISTS "modules";
+CREATE VIEW "modules" AS
+ SELECT unnest(enum_range(NULL::module)) AS name;
+
+
+-- Insert Quality module permissions for Admin, Management, and Quality employee types
+INSERT INTO "employeeTypePermission" ("employeeTypeId", "module", "create", "delete", "update", "view")
+SELECT
+ et.id AS "employeeTypeId",
+ 'Quality'::module AS "module",
+ ARRAY[et."companyId"] AS "create",
+ ARRAY[et."companyId"] AS "delete",
+ ARRAY[et."companyId"] AS "update",
+ ARRAY[et."companyId"] AS "view"
+FROM "employeeType" et
+WHERE et.name IN ('Admin', 'Management', 'Quality')
+ON CONFLICT ("employeeTypeId", "module") DO NOTHING;
+
+
+-- Update userPermission table to add Quality module permissions based on Production permissions
+UPDATE "userPermission"
+SET "permissions" = "permissions" || jsonb_build_object(
+ 'quality_view', COALESCE("permissions"->'production_view', '[]'::jsonb),
+ 'quality_create', COALESCE("permissions"->'production_create', '[]'::jsonb),
+ 'quality_update', COALESCE("permissions"->'production_update', '[]'::jsonb),
+ 'quality_delete', COALESCE("permissions"->'production_delete', '[]'::jsonb)
+);
+
+
+
+