From a74d683266d98bc61bd999ad5dc9f8488b559a6f Mon Sep 17 00:00:00 2001 From: Kworz Date: Wed, 8 May 2024 11:26:19 +0200 Subject: [PATCH] moved submodules to corresponding modules --- prisma/schema.prisma | 35 ++++++++++++----- src/lib/i18n/lang/en.json | 10 ++++- src/lib/i18n/lang/fr.json | 13 ++++++- src/lib/permission.ts | 38 ++++++++++++++----- .../(accounting)/accounting/+layout.svelte | 28 +++++++++----- .../app/(accounting)/accounting/+page.svelte | 23 +++++++---- .../accounting}/orders/+page.server.ts | 0 .../accounting}/orders/+page.svelte | 2 +- .../accounting}/orders/OrderState.svelte | 0 .../accounting}/orders/[id]/+page.server.ts | 0 .../accounting}/orders/[id]/+page.svelte | 0 .../accounting}/orders/[id]/export/+server.ts | 0 src/routes/app/(base)/+layout.svelte | 1 + src/routes/app/(pm)/+layout.server.ts | 16 ++++++++ src/routes/app/(pm)/+layout.svelte | 30 +++++++++++++++ src/routes/app/(pm)/pm/+page.svelte | 10 +++++ .../pm}/manufacturing_orders/+page.server.ts | 0 .../pm}/manufacturing_orders/+page.svelte | 0 .../manufacturing_orders/[id]/+page.server.ts | 0 .../manufacturing_orders/[id]/+page.svelte | 0 .../manufacturing_orders/new/+page.server.ts | 0 .../pm}/manufacturing_orders/new/+page.svelte | 0 .../scm => (pm)/pm}/projects/+page.server.ts | 0 .../scm => (pm)/pm}/projects/+page.svelte | 0 .../pm}/projects/[id]/+page.server.ts | 0 .../pm}/projects/[id]/+page.svelte | 0 26 files changed, 167 insertions(+), 39 deletions(-) rename src/routes/app/{(scm)/scm => (accounting)/accounting}/orders/+page.server.ts (100%) rename src/routes/app/{(scm)/scm => (accounting)/accounting}/orders/+page.svelte (98%) rename src/routes/app/{(scm)/scm => (accounting)/accounting}/orders/OrderState.svelte (100%) rename src/routes/app/{(scm)/scm => (accounting)/accounting}/orders/[id]/+page.server.ts (100%) rename src/routes/app/{(scm)/scm => (accounting)/accounting}/orders/[id]/+page.svelte (100%) rename src/routes/app/{(scm)/scm => (accounting)/accounting}/orders/[id]/export/+server.ts (100%) create mode 100644 src/routes/app/(pm)/+layout.server.ts create mode 100644 src/routes/app/(pm)/+layout.svelte create mode 100644 src/routes/app/(pm)/pm/+page.svelte rename src/routes/app/{(scm)/scm => (pm)/pm}/manufacturing_orders/+page.server.ts (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/manufacturing_orders/+page.svelte (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/manufacturing_orders/[id]/+page.server.ts (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/manufacturing_orders/[id]/+page.svelte (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/manufacturing_orders/new/+page.server.ts (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/manufacturing_orders/new/+page.svelte (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/projects/+page.server.ts (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/projects/+page.svelte (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/projects/[id]/+page.server.ts (100%) rename src/routes/app/{(scm)/scm => (pm)/pm}/projects/[id]/+page.svelte (100%) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c7bdf409..d729107f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -50,6 +50,7 @@ model user_group { admin Boolean @default(false) name String + /// SCM permission zone scm permission? article permission? @@ -57,25 +58,39 @@ model user_group { store permission? buylist permission? assembly permission? - inbound_supplies permission? - fabrication_orders permission? + inbound_supply permission? + /// Project permission zone + pm permission? + + project permission? + manufacturing_order permission? + + /// CRM permission zone crm permission? - leads permission? - companies permission? - contacts permission? - interests permission? + lead permission? + company permission? + contact permission? + interest permission? + /// Accounting permission zone accounting permission? - orders permission? - invoices permission? - payments permission? - transactions permission? + order permission? + invoice permission? + transaction permission? + /// Tools permission zone tools permission? + qr_code_scanner permission? + + /// Settings permission zone + settings permission? + + user permission? + user_group permission? users user[] diff --git a/src/lib/i18n/lang/en.json b/src/lib/i18n/lang/en.json index 1f9d0402..aa08774d 100644 --- a/src/lib/i18n/lang/en.json +++ b/src/lib/i18n/lang/en.json @@ -123,7 +123,12 @@ "user": "User", "user_count": "Users count", "generic": "Generic", - "lang": "Language" + "lang": "Language", + "financial_flows": "Finance flows", + "transactions": "Transactions", + "invoices": "Invoices", + "quotations": "Quotations", + "project_manager": "Project manager" }, "time": { "hours": "Hours" @@ -195,6 +200,9 @@ "personal_parameters": "My profile parameters", "mink_personal_parameters": "Personal mink parameters", "updated_personal_parameters": "Updated settings" + }, + "pm": { + "description": "Manage all of your company projects" } }, "scm": { diff --git a/src/lib/i18n/lang/fr.json b/src/lib/i18n/lang/fr.json index 7e07fb6d..764840e7 100644 --- a/src/lib/i18n/lang/fr.json +++ b/src/lib/i18n/lang/fr.json @@ -172,7 +172,12 @@ "user": "Utilisateur", "user_count": "Nombre d'utilisateurs", "generic": "Général", - "lang": "Langue" + "lang": "Langue", + "financial_flows": "Fluxs financiers", + "transactions": "Transactions", + "invoices": "Factures", + "quotations": "Devis", + "project_manager": "Gestionnaire d'affaires" }, "time": { "hours": "Heures" @@ -270,6 +275,12 @@ "personal_parameters": "Paramètres de mon profil", "mink_personal_parameters": "Paramètres personels de mink", "updated_personal_parameters": "Paramètres mis à jour" + }, + "accounting": { + "description": "Évaluez la santé comptable de votre société, retrouvez ici le résumé des flux jours par jours." + }, + "pm": { + "description": "Gerez les divers projets de votre société" } }, "scm": { diff --git a/src/lib/permission.ts b/src/lib/permission.ts index eabfcd5a..66fdcd8b 100644 --- a/src/lib/permission.ts +++ b/src/lib/permission.ts @@ -2,7 +2,7 @@ import type { userWithIncludes } from "$lib/components/derived/user/user"; import type { user_group } from "@prisma/client"; export type GroupPermissions = keyof Omit; -export const groupPermissions: Array = ["scm", "article", "supplier", "store", "buylist", "assembly", "inbound_supplies", "fabrication_orders", "crm", "leads", "companies", "contacts", "interests", "accounting", "orders", "invoices", "payments", "transactions", "tools", "qr_code_scanner"]; +export const groupPermissions: Array = ["scm", "article", "supplier", "store", "buylist", "assembly", "inbound_supply", "pm", "project", "manufacturing_order", "crm", "lead", "company", "contact", "interest", "accounting", "order", "invoice", "transaction", "tools", "qr_code_scanner", "settings", "user", "user_group"]; /** * Check if the given user has the needed permission to access the given path @@ -45,6 +45,7 @@ export const validateRoute = (routeId: string, user: userWithIncludes | null): b /** @todo Complete this list as each route is created */ const associatedPermissionForRoute = { + /// SCM Permission zone "/app/(scm)/scm": "scm", "/app/(scm)/scm/articles": "article", @@ -56,26 +57,45 @@ export const validateRoute = (routeId: string, user: userWithIncludes | null): b "/app/(scm)/scm/assemblies": "assembly", "/app/(scm)/scm/assemblies/[id]": "assembly", - "/app/(scm)/scm/inbound_supplies": "inbound_supplies", + "/app/(scm)/scm/inbound_supplies": "inbound_supply", "/app/(scm)/scm/lists": "buylist", - "/app/(scm)/scm/manufacturing_orders": "manufacturing_orders", - "/app/(scm)/scm/orders": "orders", "/app/(scm)/scm/suppliers": "supplier", + /// PROJECTS Permission zone + "/app/(pm)/pm": "pm", + + "/app/(pm)/pm/projects": "project", + "/app/(pm)/pm/projects/[id]": "project", + + "/app/(pm)/pm/manufacturing_orders": "manufacturing_order", + "/app/(pm)/pm/manufacturing_orders/[id]": "manufacturing_order", + + /// CRM Permission zone "/app/(crm)/crm": "crm", + /// ACCOUNTING Permission zone "/app/(accounting)/accounting": "accounting", + "/app/(accounting)/accounting/orders": "order", + "/app/(accounting)/accounting/orders/[id]": "order", + + "/app/(accounting)/accounting/invoices": "invoice", + "/app/(accounting)/accounting/invoices/[id]": "invoice", + + "/app/(accounting)/accounting/transactions": "transaction", + "/app/(accounting)/accounting/transactions/[id]": "transaction", + /// SETTINGS Permission zone "/app/(settings)/settings": "settings", - "/app/(settings)/settings/users": "users", - "/app/(settings)/settings/users/[id]": "users", - "/app/(settings)/settings/users_groups": "users_groups", - "/app/(settings)/settings/users_groups/[id]": "users_groups", + "/app/(settings)/settings/users": "user", + "/app/(settings)/settings/users/[id]": "user", + "/app/(settings)/settings/users_groups": "user_group", + "/app/(settings)/settings/users_groups/[id]": "user_group", + /// TOOLS Permission zone "/app/(tools)/tools": "tools", "/app/(tools)/tools/qr_scanner": "qr_code_scanner", - }; + } satisfies Record; const route = Object.keys(associatedPermissionForRoute).find(apfr => routeId === apfr) as keyof typeof associatedPermissionForRoute | undefined; diff --git a/src/routes/app/(accounting)/accounting/+layout.svelte b/src/routes/app/(accounting)/accounting/+layout.svelte index c4c51472..ee9a5b2b 100644 --- a/src/routes/app/(accounting)/accounting/+layout.svelte +++ b/src/routes/app/(accounting)/accounting/+layout.svelte @@ -4,21 +4,31 @@ import Flex from "$lib/components/generics/layout/flex.svelte"; import Menu from "$lib/components/generics/menu/Menu.svelte"; import MenuItem from "$lib/components/generics/menu/MenuItem.svelte"; - import MenuSeparator from "$lib/components/generics/menu/MenuGroup.svelte"; + import MenuGroup from "$lib/components/generics/menu/MenuGroup.svelte"; import { page } from "$app/stores"; + import { _ } from "svelte-i18n"; + import { validatePermission } from "$lib/permission"; + import type { LayoutData } from "./$types"; + + export let data: LayoutData; - - - - - - - - + + + + + {$_('app.generic.financial_flows')} + + {$_('app.generic.accounting')} diff --git a/src/routes/app/(accounting)/accounting/+page.svelte b/src/routes/app/(accounting)/accounting/+page.svelte index e5292f25..b60a3b28 100644 --- a/src/routes/app/(accounting)/accounting/+page.svelte +++ b/src/routes/app/(accounting)/accounting/+page.svelte @@ -1,15 +1,22 @@ -

Santé financière - mink

-

Analysez la santé de votre société

+ + {$_('app.generic.accounting')} - mink + -
+

{$_('app.generic.accounting')}

+

{$_('app.accounting.description')}

- - - +
+ +

Flux entrants

+ +
+ +

Flux sortants

+ +
\ No newline at end of file diff --git a/src/routes/app/(scm)/scm/orders/+page.server.ts b/src/routes/app/(accounting)/accounting/orders/+page.server.ts similarity index 100% rename from src/routes/app/(scm)/scm/orders/+page.server.ts rename to src/routes/app/(accounting)/accounting/orders/+page.server.ts diff --git a/src/routes/app/(scm)/scm/orders/+page.svelte b/src/routes/app/(accounting)/accounting/orders/+page.svelte similarity index 98% rename from src/routes/app/(scm)/scm/orders/+page.svelte rename to src/routes/app/(accounting)/accounting/orders/+page.svelte index 8a1325b6..b89495b8 100644 --- a/src/routes/app/(scm)/scm/orders/+page.svelte +++ b/src/routes/app/(accounting)/accounting/orders/+page.svelte @@ -69,7 +69,7 @@ {#each data.orders as order} {@const orderGrossPrice = order.order_rows.reduce((p, c) => p = p + c.needed_quantity * (c.ack_price ?? 0), 0)} - + {order.name} {order.sub_id} diff --git a/src/routes/app/(scm)/scm/orders/OrderState.svelte b/src/routes/app/(accounting)/accounting/orders/OrderState.svelte similarity index 100% rename from src/routes/app/(scm)/scm/orders/OrderState.svelte rename to src/routes/app/(accounting)/accounting/orders/OrderState.svelte diff --git a/src/routes/app/(scm)/scm/orders/[id]/+page.server.ts b/src/routes/app/(accounting)/accounting/orders/[id]/+page.server.ts similarity index 100% rename from src/routes/app/(scm)/scm/orders/[id]/+page.server.ts rename to src/routes/app/(accounting)/accounting/orders/[id]/+page.server.ts diff --git a/src/routes/app/(scm)/scm/orders/[id]/+page.svelte b/src/routes/app/(accounting)/accounting/orders/[id]/+page.svelte similarity index 100% rename from src/routes/app/(scm)/scm/orders/[id]/+page.svelte rename to src/routes/app/(accounting)/accounting/orders/[id]/+page.svelte diff --git a/src/routes/app/(scm)/scm/orders/[id]/export/+server.ts b/src/routes/app/(accounting)/accounting/orders/[id]/export/+server.ts similarity index 100% rename from src/routes/app/(scm)/scm/orders/[id]/export/+server.ts rename to src/routes/app/(accounting)/accounting/orders/[id]/export/+server.ts diff --git a/src/routes/app/(base)/+layout.svelte b/src/routes/app/(base)/+layout.svelte index e8d91639..db03a903 100644 --- a/src/routes/app/(base)/+layout.svelte +++ b/src/routes/app/(base)/+layout.svelte @@ -24,6 +24,7 @@ !validatePermission(data.user, "article", "r") ? undefined : { icon: CircleStack, href: "/app/scm/articles", label: $_('app.generic.scm') }, !validatePermission(data.user, "crm", "r") ? undefined : { icon: UserCircle, href: "/app/crm/", label: $_('app.generic.crm') }, !validatePermission(data.user, "accounting", "r") ? undefined : { icon: Banknotes, href: "/app/accounting/", label: $_('app.generic.accounting') }, + !validatePermission(data.user, "pm", "r") ? undefined : { icon: CircleStack, href: "/app/pm/", label: $_('app.generic.project_manager')} ]}>{$_('app.generic.modules')} { + + const inboundSuppliesCount = await locals.prisma.scm_order_rows.count({ where: { order: { state: { in: ["acknowledged"] }}, received_quantity: { lt: locals.prisma.scm_order_rows.fields.needed_quantity } }}); + + return { + session: locals.session, + user: locals.user, + appSettings: locals.appSettings, + inboundSuppliesCount + } + +}) satisfies LayoutServerLoad; \ No newline at end of file diff --git a/src/routes/app/(pm)/+layout.svelte b/src/routes/app/(pm)/+layout.svelte new file mode 100644 index 00000000..2ddf9454 --- /dev/null +++ b/src/routes/app/(pm)/+layout.svelte @@ -0,0 +1,30 @@ + + + + + + + {$_('app.generic.project_manager')} + + +
+ +
+
\ No newline at end of file diff --git a/src/routes/app/(pm)/pm/+page.svelte b/src/routes/app/(pm)/pm/+page.svelte new file mode 100644 index 00000000..251c4646 --- /dev/null +++ b/src/routes/app/(pm)/pm/+page.svelte @@ -0,0 +1,10 @@ + + + + {$_('app.generic.project_manager')} - mink + + +

{$_('app.generic.project_manager')}

+

{$_('app.pm.description')}

\ No newline at end of file diff --git a/src/routes/app/(scm)/scm/manufacturing_orders/+page.server.ts b/src/routes/app/(pm)/pm/manufacturing_orders/+page.server.ts similarity index 100% rename from src/routes/app/(scm)/scm/manufacturing_orders/+page.server.ts rename to src/routes/app/(pm)/pm/manufacturing_orders/+page.server.ts diff --git a/src/routes/app/(scm)/scm/manufacturing_orders/+page.svelte b/src/routes/app/(pm)/pm/manufacturing_orders/+page.svelte similarity index 100% rename from src/routes/app/(scm)/scm/manufacturing_orders/+page.svelte rename to src/routes/app/(pm)/pm/manufacturing_orders/+page.svelte diff --git a/src/routes/app/(scm)/scm/manufacturing_orders/[id]/+page.server.ts b/src/routes/app/(pm)/pm/manufacturing_orders/[id]/+page.server.ts similarity index 100% rename from src/routes/app/(scm)/scm/manufacturing_orders/[id]/+page.server.ts rename to src/routes/app/(pm)/pm/manufacturing_orders/[id]/+page.server.ts diff --git a/src/routes/app/(scm)/scm/manufacturing_orders/[id]/+page.svelte b/src/routes/app/(pm)/pm/manufacturing_orders/[id]/+page.svelte similarity index 100% rename from src/routes/app/(scm)/scm/manufacturing_orders/[id]/+page.svelte rename to src/routes/app/(pm)/pm/manufacturing_orders/[id]/+page.svelte diff --git a/src/routes/app/(scm)/scm/manufacturing_orders/new/+page.server.ts b/src/routes/app/(pm)/pm/manufacturing_orders/new/+page.server.ts similarity index 100% rename from src/routes/app/(scm)/scm/manufacturing_orders/new/+page.server.ts rename to src/routes/app/(pm)/pm/manufacturing_orders/new/+page.server.ts diff --git a/src/routes/app/(scm)/scm/manufacturing_orders/new/+page.svelte b/src/routes/app/(pm)/pm/manufacturing_orders/new/+page.svelte similarity index 100% rename from src/routes/app/(scm)/scm/manufacturing_orders/new/+page.svelte rename to src/routes/app/(pm)/pm/manufacturing_orders/new/+page.svelte diff --git a/src/routes/app/(scm)/scm/projects/+page.server.ts b/src/routes/app/(pm)/pm/projects/+page.server.ts similarity index 100% rename from src/routes/app/(scm)/scm/projects/+page.server.ts rename to src/routes/app/(pm)/pm/projects/+page.server.ts diff --git a/src/routes/app/(scm)/scm/projects/+page.svelte b/src/routes/app/(pm)/pm/projects/+page.svelte similarity index 100% rename from src/routes/app/(scm)/scm/projects/+page.svelte rename to src/routes/app/(pm)/pm/projects/+page.svelte diff --git a/src/routes/app/(scm)/scm/projects/[id]/+page.server.ts b/src/routes/app/(pm)/pm/projects/[id]/+page.server.ts similarity index 100% rename from src/routes/app/(scm)/scm/projects/[id]/+page.server.ts rename to src/routes/app/(pm)/pm/projects/[id]/+page.server.ts diff --git a/src/routes/app/(scm)/scm/projects/[id]/+page.svelte b/src/routes/app/(pm)/pm/projects/[id]/+page.svelte similarity index 100% rename from src/routes/app/(scm)/scm/projects/[id]/+page.svelte rename to src/routes/app/(pm)/pm/projects/[id]/+page.svelte