Skip to content

Commit

Permalink
moved submodules to corresponding modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Kworz committed May 8, 2024
1 parent f00cf86 commit a74d683
Show file tree
Hide file tree
Showing 26 changed files with 167 additions and 39 deletions.
35 changes: 25 additions & 10 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,47 @@ model user_group {
admin Boolean @default(false)
name String
/// SCM permission zone
scm permission?
article permission?
supplier permission?
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[]
Expand Down
10 changes: 9 additions & 1 deletion src/lib/i18n/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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": {
Expand Down
13 changes: 12 additions & 1 deletion src/lib/i18n/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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": {
Expand Down
38 changes: 29 additions & 9 deletions src/lib/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<user_group, "admin" | "id" | "name">;
export const groupPermissions: Array<GroupPermissions> = ["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<GroupPermissions> = ["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
Expand Down Expand Up @@ -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",
Expand All @@ -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<string, GroupPermissions>;

const route = Object.keys(associatedPermissionForRoute).find(apfr => routeId === apfr) as keyof typeof associatedPermissionForRoute | undefined;

Expand Down
28 changes: 19 additions & 9 deletions src/routes/app/(accounting)/accounting/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
</script>

<Flex gap={0} class="h-screen w-screen overflow-hidden" direction={$page.data.userSettings?.app_menu_left === false ? "rowReverse" : "row"}>
<Menu>
<MenuItem icon={$page.data.userSettings?.app_menu_left ? ChevronLeft : ChevronRight} href="/app" label="Accueil" />

<MenuSeparator />
<MenuItem icon={ChartPie} href="/app/accounting/" label="Santé financière" />
<MenuItem icon={ArrowUpOnSquareStack} href="/app/accounting/transactions/" label="Transactions" />
<MenuItem icon={DocumentMagnifyingGlass} href="/app/accounting/quotations" label="Devis" />
<MenuItem icon={Banknotes} href="/app/accounting/invoices" label="Interets" />
<MenuItem icon={Document} href="/app/accounting/orders" label="Factures" />
<MenuItem icon={$page.data.userSettings?.app_menu_left ? ChevronLeft : ChevronRight} href="/app" label={$_('app.generic.home')} />

<MenuItem icon={ChartPie} href="/app/accounting/" label={$_('app.generic.accounting')} />

<MenuGroup items={[
!validatePermission(data.user, "transactions", "r") ? undefined : { icon: ArrowUpOnSquareStack, href: "/app/accounting/transactions/", label: $_('app.generic.transactions') },
]}>{$_('app.generic.financial_flows')} </MenuGroup>

<MenuGroup items={[
!validatePermission(data.user, "quotations", "r") ? undefined : { icon: DocumentMagnifyingGlass, href: "/app/accounting/quotations", label: $_('app.generic.quotations') },
!validatePermission(data.user, "invoices", "r") ? undefined : { icon: Banknotes, href: "/app/accounting/invoices", label: $_('app.generic.invoices') },
!validatePermission(data.user, "orders", "r") ? undefined : { icon: Document, href: "/app/accounting/orders", label: $_('app.generic.orders') },
]}>{$_('app.generic.accounting')}</MenuGroup>

</Menu>

Expand Down
23 changes: 15 additions & 8 deletions src/routes/app/(accounting)/accounting/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<script lang="ts">
import Wrapper from "$lib/components/generics/containers/Wrapper.svelte";
import { _ } from "svelte-i18n";
</script>

<h1>Santé financière - mink</h1>
<p>Analysez la santé de votre société</p>
<svelte:head>
<title>{$_('app.generic.accounting')} - mink</title>
</svelte:head>

<div class="grid grid-cols-2 gap-6 mt-6">
<h1>{$_('app.generic.accounting')}</h1>
<p>{$_('app.accounting.description')}</p>

<Wrapper /> <!-- Charts -->
<Wrapper /> <!-- Charts -->

<div class="grid grid-cols-2 gap-6 mt-6">
<Wrapper>
<h2>Flux entrants</h2>
<!-- Charts -->
</Wrapper>
<Wrapper>
<h2>Flux sortants</h2>
<!-- Charts -->
</Wrapper>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
<TableCell>
<a href="/app/scm/orders/{order.id}">
<a href="/app/accounting/orders/{order.id}">
<Flex direction="col" gap={1}>
<span>{order.name}</span>
<span class="text-sm text-zinc-200">{order.sub_id}</span>
Expand Down
1 change: 1 addition & 0 deletions src/routes/app/(base)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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')}</MenuSeparator>

<MenuSeparator items={[
Expand Down
16 changes: 16 additions & 0 deletions src/routes/app/(pm)/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { LayoutServerLoad } from "./$types";

export const ssr = true;

export const load = (async ({ locals }) => {

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;
30 changes: 30 additions & 0 deletions src/routes/app/(pm)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script lang="ts">
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 { ChevronLeft, ChevronRight, CircleStack, Truck } from "@steeze-ui/heroicons";
import type { LayoutData } from "./$types";
import { _ } from "svelte-i18n";
import { validatePermission } from "$lib/permission";
export let data: LayoutData;
</script>

<Flex gap={0} class="h-screen w-screen overflow-hidden" direction={data.userSettings?.app_menu_left === false ? "rowReverse" : "row"}>
<Menu>
<MenuItem icon={data.userSettings?.app_menu_left ? ChevronLeft : ChevronRight} href="/app" label={$_('app.generic.home')} />

<MenuSeparator items={[
!validatePermission(data.user, "project", "r") ? undefined : { icon: CircleStack, href: "/app/pm/projects", label: $_('app.generic.projects') },
!validatePermission(data.user, "manufacturing_order", "r") ? undefined : { icon: Truck, href: "/app/pm/manufacturing_orders", label: $_('app.generic.manufacturing_orders') },
]}>{$_('app.generic.project_manager')}</MenuSeparator>
</Menu>

<div class="relative grow overflow-x-hidden overflow-y-scroll p-10 pl-6" id="main_content">
<slot />
</div>
</Flex>
10 changes: 10 additions & 0 deletions src/routes/app/(pm)/pm/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script lang="ts">
import { _ } from "svelte-i18n";
</script>

<svelte:head>
<title>{$_('app.generic.project_manager')} - mink</title>
</svelte:head>

<h1>{$_('app.generic.project_manager')}</h1>
<p>{$_('app.pm.description')}</p>

0 comments on commit a74d683

Please sign in to comment.