diff --git a/backend/db/migrations/0021_admin_user_flag.sql b/backend/db/migrations/0021_admin_user_flag.sql new file mode 100644 index 0000000..a3b719e --- /dev/null +++ b/backend/db/migrations/0021_admin_user_flag.sql @@ -0,0 +1,2 @@ +ALTER TABLE "auth_users" +ADD COLUMN "is_admin" boolean NOT NULL DEFAULT false; diff --git a/backend/src/routes/admin.ts b/backend/src/routes/admin.ts index b133cfb..1f663c9 100644 --- a/backend/src/routes/admin.ts +++ b/backend/src/routes/admin.ts @@ -30,6 +30,7 @@ export default async function adminRoutes(server: FastifyInstance) { const createTenantSeeds = async (tenantId: number, createdBy: string) => { const currentYear = new Date().getFullYear(); + const timestamp = new Date(); const insertedTags = await server.db .insert(filetags) @@ -84,77 +85,148 @@ export default async function adminRoutes(server: FastifyInstance) { const deliveryTag = insertedTags.find((tag) => tag.createdDocumentType === "deliveryNotes"); const incomingInvoiceTag = insertedTags.find((tag) => tag.incomingDocumentType === "invoices"); - await server.db + const insertedFolders = await server.db .insert(folders) .values([ { tenant: tenantId, name: "Ausgangsrechnungen", + function: "yearSubCategory", + icon: "i-heroicons-document-text", + isSystemUsed: true, + updatedAt: timestamp, + updatedBy: createdBy, + }, + { + tenant: tenantId, + name: "Angebote", + function: "yearSubCategory", + icon: "i-heroicons-document-duplicate", + isSystemUsed: true, + updatedAt: timestamp, + updatedBy: createdBy, + }, + { + tenant: tenantId, + name: "Auftragsbestätigungen", + function: "yearSubCategory", + icon: "i-heroicons-clipboard-document-check", + isSystemUsed: true, + updatedAt: timestamp, + updatedBy: createdBy, + }, + { + tenant: tenantId, + name: "Lieferscheine", + function: "yearSubCategory", + icon: "i-heroicons-truck", + isSystemUsed: true, + updatedAt: timestamp, + updatedBy: createdBy, + }, + { + tenant: tenantId, + name: "Eingangsrechnungen", + function: "yearSubCategory", + icon: "i-heroicons-inbox-arrow-down", + isSystemUsed: true, + updatedAt: timestamp, + updatedBy: createdBy, + }, + { + tenant: tenantId, + name: "Belege Bankeinzahlung", + function: "yearSubCategory", + icon: "i-heroicons-banknotes", + isSystemUsed: true, + updatedAt: timestamp, + updatedBy: createdBy, + }, + ]) + .returning({ + id: folders.id, + name: folders.name, + }); + + const folderByName = new Map(insertedFolders.map((folder) => [folder.name, folder.id])); + + await server.db + .insert(folders) + .values([ + { + tenant: tenantId, + name: String(currentYear), + parent: folderByName.get("Ausgangsrechnungen"), function: "invoices", year: currentYear, icon: "i-heroicons-document-text", standardFiletype: invoiceTag?.id, standardFiletypeIsOptional: false, isSystemUsed: true, - updatedAt: new Date(), + updatedAt: timestamp, updatedBy: createdBy, }, { tenant: tenantId, - name: "Angebote", + name: String(currentYear), + parent: folderByName.get("Angebote"), function: "quotes", year: currentYear, icon: "i-heroicons-document-duplicate", standardFiletype: quoteTag?.id, standardFiletypeIsOptional: false, isSystemUsed: true, - updatedAt: new Date(), + updatedAt: timestamp, updatedBy: createdBy, }, { tenant: tenantId, - name: "Auftragsbestätigungen", + name: String(currentYear), + parent: folderByName.get("Auftragsbestätigungen"), function: "confirmationOrders", year: currentYear, icon: "i-heroicons-clipboard-document-check", standardFiletype: confirmationTag?.id, standardFiletypeIsOptional: false, isSystemUsed: true, - updatedAt: new Date(), + updatedAt: timestamp, updatedBy: createdBy, }, { tenant: tenantId, - name: "Lieferscheine", + name: String(currentYear), + parent: folderByName.get("Lieferscheine"), function: "deliveryNotes", year: currentYear, icon: "i-heroicons-truck", standardFiletype: deliveryTag?.id, standardFiletypeIsOptional: false, isSystemUsed: true, - updatedAt: new Date(), + updatedAt: timestamp, updatedBy: createdBy, }, { tenant: tenantId, - name: "Eingangsrechnungen", + name: String(currentYear), + parent: folderByName.get("Eingangsrechnungen"), function: "incomingInvoices", year: currentYear, icon: "i-heroicons-inbox-arrow-down", standardFiletype: incomingInvoiceTag?.id, standardFiletypeIsOptional: false, isSystemUsed: true, - updatedAt: new Date(), + updatedAt: timestamp, updatedBy: createdBy, }, { tenant: tenantId, - name: "Belege Bankeinzahlung", + name: String(currentYear), + parent: folderByName.get("Belege Bankeinzahlung"), function: "deposit", year: currentYear, icon: "i-heroicons-banknotes", isSystemUsed: true, - updatedAt: new Date(), + updatedAt: timestamp, updatedBy: createdBy, }, ]); diff --git a/frontend/pages/settings/admin.vue b/frontend/pages/settings/admin.vue new file mode 100644 index 0000000..9f21a21 --- /dev/null +++ b/frontend/pages/settings/admin.vue @@ -0,0 +1,888 @@ + + + + +