Seed global reference data from exports
All checks were successful
Build and Push Docker Images / build-frontend (push) Successful in 2m1s
Build and Push Docker Images / build-backend (push) Successful in 58s
Build and Push Docker Images / build-website (push) Successful in 35s
Build and Push Docker Images / build-central-services-api (push) Successful in 35s
Build and Push Docker Images / build-central-services-admin (push) Successful in 34s
Build and Push Docker Images / build-docs (push) Successful in 34s
All checks were successful
Build and Push Docker Images / build-frontend (push) Successful in 2m1s
Build and Push Docker Images / build-backend (push) Successful in 58s
Build and Push Docker Images / build-website (push) Successful in 35s
Build and Push Docker Images / build-central-services-api (push) Successful in 35s
Build and Push Docker Images / build-central-services-admin (push) Successful in 34s
Build and Push Docker Images / build-docs (push) Successful in 34s
This commit is contained in:
13742
backend/db/migrations/0058_global_reference_data.sql
Normal file
13742
backend/db/migrations/0058_global_reference_data.sql
Normal file
File diff suppressed because one or more lines are too long
@@ -386,6 +386,13 @@
|
||||
"when": 1784635200000,
|
||||
"tag": "0057_incoming_invoice_einvoice_metadata",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 55,
|
||||
"version": "7",
|
||||
"when": 1786023052994,
|
||||
"tag": "0058_global_reference_data",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { and, eq } from "drizzle-orm"
|
||||
import bcrypt from "bcrypt"
|
||||
|
||||
import {
|
||||
accounts,
|
||||
authProfiles,
|
||||
authRoles,
|
||||
authRolePermissions,
|
||||
@@ -19,7 +18,6 @@ import {
|
||||
teams,
|
||||
tenants,
|
||||
texttemplates,
|
||||
units,
|
||||
} from "../../db/schema"
|
||||
import { matrixService } from "./matrix.service"
|
||||
|
||||
@@ -52,34 +50,13 @@ const adminPermissions = [
|
||||
"organisation.tasks.write",
|
||||
]
|
||||
|
||||
const defaultUnits = [
|
||||
{ name: "Stück", single: "Stück", multiple: "Stück", short: "Stk.", step: "1" },
|
||||
{ name: "Stunde", single: "Stunde", multiple: "Stunden", short: "Std.", step: "0.25" },
|
||||
{ name: "Pauschale", single: "Pauschale", multiple: "Pauschalen", short: "Psch.", step: "1" },
|
||||
{ name: "Meter", single: "Meter", multiple: "Meter", short: "m", step: "0.1" },
|
||||
]
|
||||
|
||||
const defaultTaxTypes = [
|
||||
{ label: "Umsatzsteuer 19%", percentage: 19 },
|
||||
{ label: "Umsatzsteuer 7%", percentage: 7 },
|
||||
{ label: "Steuerfrei", percentage: 0 },
|
||||
]
|
||||
|
||||
const defaultAccounts = [
|
||||
{ number: "8400", label: "Erlöse 19% USt", accountChart: "skr03" },
|
||||
{ number: "8300", label: "Erlöse 7% USt", accountChart: "skr03" },
|
||||
{ number: "1200", label: "Bank", accountChart: "skr03" },
|
||||
{ number: "1000", label: "Kasse", accountChart: "skr03" },
|
||||
{ number: "1400", label: "Forderungen aus Lieferungen und Leistungen", accountChart: "skr03" },
|
||||
{ number: "1600", label: "Verbindlichkeiten aus Lieferungen und Leistungen", accountChart: "skr03" },
|
||||
]
|
||||
|
||||
async function ensureGlobalDefaults(server: FastifyInstance, userId: string) {
|
||||
for (const unit of defaultUnits) {
|
||||
const existing = await server.db.select({ id: units.id }).from(units).where(eq(units.name, unit.name)).limit(1)
|
||||
if (!existing.length) await server.db.insert(units).values(unit)
|
||||
}
|
||||
|
||||
for (const taxType of defaultTaxTypes) {
|
||||
const existing = await server.db
|
||||
.select({ id: taxTypes.id })
|
||||
@@ -96,20 +73,6 @@ async function ensureGlobalDefaults(server: FastifyInstance, userId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
for (const account of defaultAccounts) {
|
||||
const existing = await server.db
|
||||
.select({ id: accounts.id })
|
||||
.from(accounts)
|
||||
.where(and(eq(accounts.accountChart, account.accountChart), eq(accounts.number, account.number)))
|
||||
.limit(1)
|
||||
|
||||
if (!existing.length) {
|
||||
await server.db.insert(accounts).values({
|
||||
...account,
|
||||
description: "FEDEO Standardkonto",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureTenantFileDefaults(server: FastifyInstance, tenantId: number, userId: string) {
|
||||
|
||||
Reference in New Issue
Block a user