import {defineStore} from 'pinia'
import dayjs from "dayjs"
//import {typeOf} from "uri-js/dist/esnext/util";


import projecttype from "~/components/columnRenderings/projecttype.vue"
import contracttype from "~/components/columnRenderings/contracttype.vue"
import memberrelation from "~/components/columnRenderings/memberrelation.vue"
import customer from "~/components/columnRenderings/customer.vue"
import contact from "~/components/columnRenderings/contact.vue"
import plant from "~/components/columnRenderings/plant.vue"
import vendor from "~/components/columnRenderings/vendor.vue"
import product from "~/components/columnRenderings/product.vue"
import active from "~/components/columnRenderings/active.vue"
import sellingPrice from "~/components/columnRenderings/sellingPrice.vue";
import unit from "~/components/columnRenderings/unit.vue";
import isCompany from "~/components/columnRenderings/isCompany.vue"
import address from "~/components/columnRenderings/address.vue"
import sepa from "~/components/columnRenderings/sepa.vue"
import recurring from "~/components/columnRenderings/recurring.vue"
import description from "~/components/columnRenderings/description.vue"
import purchasePrice from "~/components/columnRenderings/purchasePrice.vue";
import project from "~/components/columnRenderings/project.vue";
import branch from "~/components/columnRenderings/branch.vue";
import costcentre from "~/components/columnRenderings/costcentre.vue";
import created_at from "~/components/columnRenderings/created_at.vue";
import profile from "~/components/columnRenderings/profile.vue";
import profiles from "~/components/columnRenderings/profiles.vue";
import vehicle from "~/components/columnRenderings/vehicle.vue"
import usePlanning from "~/components/columnRenderings/usePlanning.vue"
import sellingPriceComposedMaterial from "~/components/columnRenderings/sellingPriceComposedMaterial.vue"
import sellingPriceComposedWorker from "~/components/columnRenderings/sellingPriceComposedWorker.vue"
import sellingPriceComposedTotal from "~/components/columnRenderings/sellingPriceComposedTotal.vue"
import startDate from "~/components/columnRenderings/startDate.vue"
import endDate from "~/components/columnRenderings/endDate.vue"
import startDateTime from "~/components/columnRenderings/startDateTime.vue"
import endDateTime from "~/components/columnRenderings/endDateTime.vue"
import serviceCategories from "~/components/columnRenderings/serviceCategories.vue"
import productcategoriesWithLoad from "~/components/columnRenderings/productcategoriesWithLoad.vue"
import externalLink from "~/components/columnRenderings/externalLink.vue"
import phase from "~/components/columnRenderings/phase.vue"
import vehiclesWithLoad from "~/components/columnRenderings/vehiclesWithLoad.vue"
import inventoryitemsWithLoad from "~/components/columnRenderings/inventoryitemsWithLoad.vue"
import inventoryitemgroupsWithLoad from "~/components/columnRenderings/inventoryitemgroupsWithLoad.vue"
import space from "~/components/columnRenderings/space.vue"
import driver from "~/components/columnRenderings/driver.vue"

import quantity from "~/components/helpRenderings/quantity.vue"
import {useFunctions} from "~/composables/useFunctions.js";
import signDate from "~/components/columnRenderings/signDate.vue";
import sepaDate from "~/components/columnRenderings/sepaDate.vue";
import bankAccounts from "~/components/columnRenderings/bankAccounts.vue";
import bankAccount from "~/components/columnRenderings/bankAccount.vue";
import outgoingSepaMandate from "~/components/columnRenderings/outgoingSepaMandate.vue";

// @ts-ignore
export const useDataStore = defineStore('data', () => {

    const outgoingSepaMandateTypeOptions = [
        { key: "CORE", label: "Basislastschrift (CORE)" },
        { key: "B2B", label: "Firmenlastschrift (B2B)" }
    ]

    const outgoingSepaSequenceTypeOptions = [
        { key: "RCUR", label: "Wiederkehrend (RCUR)" },
        { key: "OOFF", label: "Einmalig (OOFF)" },
        { key: "FRST", label: "Erstlastschrift (FRST)" },
        { key: "FNAL", label: "Letztlastschrift (FNAL)" }
    ]



    const filetagCreatedDocumentTypeOptions = [
        { key: "invoices", label: "Rechnung" },
        { key: "serialInvoices", label: "Serienrechnung" },
        { key: "advanceInvoices", label: "Abschlagsrechnung" },
        { key: "cancellationInvoices", label: "Storno" },
        { key: "quotes", label: "Angebot" },
        { key: "costEstimates", label: "Kostenschätzung" },
        { key: "confirmationOrders", label: "Auftragsbestätigung" },
        { key: "deliveryNotes", label: "Lieferschein" },
        { key: "packingSlips", label: "Packschein" },
    ]

    const filetagIncomingDocumentTypeOptions = [
        { key: "invoices", label: "Eingangsrechnung" },
        { key: "reminders", label: "Mahnung" },
    ]

    const getFiletagDocumentTypeLabel = (options, value) => {
        if (value === "advanceInvoice") return "Abschlagsrechnung"

        return options.find((option) => option.key === value)?.label || value
    }

    const dataTypes = {
        tasks: {
            isArchivable: true,
            label: "Aufgaben",
            labelSingle: "Aufgabe",
            isStandardEntity: false,
            redirect: true,
            historyItemHolder: "task",
            selectWithInformation: "*, plant(*), project(*), customer(*)",
            filters: [
                {
                    name: "Nur Offene Aufgaben",
                    default: true,
                    "filterFunction": function (row) {
                        if(row.categorie !== "Erledigt") {
                            return true
                        } else {
                            return false
                        }
                    }
                },{
                    name: "Archivierte ausblenden",
                    default: true,
                    "filterFunction": function (row) {
                        if(!row.archived) {
                            return true
                        } else {
                            return false
                        }
                    }
                }
            ],
            templateColumns: [
                {
                    key: "created_at",
                    label: "Erstellt am",
                    component: created_at,
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: "name",
                    label: "Name",
                    title: true,
                    required: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: "categorie",
                    label: "Kategorie",
                    required: true,
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        {label:"Offen"},
                        {label:"In Bearbeitung"},
                        {label:"Abgeschlossen"}
                    ],
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: "profile",
                    label: "Mitarbeiter",
                    component: profile,
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    inputColumn: "Zuweisungen"
                },{
                    key: "project",
                    label: "Projekt",
                    component: project,
                    inputType: "select",
                    selectDataType: "projects",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    inputColumn: "Zuweisungen"
                },{
                    key: "customer",
                    label: "Kunde",
                    component: customer,
                    inputType: "select",
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    inputColumn: "Zuweisungen"
                },{
                    key: "plant",
                    label: "Objekt",
                    component: plant,
                    inputType: "select",
                    selectDataType: "plants",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    inputColumn: "Zuweisungen"
                },{
                    key: "description",
                    label: "Beschreibung",
                    inputColumn: "Allgemeines"
                },
            ],
            inputColumns: [
                "Allgemeines",
                "Zuweisungen"
            ],
            showTabs: [{label: 'Informationen'},{label: 'Wiki'}]
        },
        customers: {
            isArchivable: true,
            label: "Kunden",
            labelSingle: "Kunde",
            isStandardEntity: true,
            redirect:true,
            numberRangeHolder: "customerNumber",
            historyItemHolder: "customer",
            sortColumn: "customerNumber",
            selectWithInformation: "*, projects(*), plants(*), contracts(*), outgoingsepamandates(*, bankaccount(*)), contacts(*), createddocuments(*, statementallocations(*)), files(*), events(*), customerinventoryitems(*), customerspaces(*)",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            inputColumns: [
                "Allgemeines",
                "Kontaktdaten"
            ],
            templateColumns: [
                {
                    key: 'customerNumber',
                    label: "Kundennummer",
                    inputIsNumberRange: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true
                }, {
                    key: "isCompany",
                    label: "Firmenkunde",
                    component: isCompany,
                    inputType: "bool",
                    inputColumn: "Allgemeines"
                }, {
                    key: "name",
                    label: "Firmenname",
                    required: true,
                    title: true,
                    inputType: "text",
                    disabledFunction: function (item) {
                        return !item.isCompany
                    },
                    showFunction: function (item) {
                        return item.isCompany
                    },
                    inputColumn: "Allgemeines",
                    sortable: true,
                    maxLength: 20,
                    distinct: true,
                }, {
                    key: "nameAddition",
                    label: "Firmenname Zusatz",
                    inputType: "text",
                    disabledFunction: function (item) {
                        return !item.isCompany
                    },
                    showFunction: function (item) {
                        return item.isCompany
                    },
                    inputColumn: "Allgemeines",
                    maxLength: 20,
                    distinct: true,
                },{
                    key: "salutation",
                    label: "Anrede",
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.name = `${row.salutation ? (row.salutation + " ") : ""}${row.title ? (row.title + " ") : ""}${row.firstname ? (row.firstname + " ") : ""}${row.lastname}`;
                    },
                    disabledFunction: function (item) {
                        return item.isCompany
                    },
                    showFunction: function (item) {
                        return !item.isCompany
                    },
                    inputColumn: "Allgemeines",
                    sortable: true,
                    distinct: true
                },{
                    key: "title",
                    label: "Titel",
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.name = `${row.salutation ? (row.salutation + " ") : ""}${row.title ? (row.title + " ") : ""}${row.firstname ? (row.firstname + " ") : ""}${row.lastname}`;
                    },
                    disabledFunction: function (item) {
                        return item.isCompany
                    },
                    showFunction: function (item) {
                        return !item.isCompany
                    },
                    inputColumn: "Allgemeines"
                },{
                    key: "firstname",
                    label: "Vorname",//TODO: Add Conditional Rendering to Datatypes
                    title: true,
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.name = `${row.salutation ? (row.salutation + " ") : ""}${row.title ? (row.title + " ") : ""}${row.firstname ? (row.firstname + " ") : ""}${row.lastname}`;
                    },
                    disabledFunction: function (item) {
                        return item.isCompany
                    },
                    showFunction: function (item) {
                        return !item.isCompany
                    },
                    inputColumn: "Allgemeines"
                },{
                    key: "lastname",
                    label: "Nachname",
                    title: true,
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.name = `${row.salutation ? (row.salutation + " ") : ""}${row.title ? (row.title + " ") : ""}${row.firstname ? (row.firstname + " ") : ""}${row.lastname}`;
                    },
                    disabledFunction: function (item) {
                        return item.isCompany
                    },
                    showFunction: function (item) {
                        return !item.isCompany
                    },
                    inputColumn: "Allgemeines"
                },{
                    key: "active",
                    label: "Aktiv",
                    component: active,
                    inputType: "bool",
                    defaultValue: true,
                    inputColumn: "Allgemeines",
                    sortable: true,
                    distinct: true
                }, {
                    key: "customPaymentDays",
                    label: "Zahlungsziel in Tagen",
                    inputType: "number",
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: "custom_payment_type",
                    label: "Zahlungsart",
                    inputType: "select",
                    selectValueAttribute:"key",
                    selectOptionAttribute: "label",
                    selectManualOptions: [
                        {label:'Überweisung', key: 'transfer'},
                        {label:'SEPA Lastschrift', key: 'direct-debit'},
                    ],
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: "customTaxType",
                    label: "Standard Steuertyp",
                    inputType: "select",
                    selectValueAttribute:"key",
                    selectOptionAttribute: "label",
                    selectManualOptions: [
                        {label:'Standard', key: 'Standard'},
                        {label:'13b UStG', key: '13b UStG'},
                        {label:'19 UStG Kleinunternehmer', key: '19 UStG'},
                    ],
                    inputColumn: "Allgemeines",
                    sortable: true
                }, {
                    key: "customSurchargePercentage",
                    label: "Individueller Aufschlag",
                    inputType: "number",
                    inputColumn: "Allgemeines",
                    sortable: true
                }, {
                    key: "infoData.street",
                    label: "Straße + Hausnummer",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "infoData.special",
                    label: "Adresszusatz",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "infoData.zip",
                    label: "Postleitzahl",
                    inputType: "text",
                    inputChangeFunction: async function (row) {
                        const zip = String(row.infoData.zip || "").replace(/\D/g, "")
                        row.infoData.zip = zip
                        if ([4, 5].includes(zip.length)) {
                            const zipData = await useFunctions().useZipCheck(zip)
                            row.infoData.zip = zipData?.zip || row.infoData.zip
                            row.infoData.city = zipData?.short || row.infoData.city
                        }
                    },
                    disabledInTable: true,
                    inputColumn: "Kontaktdaten",
                    sortable: true
                },
                {
                    key: "infoData.city",
                    label: "Stadt",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Kontaktdaten",
                    sortable: true
                },
                {
                    key: "infoData.country",
                    label: "Land",
                    inputType: "select",
                    selectDataType: "countrys",
                    selectOptionAttribute: "name",
                    selectValueAttribute: "name",
                    defaultValue: "Deutschland",
                    disabledInTable: true,
                    inputColumn: "Kontaktdaten",
                    sortable: true
                },
                {
                    key: "address",
                    label: "Adresse",
                    component: address,
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "infoData.tel",
                    label: "Telefon",
                    inputType: "text",
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "infoData.mobileTel",
                    label: "Mobilnummer",
                    inputType: "text",
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "infoData.email",
                    label: "E-Mail",
                    inputType: "text",
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "infoData.invoiceEmail",
                    label: "E-Mail für Rechnungen",
                    inputType: "text",
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "infoData.web",
                    label: "Web",
                    inputType: "text",
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "infoData.bankAccountIds",
                    label: "Bankkonten",
                    component: bankAccounts,
                    inputType: "bankaccountassign",
                    inputColumn: "Kontaktdaten",
                    disabledInTable: true
                },
                {
                    key: "infoData.ustid",
                    label: "USt-Id",
                    inputType: "text",
                    inputColumn: "Kontaktdaten"
                },
                {
                    key: "notes",
                    label: "Notizen",
                    inputType: "textarea",
                    inputColumn: "Allgemeines"
                },
                /*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/
            ],
            showTabs: [{label: 'Informationen'},{label: 'Ansprechpartner'},{label: 'Dateien'},{label: 'Ausgangsbelege'},{label: 'Projekte'},{label: 'Objekte'},{label: 'Termine'},{label: 'Verträge'},{label: 'Ausgehende SEPA-Mandate', key: 'outgoingsepamandates', type: 'outgoingsepamandates'},{label: 'Kundeninventar', key: 'customerinventoryitems'},{label: 'Kundenlagerplätze', key: 'customerspaces'},{label: 'Wiki'}]
        },
        members: {
            isArchivable: true,
            label: "Mitglieder",
            labelSingle: "Mitglied",
            isStandardEntity: true,
            redirect: true,
            numberRangeHolder: "customerNumber",
            historyItemHolder: "customer",
            sortColumn: "customerNumber",
            selectWithInformation: "*, projects(*), plants(*), contracts(*), contacts(*), createddocuments(*, statementallocations(*)), files(*), events(*)",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    return !row.archived
                }
            }],
            inputColumns: [
                "Allgemeines",
                "Bank & Kontakt"
            ],
            templateColumns: [
                {
                    key: 'customerNumber',
                    label: "Mitgliedsnummer",
                    inputIsNumberRange: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "name",
                    label: "Name",
                    title: true,
                    sortable: true,
                    distinct: true
                },
                {
                    key: "salutation",
                    label: "Anrede",
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.name = `${row.salutation ? (row.salutation + " ") : ""}${row.title ? (row.title + " ") : ""}${row.firstname ? (row.firstname + " ") : ""}${row.lastname || ""}`.trim();
                    },
                    inputColumn: "Allgemeines",
                    sortable: true,
                    distinct: true
                },
                {
                    key: "title",
                    label: "Titel",
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.name = `${row.salutation ? (row.salutation + " ") : ""}${row.title ? (row.title + " ") : ""}${row.firstname ? (row.firstname + " ") : ""}${row.lastname || ""}`.trim();
                    },
                    inputColumn: "Allgemeines"
                },
                {
                    key: "firstname",
                    label: "Vorname",
                    required: true,
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.name = `${row.salutation ? (row.salutation + " ") : ""}${row.title ? (row.title + " ") : ""}${row.firstname ? (row.firstname + " ") : ""}${row.lastname || ""}`.trim();
                    },
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "lastname",
                    label: "Nachname",
                    required: true,
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.name = `${row.salutation ? (row.salutation + " ") : ""}${row.title ? (row.title + " ") : ""}${row.firstname ? (row.firstname + " ") : ""}${row.lastname || ""}`.trim();
                    },
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "infoData.birthdate",
                    label: "Geburtsdatum",
                    inputType: "date",
                    inputColumn: "Allgemeines",
                    disabledInTable: true
                },
                {
                    key: "memberrelation",
                    label: "Mitgliedsverhältnis",
                    component: memberrelation,
                    inputType: "select",
                    selectDataType: "memberrelations",
                    selectOptionAttribute: "type",
                    selectSearchAttributes: ['type', 'billingInterval'],
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "active",
                    label: "Aktiv",
                    component: active,
                    inputType: "bool",
                    defaultValue: true,
                    inputColumn: "Allgemeines",
                    sortable: true,
                    distinct: true
                },
                {
                    key: "customPaymentDays",
                    label: "Beitragsintervall in Tagen",
                    inputType: "number",
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "infoData.bankAccountIds",
                    label: "Bankkonten",
                    component: bankAccounts,
                    inputType: "bankaccountassign",
                    required: true,
                    inputColumn: "Bank & Kontakt",
                    disabledInTable: true
                },
                {
                    key: "infoData.hasSEPA",
                    label: "SEPA-Mandat vorhanden",
                    inputType: "bool",
                    inputColumn: "Bank & Kontakt",
                    disabledInTable: true
                },
                {
                    key: "infoData.sepaSignedAt",
                    label: "SEPA unterschrieben am",
                    inputType: "date",
                    required: true,
                    showFunction: function (item) {
                        return Boolean(item.infoData?.hasSEPA)
                    },
                    inputColumn: "Bank & Kontakt",
                    disabledInTable: true
                },
                {
                    key: "infoData.street",
                    label: "Straße + Hausnummer",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Bank & Kontakt"
                },
                {
                    key: "infoData.special",
                    label: "Adresszusatz",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Bank & Kontakt"
                },
                {
                    key: "infoData.zip",
                    label: "Postleitzahl",
                    inputType: "text",
                    inputChangeFunction: async function (row) {
                        const zip = String(row.infoData.zip || "").replace(/\D/g, "")
                        row.infoData.zip = zip
                        if ([4, 5].includes(zip.length)) {
                            const zipData = await useFunctions().useZipCheck(zip)
                            row.infoData.zip = zipData?.zip || row.infoData.zip
                            row.infoData.city = zipData?.short || row.infoData.city
                        }
                    },
                    disabledInTable: true,
                    inputColumn: "Bank & Kontakt"
                },
                {
                    key: "infoData.city",
                    label: "Stadt",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Bank & Kontakt"
                },
                {
                    key: "infoData.country",
                    label: "Land",
                    inputType: "select",
                    selectDataType: "countrys",
                    selectOptionAttribute: "name",
                    selectValueAttribute: "name",
                    defaultValue: "Deutschland",
                    disabledInTable: true,
                    inputColumn: "Bank & Kontakt"
                },
                {
                    key: "address",
                    label: "Adresse",
                    component: address,
                    inputColumn: "Bank & Kontakt"
                },
                {
                    key: "infoData.tel",
                    label: "Telefon",
                    inputType: "text",
                    inputColumn: "Bank & Kontakt"
                },
                {
                    key: "infoData.email",
                    label: "E-Mail",
                    inputType: "text",
                    inputColumn: "Bank & Kontakt"
                },
                {
                    key: "notes",
                    label: "Notizen",
                    inputType: "textarea",
                    inputColumn: "Allgemeines"
                },
            ],
            showTabs: [{label: 'Informationen'},{label: 'Ansprechpartner'},{label: 'Dateien'},{label: 'Ausgangsbelege'},{label: 'Projekte'},{label: 'Objekte'},{label: 'Termine'},{label: 'Verträge'},{label: 'Wiki'}]
        },
        contacts: {
            isArchivable: true,
            label: "Kontakte",
            labelSingle: "Kontakt",
            isStandardEntity: true,
            redirect:true,
            historyItemHolder: "contact",
            selectWithInformation: "*, customer(*), vendor(*)",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "fullName",
                    label: "Name",
                    title: true,
                    sortable: true
                },{
                    key: "salutation",
                    label: "Anrede",
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.fullName = `${row.firstName} ${row.lastName}`
                    },
                    sortable: true
                },{
                    key: "title",
                    label: "Titel",
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.fullName = `${row.firstName} ${row.lastName}`
                    }
                },{
                    key: "firstName",
                    label: "Vorname",
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.fullName = `${row.firstName} ${row.lastName}`
                    }
                },{
                    key: "lastName",
                    label: "Nachname",
                    required: true,
                    inputType: "text",
                    inputChangeFunction: function (row) {
                        row.fullName = `${row.firstName} ${row.lastName}`
                    }
                },
                {
                    key: "active",
                    label: "Aktiv",
                    component: active,
                    inputType: "bool",
                    sortable: true
                },
                {
                    key: "customer",
                    label: "Kunde",
                    component: customer,
                    inputType: "select",
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    secondInfo: true,
                    secondInfoKey: "name"
                },
                {
                    key: "vendor",
                    label: "Lieferant",
                    component: vendor,
                    inputType: "select",
                    selectDataType: "vendors",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    secondInfo: true,
                    secondInfoKey: "name"
                },
                {
                    key: "role",
                    label: "Rolle",
                    inputType: "text"
                },
                {
                    key: "email",
                    label: "E-Mail",
                    inputType: "text",
                },
                {
                    key: "phoneMobile",
                    label: "Mobil",
                    inputType: "text",
                },
                {
                    key: "phoneHome",
                    label: "Festnetz",
                    inputType: "text",
                },
                {
                    key: "birthday",
                    label: "Geburtstag",
                    inputType: "date",
                    sortable: true
                },
                {
                    key: "notes",
                    label: "Notizen",
                    inputType: "textarea",
                },
            ],
            showTabs:[
                {
                    label: 'Informationen',
                },{
                    label: 'Wiki',
                }
            ]
        },
        contracts: {
            isArchivable: true,
            label: "Verträge",
            labelSingle: "Vertrag",
            isStandardEntity: true,
            numberRangeHolder: "contractNumber",
            redirect:true,
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            inputColumns: [
                "Allgemeines",
                "Abrechnung"
            ],
            selectWithInformation: "*, customer(*), contracttype(*), outgoingsepamandate(*, bankaccount(*)), files(*)",
            templateColumns: [
                {
                    key: 'contractNumber',
                    label: "Vertragsnummer",
                    inputIsNumberRange: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "name",
                    required: true,
                    label: "Name",
                    title: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: "contracttype",
                    label: "Vertragstyp",
                    component: contracttype,
                    inputType: "select",
                    selectDataType: "contracttypes",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name"],
                    inputChangeFunction: function (item, loadedOptions = {}) {
                        const selectedContractType = (loadedOptions.contracttypes || []).find(i => i.id === item.contracttype)
                        if (!selectedContractType) return

                        item.paymentType = selectedContractType.paymentType || null
                        item.recurring = Boolean(selectedContractType.recurring)
                        item.billingInterval = selectedContractType.billingInterval || null
                    },
                    inputColumn: "Allgemeines"
                },{
                    key: "allowedContracttypes",
                    label: "Vertragstypen für Änderungsanfragen",
                    inputType: "select",
                    selectDataType: "contracttypes",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name"],
                    selectMultiple: true,
                    inputColumn: "Allgemeines"
                },{
                    key: "active",
                    label: "Aktiv",
                    component: active,
                    inputType: "bool",
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: "recurring",
                    label: "Wiederkehrend",
                    component: recurring,
                    inputType: "bool",
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: 'customer',
                    label: "Kunde",
                    required: true,
                    component: customer,
                    inputType: "select",
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    inputColumn: "Allgemeines"
                },{
                    key: 'contact',
                    label: "Ansprechpartner",
                    component: contact,
                    inputType: "select",
                    selectDataType: "contacts",
                    selectDataTypeFilter: function (i,item) {
                      return i.customer === item.customer
                    },
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    inputColumn: "Allgemeines"
                },{
                    key: 'duration',
                    label: "mindest Vertragslaufzeit",
                    inputType: "select",
                    selectValueAttribute:"label",
                    selectManualOptions: [
                        {label:'12 Monate'},
                        {label:'24 Monate'},
                        {label:'36 Monate'},
                        {label:'48 Monate'},
                        ],
                    inputColumn: "Allgemeines",
                    sortable: true
                },{
                    key: 'invoiceDispatch',
                    label: "Rechnungsversand",
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        {label:'E-Mail'},
                        {label:'Post'}
                    ],
                    inputColumn: "Abrechnung",
                    sortable: true
                },{
                    key: 'paymentType',
                    label: "Zahlungsart",
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        {label:'Einzug'},
                        {label:'Überweisung'}
                    ],
                    inputColumn: "Abrechnung"
                },{
                    key: 'outgoingsepamandate',
                    label: "SEPA-Mandat",
                    component: outgoingSepaMandate,
                    inputType: "select",
                    selectDataType: "outgoingsepamandates",
                    selectOptionAttribute: "reference",
                    selectSearchAttributes: ["reference", "status"],
                    selectDataTypeFilter: function (i, item) {
                        const mandateCustomer = i.customer?.id || i.customer
                        return !i.archived && i.status === "Aktiv" && (!item.customer || mandateCustomer === item.customer)
                    },
                    entityModalButtonsType: "outgoingsepamandates",
                    entityModalCreateQueryFunction: function (item) {
                        return {customer: item.customer}
                    },
                    showFunction: function (item) {
                        return item.paymentType === "Einzug"
                    },
                    inputColumn: "Abrechnung"
                },{
                    key: "billingInterval",
                    label: "Abrechnungsintervall",
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        { label: "Monatlich" },
                        { label: "Quartalsweise" },
                        { label: "Halbjährlich" },
                        { label: "Jährlich" }
                    ],
                    inputColumn: "Abrechnung",
                    sortable: true
                },{
                    key: 'startDate',
                    label: "Vertragsstart",
                    inputType: "date",
                    inputColumn: "Allgemeines",
                    component: startDate,
                    sortable: true
                },{
                    key: 'endDate',
                    label: "Vertragsende",
                    inputType: "date",
                    inputColumn: "Allgemeines",
                    component: endDate,
                    sortable: true
                },{
                    key: 'signDate',
                    label: "Unterschrieben am",
                    inputType: "date",
                    inputColumn: "Allgemeines",
                    component: signDate,
                    sortable: true
                },{
                    key: 'sepaDate',
                    label: "SEPA Datum",
                    inputType: "date",
                    inputColumn: "Abrechnung",
                    component: sepaDate
                },{
                    key: 'sepaRef',
                    label: "Mandatsreferenz",
                    inputType: "text",
                    inputColumn: "Abrechnung"
                },{
                    key: 'bankingIban',
                    label: "IBAN",
                    inputType: "text",
                    inputColumn: "Abrechnung"
                },{
                    key: 'bankingOwner',
                    label: "Inhaber",
                    inputType: "text",
                    inputColumn: "Abrechnung"
                },{
                    key: 'bankingName',
                    label: "Bank",
                    inputType: "text",
                    inputColumn: "Abrechnung"
                },{
                    key: 'bankingBIC',
                    label: "BIC",
                    inputType: "text",
                    inputColumn: "Abrechnung"
                },{
                    key: "notes",
                    label: "Notizen",
                    inputType: "textarea",
                }
            ],
            showTabs: [{label: 'Informationen'},{label: 'Dateien'},{label: 'Logbuch'},{label: 'Wiki'}]
        },
        contracttypes: {
            isArchivable: true,
            label: "Vertragstypen",
            labelSingle: "Vertragstyp",
            isStandardEntity: true,
            redirect: true,
            sortColumn: "name",
            selectWithInformation: "*",
            historyItemHolder: "contracttype",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea",
                    sortable: true
                },
                {
                    key: "paymentType",
                    label: "Zahlart",
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        { label: "Einzug" },
                        { label: "Überweisung" }
                    ],
                    sortable: true
                },
                {
                    key: "billingInterval",
                    label: "Abrechnungsintervall",
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        { label: "Monatlich" },
                        { label: "Quartalsweise" },
                        { label: "Halbjährlich" },
                        { label: "Jährlich" }
                    ],
                    sortable: true
                },
                {
                    key: "recurring",
                    label: "Wiederkehrend",
                    inputType: "bool",
                    component: recurring,
                    sortable: true
                }
            ],
            showTabs: [{ label: "Informationen" }]
        },
        memberrelations: {
            isArchivable: true,
            label: "Mitgliedsverhältnisse",
            labelSingle: "Mitgliedsverhältnis",
            isStandardEntity: true,
            historyItemHolder: "memberrelation",
            redirect: true,
            sortColumn: "type",
            selectWithInformation: "*",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    return !row.archived
                }
            }],
            templateColumns: [
                {
                    key: "type",
                    label: "Typ",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "billingInterval",
                    label: "Abrechnungsintervall",
                    required: true,
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectOptionAttribute: "label",
                    selectManualOptions: [
                        { label: "Monatlich" },
                        { label: "Quartalsweise" },
                        { label: "Halbjährlich" },
                        { label: "Jährlich" }
                    ],
                    sortable: true
                },
                {
                    key: "billingAmount",
                    label: "Abrechnungshöhe",
                    required: true,
                    inputType: "number",
                    inputTrailing: "€",
                    sortable: true
                }
            ],
            showTabs: [{ label: "Informationen" }]
        },
        outgoingsepamandates: {
            isArchivable: true,
            label: "Ausgehende SEPA-Mandate",
            labelSingle: "Ausgehendes SEPA-Mandat",
            isStandardEntity: true,
            redirect: true,
            numberRangeHolder: "reference",
            historyItemHolder: "outgoingsepamandate",
            sortColumn: "reference",
            selectWithInformation: "*, customer(*), bankaccount(*)",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    return !row.archived
                }
            }],
            inputColumns: [
                "Allgemeines",
                "Mandat"
            ],
            templateColumns: [
                {
                    key: "reference",
                    label: "Mandatsreferenz",
                    title: true,
                    required: true,
                    inputIsNumberRange: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "customer",
                    label: "Kunde",
                    component: customer,
                    required: true,
                    inputType: "select",
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name", "customerNumber"],
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "bankaccount",
                    label: "Bankverbindung",
                    component: bankAccount,
                    required: true,
                    inputType: "select",
                    selectDataType: "entitybankaccounts",
                    selectOptionAttribute: "displayLabel",
                    selectSearchAttributes: ["displayLabel", "iban", "bankName"],
                    entityModalButtonsType: "entitybankaccounts",
                    inputColumn: "Mandat"
                },
                {
                    key: "status",
                    label: "Status",
                    required: true,
                    defaultValue: "Entwurf",
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        { label: "Entwurf" },
                        { label: "Aktiv" },
                        { label: "Widerrufen" },
                        { label: "Abgelaufen" }
                    ],
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "mandateType",
                    label: "Mandatstyp",
                    required: true,
                    defaultValue: "CORE",
                    inputType: "select",
                    selectValueAttribute: "key",
                    selectOptionAttribute: "label",
                    selectManualOptions: outgoingSepaMandateTypeOptions,
                    inputColumn: "Mandat",
                    sortable: true
                },
                {
                    key: "sequenceType",
                    label: "Sequenz",
                    required: true,
                    defaultValue: "RCUR",
                    inputType: "select",
                    selectValueAttribute: "key",
                    selectOptionAttribute: "label",
                    selectManualOptions: outgoingSepaSequenceTypeOptions,
                    inputColumn: "Mandat",
                    sortable: true
                },
                {
                    key: "signedAt",
                    label: "Unterschrieben am",
                    inputType: "date",
                    inputColumn: "Mandat",
                    sortable: true
                },
                {
                    key: "validFrom",
                    label: "Gültig ab",
                    inputType: "date",
                    inputColumn: "Mandat",
                    sortable: true
                },
                {
                    key: "validUntil",
                    label: "Gültig bis",
                    inputType: "date",
                    inputColumn: "Mandat",
                    sortable: true
                },
                {
                    key: "defaultMandate",
                    label: "Standardmandat",
                    inputType: "bool",
                    defaultValue: false,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "notes",
                    label: "Notizen",
                    inputType: "textarea",
                    inputColumn: "Allgemeines"
                }
            ],
            showTabs: [{ label: "Informationen" }, { label: "Wiki" }]
        },
        absencerequests: {
            isArchivable: true,
            label: "Abwesenheiten",
            labelSingle: "Abwesenheit",
            isStandardEntity: true,
            sortColumn:"startDate",
            sortAscending: false,
            selectWithInformation: "*",
            historyItemHolder: "absencerequest",
            redirect:true,
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns:[
                {
                    key: "approved",
                    label: "Genehmigt",
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        {label:"Offen"},
                        {label:"Genehmigt"},
                        {label:"Abgelehnt"}
                    ]
                },{
                    key: "name",
                    label: "Name",
                    required: true,
                    inputType: "text",
                    title: true
                },
                {
                    key: "profile",
                    label: "Mitarbeiter",
                    required: true,
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    component: profile
                },{
                    key: "reason",
                    label: "Grund",
                    inputType: "select",
                    required: true,
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        {label:"Urlaub"},
                        {label:"Berufsschule"},
                        {label:"Schlechtwetter"},
                        {label:"Saison Kurzarbeitergeld"},
                        {label:"unbezahlter Urlaub"},
                        {label:"Überstundenausgleich"},
                        {label:"Sonderurlaub(bezahlt)"},
                        {label:"Schulung"},
                        {label:"Mutterschutz"},
                        {label:"Krankheit ab 2. Tag (mit Attest)"},
                        {label:"Krankheit 1 Tag (mit Attest)"},
                        {label:"Krankheit"},
                        {label:"Kind krank - Kinderbetreuung"},
                        {label:"Elternzeit"},
                    ]
                },{
                    key: "startDate",
                    required: true,
                    label: "Start",
                    inputType: "date",
                    component: startDate,
                    sortable: true
                },{
                    key: "endDate",
                    required: true,
                    label: "Ende",
                    inputType: "date",
                    component: endDate,
                    sortable: true
                },{
                    key: "note",
                    label: "Notizen",
                    inputType: "textarea"
                }
            ],
            showTabs: [{label: 'Informationen'}]
        },
        plants: {
            isArchivable: true,
            label: "Objekte",
            labelSingle: "Objekt",
            isStandardEntity: true,
            redirect:true,
            historyItemHolder: "plant",
            sortColumn:"name",
            selectWithInformation: "*, customer(id,name)",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    required: true,
                    inputType: "text",
                    title: true,
                    sortable: true
                },
                {
                    key: "customer",
                    label: "Kunde",
                    component: customer,
                    inputType: "select",
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                },{
                    key: "description.text",
                    label: "Beschreibung",
                    inputType:"textarea",
                    component: description
                },
            ],
            showTabs: [
                {
                label: "Informationen"
            },{
                label: "Projekte"
            },{
                label: "Aufgaben"
            },{
                label: "Dateien"
            },{
                label: "Wiki"
            }]
        },
        products: {
            isArchivable: true,
            label: "Artikel",
            labelSingle: "Artikel",
            isStandardEntity: true,
            redirect:true,
            selectWithInformation: "*, unit(name)",
            historyItemHolder: "product",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label:"Name",
                    required: true,
                    title: true,
                    inputType: "text"
                },
                {
                    key: "manufacturer",
                    label: "Hersteller",
                    inputType: "text"
                },
                {
                    key: "unit",
                    label: "Einheit",
                    required: true,
                    component: unit,
                    inputType: "select",
                    selectDataType: "units",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                },
                {
                    key: "purchase_price",
                    label: "Einkaufspreis",
                    component: purchasePrice,
                    inputType: "number",
                    inputTrailing: "EUR",
                    inputChangeFunction: function (row) {
                        console.log(row)
                        if(row.markup_percentage) {
                            row.selling_price = (row.purchase_price * (1+row.markup_percentage/100)).toFixed(4)
                        } else {
                            row.selling_price = Number(row.purchase_price.toFixed(4))
                        }
                    }
                },{
                    key: "markup_percentage",
                    label: "Aufschlag",
                    inputType: "number",
                    inputTrailing: "%",
                    inputChangeFunction: function (row) {
                        console.log(row)
                        if(row.purchase_price && ! row.selling_price) {
                            row.selling_price = (row.purchase_price * (1+row.markup_percentage/100)).toFixed(4)
                        } else if(row.selling_price && !row.purchase_price) {
                            row.purchase_price = (row.selling_price / (1+row.markup_percentage/100)).toFixed(4)
                        } else {
                            row.selling_price = (row.purchase_price * (1+row.markup_percentage/100)).toFixed(4)
                        }
                    }
                },{
                    key: "selling_price",
                    label: "Verkaufpreispreis",
                    required: true,
                    component: sellingPrice,
                    inputType: "number",
                    inputTrailing: "EUR",
                    inputChangeFunction: function (row) {
                        console.log(row)
                        if(row.purchase_price ) {
                            row.markup_percentage = ((row.selling_price / row.purchase_price - 1) * 100 ).toFixed(2)
                        } else{
                            row.purchase_price = (row.selling_price / (1+row.markup_percentage/100)).toFixed(4)
                        }
                    }
                },{
                    key: "tax_percentage",
                    label: "Umsatzsteuer",
                    inputType: "select",
                    selectOptionAttribute: "label",
                    selectValueAttribute: 'key',
                    required: true,
                    selectManualOptions: [
                        {label: "19 %", key: 19},
                        {label: "7 %", key: 7},
                        {label: "0 %", key: 0}]
                },
                /*{
                    key: "tags",
                    label: "Tags"
                },*/
                {
                    key: "productcategories",
                    label: "Artikelkategorien",
                    inputType: "select",
                    selectDataType: "productcategories",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    selectMultiple: true,
                    component: productcategoriesWithLoad
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType:"textarea"
                },
                {
                    key: "supplier_link",
                    label: "Link zum Lieferanten",
                    inputType: "text",
                    component: externalLink
                },
            ],
            showTabs: [
                {
                    label: "Informationen",
                },{
                    label: "Wiki",
                }
            ]
        },
        projects: {
            isArchivable: true,
            label: "Projekte",
            labelSingle: "Projekt",
            isStandardEntity: true,
            redirect:true,
            historyItemHolder: "project",
            numberRangeHolder: "projectNumber",
            selectWithInformation: "*, customer(id,name), plant(id,name), projecttype(name, id), tasks(*, project(id,name), customer(id,name), plant(id,name)), files(*), createddocuments(*, statementallocations(*)), events(*), times(*, profile(id, fullName))",
            sortColumn: "projectNumber",
            filters: [
                {
                    name: "Nur Offene Projekte",
                    default: true,
                    "filterFunction": function (row) {
                        if(row.phases && row.phases.length > 0) {
                            return row.phases.find(i => i.active).label !== "Abgeschlossen"

                            //return phase.label !== "Abgeschlossen";


                        } else {
                            return true
                        }

                    }
                }, {
                    name: "Archivierte ausblenden",
                    default: true,
                    "filterFunction": function (row) {
                        if(!row.archived) {
                            return true
                        } else {
                            return false
                        }
                    }
                }
            ],
            templateColumns: [
                {
                key: "projectNumber",
                label: "Projektnummer",
                    sortable: true
                },
                {
                    key: "projecttype",
                    label: "Typ",
                    required: true,
                    component: projecttype,
                    inputType: "select",
                    selectDataType: "projecttypes",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    inputChangeFunction: function (item,loadedOptions = {}) {
                        const selectedProjectType = loadedOptions.projecttypes?.find(i => i.id === item.projecttype)

                        if (!selectedProjectType || !Array.isArray(selectedProjectType.initialPhases)) {
                            item.phases = []
                            item.active_phase = null
                            return
                        }

                        const phases = selectedProjectType.initialPhases.map((phase, index) => ({
                            key: phase?.key || crypto.randomUUID(),
                            icon: phase?.icon || '',
                            label: phase?.label || '',
                            optional: Boolean(phase?.optional),
                            description: phase?.description || '',
                            quickactions: Array.isArray(phase?.quickactions) ? phase.quickactions.map((quickaction) => ({
                                ...quickaction
                            })) : [],
                            active: index === 0
                        }))

                        item.phases = phases
                        item.active_phase = phases.find(i => i.active)?.label || null
                    },
                    sortable: true
                },{
                    key: "active_phase",
                    label: "Phase",
                    distinct:true
                },{
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "customer",
                    label: "Kunde",
                    component: customer,
                    required: true,
                    inputType: "select",
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    secondInfo: true,
                    secondInfoKey: "name",
                },{
                    key: "plant",
                    label: "Objekt",
                    component: plant,
                    inputType: "select",
                    selectDataType: "plants",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                },{
                    key: "customerRef",
                    label: "Referenz des Kunden",
                    inputType: "text"
                },{
                    key: "notes",
                    label: "Notizen",
                    inputType: "textarea"
                },
                /*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/],
            showTabs: [
                {
                key: "information",
                label: "Informationen"
            },
                {
                    key: "phases",
                    label: "Phasen"
                },{
                    key: "tasks",
                    label: "Aufgaben"
                },{
                    key: "files",
                    label: "Dateien"
                },{
                    label: "Zeiten"
                },{
                    label: "Ausgangsbelege"
                },{
                    label: "Termine"
                },{
                    label: "Wiki"
                }/*,{
                    key: "timetracking",
                    label: "Zeiterfassung"
                },{
                    key: "events",
                    label: "Termine"
                },{
                    key: "material",
                    label: "Material"
                }*/]
        },
        vehicles: {
            isArchivable: true,
            label: "Fahrzeuge",
            labelSingle: "Fahrzeug",
            isStandardEntity: true,
            redirect:true,
            historyItemHolder: "vehicle",
            sortColumn:"licensePlate",
            selectWithInformation: "*, checks(*), files(*)",
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns:[
                {
                    key: 'active',
                    label: "Aktiv",
                    component: active,
                    inputType: "bool",
                    sortable: true
                },{
                    key: 'license_plate',
                    label: "Kennzeichen",
                    required: true,
                    inputType: "text",
                    title: true,
                    sortable: true
                },{
                    key: 'vin',
                    label: "Identifikationnummer",
                    inputType: "text"
                },
                {
                    key: "type",
                    label: "Typ",
                    inputType: "text"
                },
                /*{
                    key: "driver",
                    label: "Fahrer",
                    inputType: "select",
                    selectDataType: "auth_users",
                    selectOptionAttribute: "fullName",
                    component: driver
                },*/
                {
                    key: "tank_size",
                    label: "Tankvolumen",
                    unit: "L",
                    inputType: "number"
                },
                {
                    key: "build_year",
                    label: "Baujahr",
                    inputType: "number"
                },
                {
                    key: "towing_capacity",
                    label: "Anhängelast",
                    unit: "Kg",
                    inputType: "number",
                    sortable: true
                },
                {
                    key: "color",
                    label: "Farbe",
                    inputType: "text"
                },
                {
                    key: "power_in_kw",
                    label: "Leistung",
                    unit: "kW",
                    inputType: "number",
                    sortable: true
                },
                /*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/
            ],
            showTabs: [
                {
                    label: 'Informationen',
                }, {
                    label: 'Dateien',
                }, {
                    label: 'Überprüfungen',
                }, {
                    label: 'Wiki',
                }
            ]
        },
        vendors: {
            isArchivable: true,
            label: "Lieferanten",
            labelSingle: "Lieferant",
            isStandardEntity: true,
            redirect:true,
            numberRangeHolder: "vendorNumber",
            historyItemHolder: "vendor",
            sortColumn: "vendorNumber",
            selectWithInformation: "*, contacts(*)",
            filters: [{
                name: "SEPA nicht erteilt",
                "filterFunction": function (row) {
                    return !row.hasSEPA
                },
            },{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: 'vendorNumber',
                    label: "Lieferantennummer",
                    inputType: "text",
                    inputIsNumberRange: true,
                    sortable: true
                },
                {
                    key: "name",
                    required: true,
                    label: "Name",
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "infoData.streetNumber",
                    label: "Straße + Hausnummer",
                    inputType: "text",
                    disabledInTable: true
                },
                {
                    key: "infoData.special",
                    label: "Adresszusatz",
                    inputType: "text",
                    disabledInTable: true
                },
                {
                    key: "infoData.zip",
                    label: "Postleitzahl",
                    inputType: "text",
                    disabledInTable: true,
                    inputChangeFunction: async function (row) {
                        const zip = String(row.infoData.zip || "").replace(/\D/g, "")
                        row.infoData.zip = zip
                        if ([4, 5].includes(zip.length)) {
                            const zipData = await useFunctions().useZipCheck(zip)
                            row.infoData.zip = zipData?.zip || row.infoData.zip
                            row.infoData.city = zipData?.short || row.infoData.city
                        }
                    },
                },
                {
                    key: "infoData.city",
                    label: "Stadt",
                    inputType: "text",
                    disabledInTable: true
                },
                {
                    key: "infoData.country",
                    label: "Land",
                    inputType: "select",
                    selectDataType: "countrys",
                    selectOptionAttribute: "name",
                    selectValueAttribute: "name",
                    disabledInTable: true
                },
                {
                    key: "address",
                    label: "Adresse",
                    component: address
                },
                {
                    key: "infoData.tel",
                    label: "Telefon",
                    inputType: "text"
                },
                {
                    key: "infoData.email",
                    label: "E-Mail",
                    inputType: "text"
                },
                {
                    key: "infoData.web",
                    label: "Web",
                    inputType: "text"
                },
                {
                    key: "infoData.bankAccountIds",
                    label: "Bankkonten",
                    component: bankAccounts,
                    inputType: "bankaccountassign",
                    disabledInTable: true
                },
                {
                    key: "infoData.ustid",
                    label: "USt-Id",
                    inputType: "text"
                },
                {
                    key: "hasSEPA",
                    label: "SEPA Mandat erteilt",
                    inputType: "bool",
                    component: sepa
                },
                {
                    key: "defaultPaymentMethod",
                    label: "Standard Zahlungsmethode",
                    inputType: "select",
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        {label:"Einzug"},
                        {label:"Überweisung"},
                        {label:"Kreditkarte"},
                    ],
                },
                {
                    key: "notes",
                    label: "Notizen",
                    inputType: "textarea"
                },
                /*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/
            ],
            showTabs: [
                {
                    label: 'Informationen',
                },{
                    label: 'Ansprechpartner',
                }, {
                    label: 'Dateien',
                }, {
                    label: 'Wiki',
                }
            ]
        },
        messages: {
            label: "Nachrichten",
            labelSingle: "Nachricht"
        },
        spaces: {
            isArchivable: true,
            label: "Lagerplätze",
            labelSingle: "Lagerplatz",
            isStandardEntity: true,
            selectWithInformation: "*, files(*)",
            sortColumn: "spaceNumber",
            redirect: true,
            numberRangeHolder: "spaceNumber",
            historyItemHolder: "space",
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            inputColumns: [
                "Allgemeines",
                "Ort"
            ],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    inputType: "text",
                    required: true,
                    title: true,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: 'space_number',
                    label: "Lagerplatznr.",
                    inputType: "text",
                    inputIsNumberRange: true,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "type",
                    label: "Typ",
                    inputType: "select",
                    required: true,
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        {label:"Standort"},
                        {label:"Raum"},
                        {label:"Regalplatz"},
                        {label:"Kiste"},
                        {label:"Palettenplatz"},
                        {label:"Sonstiges"}
                    ],
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "parent_space",
                    label: "Übergeordneter Lagerplatz",
                    inputType: "select",
                    selectDataType: "spaces",
                    selectOptionAttribute: "spaceNumber",
                    selectValueAttribute: "id",
                    inputColumn: "Allgemeines"
                },
                {
                    key: "info_data.streetNumber",
                    label: "Straße + Hausnummer",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Ort"
                },
                {
                    key: "info_data.special",
                    label: "Adresszusatz",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Ort"
                },
                {
                    key: "info_data.zip",
                    label: "Postleitzahl",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Ort",
                    inputChangeFunction: async function (row) {
                        const zip = String(row.info_data.zip || "").replace(/\D/g, "")
                        row.info_data.zip = zip
                        if ([4, 5].includes(zip.length)) {
                            const zipData = await useFunctions().useZipCheck(zip)
                            row.info_data.zip = zipData?.zip || row.info_data.zip
                            row.info_data.city = zipData?.short || row.info_data.city
                        }
                    },
                },
                {
                    key: "info_data.city",
                    label: "Stadt",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Ort"
                },
                {
                    key: "info_data.country",
                    label: "Land",
                    inputType: "select",
                    selectDataType: "countrys",
                    selectOptionAttribute: "name",
                    selectValueAttribute: "name",
                    disabledInTable: true,
                    inputColumn: "Ort"
                },
                {
                    key: "address",
                    label: "Adresse",
                    component: address
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea",
                }
            ],
            showTabs: [
                {
                    label: 'Informationen',
                }, {
                    label: 'Dateien',
                },{label: 'Inventarartikel'},{label: 'Wiki'}
            ]
        },
        customerspaces: {
            isArchivable: true,
            label: "Kundenlagerplätze",
            labelSingle: "Kundenlagerplatz",
            isStandardEntity: true,
            selectWithInformation: "*, customer(id,name), files(*)",
            sortColumn: "space_number",
            redirect: true,
            numberRangeHolder: "space_number",
            historyItemHolder: "customerspace",
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    return !row.archived
                }
            }],
            inputColumns: [
                "Allgemeines",
                "Ort"
            ],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    inputType: "text",
                    required: true,
                    title: true,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "customer",
                    label: "Kunde",
                    inputType: "select",
                    required: true,
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name"],
                    component: customer,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "space_number",
                    label: "Kundenlagerplatznr.",
                    inputType: "text",
                    inputIsNumberRange: true,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "type",
                    label: "Typ",
                    inputType: "select",
                    required: true,
                    selectValueAttribute: "label",
                    selectManualOptions: [
                        {label:"Standort"},
                        {label:"Raum"},
                        {label:"Regalplatz"},
                        {label:"Kiste"},
                        {label:"Palettenplatz"},
                        {label:"Sonstiges"}
                    ],
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "parentSpace",
                    label: "Übergeordneter Kundenlagerplatz",
                    inputType: "select",
                    selectDataType: "customerspaces",
                    selectOptionAttribute: "space_number",
                    selectValueAttribute: "id",
                    inputColumn: "Allgemeines"
                },
                {
                    key: "info_data.streetNumber",
                    label: "Straße + Hausnummer",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Ort"
                },
                {
                    key: "info_data.special",
                    label: "Adresszusatz",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Ort"
                },
                {
                    key: "info_data.zip",
                    label: "Postleitzahl",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Ort",
                    inputChangeFunction: async function (row) {
                        const zip = String(row.info_data.zip || "").replace(/\D/g, "")
                        row.info_data.zip = zip
                        if ([4, 5].includes(zip.length)) {
                            const zipData = await useFunctions().useZipCheck(zip)
                            row.info_data.zip = zipData?.zip || row.info_data.zip
                            row.info_data.city = zipData?.short || row.info_data.city
                        }
                    },
                },
                {
                    key: "info_data.city",
                    label: "Stadt",
                    inputType: "text",
                    disabledInTable: true,
                    inputColumn: "Ort"
                },
                {
                    key: "info_data.country",
                    label: "Land",
                    inputType: "select",
                    selectDataType: "countrys",
                    selectOptionAttribute: "name",
                    selectValueAttribute: "name",
                    disabledInTable: true,
                    inputColumn: "Ort"
                },
                {
                    key: "address",
                    label: "Adresse",
                    component: address
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea",
                }
            ],
            showTabs: [
                {
                    label: 'Informationen',
                }, {
                    label: 'Dateien',
                },{label: 'Kundeninventar', key: 'customerinventoryitems'},{label: 'Wiki'}
            ]
        },
        users: {
            label: "Benutzer",
            labelSingle: "Benutzer"
        },
        createddocuments: {
            isArchivable: true,
            label: "Dokumente",
            labelSingle: "Dokument",
            selectWithInformation: "*, files(*), statementallocations(*), outgoingsepamandate(*)",
            filters: [
                {
                    name: "Archivierte ausblenden",
                    default: true,
                    "filterFunction": function (row) {
                        if(!row.archived) {
                            return true
                        } else {
                            return false
                        }
                    }
                }
            ],
            templateColumns: [
                {
                    key: "customer",
                    distinct: true
                }
            ]
        },
        tickets: {
            isArchivable: true,
            label: "Tickets",
            labelSingle: "Ticket",

        },
        ticketmessages: {
            isArchivable: true,
            label: "Nachrichten",
            labelSingle: "Nachricht",

        },
        files: {
            isArchivable: true,
            label: "Dateien",
            labelSingle: "Datei",
            selectWithInformation: "*",
        },
        filetags: {
            isArchivable: true,
            label: "Dateitypen",
            labelSingle: "Dateityp",
            isStandardEntity: true,
            redirect: true,
            inputColumns: [
                "Allgemeines",
                "Automatik",
            ],
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    return !row.archived
                }
            }],
            canArchiveFunction: function (row) {
                return !row.isSystemUsed
            },
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    title: true,
                    required: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true,
                },
                {
                    key: "color",
                    label: "Farbe",
                    inputType: "text",
                    inputColumn: "Allgemeines",
                },
                {
                    key: "createdDocumentType",
                    label: "Ausgangsbeleg-Typ",
                    inputType: "select",
                    selectValueAttribute: "key",
                    selectOptionAttribute: "label",
                    selectManualOptions: filetagCreatedDocumentTypeOptions,
                    displayFunction: function (value) {
                        return getFiletagDocumentTypeLabel(filetagCreatedDocumentTypeOptions, value)
                    },
                    inputColumn: "Automatik",
                },
                {
                    key: "incomingDocumentType",
                    label: "Eingangsbeleg-Typ",
                    inputType: "select",
                    selectValueAttribute: "key",
                    selectOptionAttribute: "label",
                    selectManualOptions: filetagIncomingDocumentTypeOptions,
                    displayFunction: function (value) {
                        return getFiletagDocumentTypeLabel(filetagIncomingDocumentTypeOptions, value)
                    },
                    inputColumn: "Automatik",
                },
                {
                    key: "isSystemUsed",
                    label: "Systemtyp",
                    inputType: "bool",
                    inputColumn: "Automatik",
                    disabledFunction: function () {
                        return true
                    }
                },
            ],
            showTabs: [{label: "Informationen"}]
        },
        folders: {
            isArchivable: true,
            label: "Ordner",
            labelSingle: "Ordner",
            selectWithInformation: "*",
        },
        incominginvoices: {
            label: "Eingangsrechnungen",
            labelSingle: "Eingangsrechnung",
            redirect:true,
            filters: [
                {
                    name: "Archivierte ausblenden",
                    default: true,
                    "filterFunction": function (row) {
                        if(!row.archived) {
                            return true
                        } else {
                            return false
                        }
                    }
                }
            ],
            templateColumns: [
                {
                    key: 'reference',
                    label: "Referenz:",
                    sortable: true,
                }, {
                    key: 'preparationSource',
                    label: "Quelle",
                }, {
                    key: 'state',
                    label: "Status:"
                },
                {
                    key: "date",
                    label: "Datum",
                    sortable: true,
                },
                {
                    key: "vendor",
                    label: "Lieferant",
                },
                {
                    key: "amount",
                    label: "Betrag",
                },
                {
                    key: "openAmount",
                    label: "Offener Betrag",
                },
                {
                    key: "dueDate",
                    label: "Fälligkeitsdatum",
                    sortable: true,
                },
                {
                    key: "paid",
                    label: "Bezahlt"
                },
                {
                    key: "paymentType",
                    label: "Zahlart",
                    sortable: true,
                },
                {
                    key: "description",
                    label: "Beschreibung"
                }
            ]
        },
        customerinventoryitems: {
            isArchivable: true,
            label: "Kundeninventar",
            labelSingle: "Kundeninventarartikel",
            isStandardEntity: true,
            selectWithInformation: "*, files(*), customer(id,name), customerspace(id,name,space_number), product(id,name,article_number,description,manufacturer,manufacturer_number,purchase_price,vendorAllocation), vendor(id,name)",
            redirect: true,
            numberRangeHolder: "customerInventoryId",
            historyItemHolder: "customerinventoryitem",
            inputColumns: [
                "Allgemeines",
                "Anschaffung"
            ],
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    return !row.archived
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    title: true,
                    required: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "customer",
                    label: "Kunde",
                    inputType: "select",
                    required: true,
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name"],
                    component: customer,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "customerInventoryId",
                    label: "Kundeninventar-ID",
                    inputType: "text",
                    inputIsNumberRange: true,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "product",
                    label: "Ableitung von Artikel",
                    inputType: "select",
                    selectDataType: "products",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name", "article_number"],
                    inputColumn: "Allgemeines",
                    component: product,
                    inputChangeFunction: function (row, loadedOptions) {
                        const products = loadedOptions?.products || []
                        const selected = products.find((p) => p.id === row.product)
                        if (!selected) return

                        row.name = selected.name || null
                        row.description = selected.description || null
                        row.manufacturer = selected.manufacturer || null
                        row.manufacturerNumber = selected.manufacturer_number || null
                        row.purchasePrice = typeof selected.purchase_price === "number" ? selected.purchase_price : row.purchasePrice
                        row.currentValue = row.currentValue ?? row.purchasePrice

                        const allocations = Array.isArray(selected.vendor_allocation)
                            ? selected.vendor_allocation
                            : (Array.isArray(selected.vendorAllocation) ? selected.vendorAllocation : [])
                        const firstAllocation = allocations[0]
                        if (typeof firstAllocation === "number") {
                            row.vendor = firstAllocation
                        } else if (firstAllocation && typeof firstAllocation === "object") {
                            row.vendor = firstAllocation.vendor || firstAllocation.vendor_id || firstAllocation.id || row.vendor
                        }
                    }
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea",
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "customerspace",
                    label: "Aktueller Kundenlagerplatz",
                    inputType: "select",
                    selectDataType: "customerspaces",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name", "space_number"],
                    inputColumn: "Allgemeines",
                    component: space
                },
                {
                    key: "serialNumber",
                    label: "Seriennummer",
                    inputType: "text",
                    inputColumn: "Allgemeines"
                },
                {
                    key: "quantity",
                    label: "Menge",
                    inputType: "number",
                    inputColumn: "Allgemeines",
                    disabledFunction: function (item) {
                        return item.serialNumber
                    },
                    helpComponent: quantity,
                    sortable: true
                },
                {
                    key: "purchaseDate",
                    label: "Kaufdatum",
                    inputType: "date",
                    inputColumn: "Anschaffung",
                    sortable: true
                },
                {
                    key: "vendor",
                    label: "Lieferant",
                    inputType: "select",
                    selectDataType: "vendors",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name"],
                    inputColumn: "Anschaffung",
                    component: vendor
                },
                {
                    key: "purchasePrice",
                    label: "Kaufpreis",
                    inputType: "number",
                    inputStepSize: "0.01",
                    inputColumn: "Anschaffung",
                    component: purchasePrice,
                    sortable: true
                },
                {
                    key: "manufacturer",
                    label: "Hersteller",
                    inputType: "text",
                    inputColumn: "Anschaffung"
                },
                {
                    key: "manufacturerNumber",
                    label: "Herstellernummer",
                    inputType: "text",
                    inputColumn: "Anschaffung"
                },
                {
                    key: "currentValue",
                    label: "Aktueller Wert",
                    inputType: "number",
                    inputStepSize: "0.01",
                    inputColumn: "Anschaffung",
                    sortable: true
                },
            ],
            showTabs: [
                {
                    label: 'Informationen',
                }, {
                    label: 'Dateien',
                }, {
                    label: 'Wiki',
                }
            ]
        },
        inventoryitems: {
            isArchivable: true,
            label: "Inventarartikel",
            labelSingle: "Inventarartikel",
            isStandardEntity: true,
            selectWithInformation: "*, files(*), vendor(id,name), currentSpace(id,name)",
            redirect: true,
            numberRangeHolder: "articleNumber",
            historyItemHolder: "inventoryitem",
            inputColumns: [
                "Allgemeines",
                "Anschaffung"
            ],
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    title: true,
                    required: true,
                    inputType: "text",
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "usePlanning",
                    label: "In Plantafel anzeigen",
                    inputType: "bool",
                    inputColumn: "Allgemeines",
                    component: usePlanning,
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea",
                    sortable: true
                },
                {
                    key: "currentSpace",
                    label: "Aktueller Lagerplatz",
                    inputType: "select",
                    selectDataType: "spaces",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    inputColumn: "Allgemeines",
                    component: space
                },
                {
                    key: "articleNumber",
                    label: "Artikelnummer",
                    inputType: "text",
                    inputIsNumberRange: true,
                    inputColumn: "Allgemeines",
                    sortable: true
                },
                {
                    key: "serialNumber",
                    label: "Seriennummer",
                    inputType: "text",
                    inputColumn: "Allgemeines"
                },
                {
                    key: "purchaseDate",
                    label: "Kaufdatum",
                    inputType: "date",
                    inputColumn: "Anschaffung",
                    sortable: true
                },
                {
                    key: "vendor",
                    label: "Lieferant",
                    inputType: "select",
                    selectDataType: "vendors",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    inputColumn: "Anschaffung",
                    component: vendor
                },
                {
                    key: "quantity",
                    label: "Menge",
                    inputType: "number",
                    inputColumn: "Allgemeines",
                    disabledFunction: function (item) {
                        return item.serialNumber
                    },
                    helpComponent: quantity,
                    sortable: true
                },
                {
                    key: "purchase_price",
                    label: "Kaufpreis",
                    inputType: "number",
                    inputStepSize: "0.01",
                    inputColumn: "Anschaffung",
                    sortable: true
                },
                {
                    key: "manufacturer",
                    label: "Hersteller",
                    inputType: "text",
                    inputColumn: "Anschaffung"
                },
                {
                    key: "manufacturerNumber",
                    label: "Herstellernummer",
                    inputType: "text",
                    inputColumn: "Anschaffung"
                },
                /*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/
                {
                    key: "currentValue",
                    label: "Aktueller Wert",
                    inputType: "number",
                    inputStepSize: "0.01",
                    inputColumn: "Anschaffung",
                    sortable: true
                },

            ],
            showTabs: [
                {
                    label: 'Informationen',
                }, {
                    label: 'Dateien',
                }, {
                    label: 'Wiki',
                }
            ]
        },
        inventoryitemgroups: {
            isArchivable: true,
            label: "Inventarartikelgruppen",
            labelSingle: "Inventarartikelgruppe",
            isStandardEntity: true,
            historyItemHolder: "inventoryitemgroup",
            selectWithInformation: "*",
            redirect: true,
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    title: true,
                    required: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea"
                },
                {
                    key: "usePlanning",
                    label: "In Plantafel anzeigen",
                    inputType: "bool",
                    component: usePlanning
                },{
                    key: "inventoryitems",
                    label: "Inventarartikel",
                    inputType: "select",
                    selectDataType: "inventoryitems",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    selectMultiple: true,
                    required: true,
                    component: inventoryitemsWithLoad
                },/*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/

            ],
            showTabs: [
                {
                    label: 'Informationen',
                },{
                    label: 'Wiki',
                }
            ]
        },
        documentboxes: {
            isArchivable: true,
            label: "Dokumentenboxen",
            labelSingle: "Dokumentenbox",
            isStandardEntity: true,
            selectWithInformation: "*, space(*), files(*)",
            redirect: true,
            numberRangeHolder: "key",
            historyItemHolder: "documentbox",
            inputColumns: [
                "Allgemeines",
            ],
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "space",
                    label: "Aktueller Lagerplatz",
                    inputType: "select",
                    selectDataType: "spaces",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    inputColumn: "Allgemeines",
                    component: space
                },
                {
                    key: "key",
                    label: "Nummer",
                    inputType: "text",
                    inputIsNumberRange: true,
                    inputColumn: "Allgemeines",
                    title: true,
                    required: true,
                },
                /*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/

            ],
            showTabs: [
                {
                    label: 'Informationen',
                }, {
                    label: 'Dateien',
                }
            ]
        },
        services: {
            isArchivable: true,
            label: "Leistungen",
            labelSingle: "Leistung",
            isStandardEntity: true,
            redirect: true,
            selectWithInformation: "*, unit(*), costcentre(*)",
            historyItemHolder: "service",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "unit",
                    label: "Einheit",
                    component: unit,
                    inputType: "select",
                    selectDataType: "units",
                    selectOptionAttribute: "name",
                    required: true,
                    selectSearchAttributes: ['name'],
                },
                {
                    key: "sellingPrice",
                    label: "Verkaufspreis",
                    component: sellingPrice,
                },
                {
                    key: "priceUpdateLocked",
                    label: "Preis-Update sperren",
                    inputType: "bool",
                },
                {
                    key: "taxPercentage",
                    label: "Umsatzsteuer",
                    inputType: "select",
                    selectOptionAttribute: "label",
                    selectValueAttribute: 'key',
                    required: true,
                    selectManualOptions: [
                        {label: "19 %", key: 19},
                        {label: "7 %", key: 7},
                        {label: "0 %", key: 0}]
                    //TODO: Default Value
                },
                {
                    key: "costcentre",
                    label: "Kostenstellen-Vorauswahl",
                    inputType: "select",
                    selectDataType: "costcentres",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name", "number"],
                    component: costcentre
                },
                {
                    key: "servicecategories",
                    label: "Leistungskategorien",
                    inputType: "select",
                    selectDataType: "servicecategories",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    selectMultiple: true,
                    component: serviceCategories
                },
                {
                    key: "sellingPriceComposed.worker",
                    label: "Verkaufspreis Personal pro Einheit",
                    inputType: "number",
                    inputTrailing: "EUR",
                    inputChangeFunction: function (row) {
                        if(row.sellingPriceComposed.worker) {
                            row.sellingPriceComposed.total = row.sellingPriceComposed.worker + (row.sellingPriceComposed.material || 0)
                            row.sellingPrice = row.sellingPriceComposed.total
                        }
                    },
                    component: sellingPriceComposedWorker
                },
                {
                    key: "sellingPriceComposed.material",
                    label: "Verkaufspreis Material pro Einheit",
                    inputType: "number",
                    inputTrailing: "EUR",
                    inputChangeFunction: function (row) {
                        if(row.sellingPriceComposed.material) {
                            row.sellingPriceComposed.total = (row.sellingPriceComposed.worker || 0) + row.sellingPriceComposed.material
                            row.sellingPrice = row.sellingPriceComposed.total
                        }
                    },
                    component: sellingPriceComposedMaterial
                },
                {
                    key: "materialComposing",
                    label: "Zusammensetzung Materialpreis pro Einheit",
                    inputType: "materialComposing",
                },
                {
                    key: "personalComposing",
                    label: "Zusammensetzung Personal pro Einheit",
                    inputType: "personalComposing",
                },
                {
                    key: "sellingPriceComposed.total",
                    label: "Verkaufspreis Gesamt pro Einheit",
                    inputType: "number",
                    inputTrailing: "EUR",
                    required: true,
                    /*disabledFunction: function (item) {
                        return item.sellingPriceComposed.worker || item.sellingPriceComposed.material
                    },*/
                    inputChangeFunction: function (row) {
                        if(row.sellingPriceComposed.worker) {
                            row.sellingPriceComposed.material = row.sellingPriceComposed.total - row.sellingPriceComposed.worker
                        } else if(row.sellingPriceComposed.material) {
                            row.sellingPriceComposed.worker = row.sellingPriceComposed.total - row.sellingPriceComposed.material
                        }
                    },
                    component: sellingPriceComposedTotal
                },


                {
                    key: "description",
                    label: "Beschreibung",
                    inputType:"textarea"
                },
            ],
            showTabs: [
                {
                    label: 'Informationen',
                },{
                    label: 'Wiki',
                }
            ]
        },
        hourrates: {
            isArchivable: true,
            label: "Stundensätze",
            labelSingle: "Stundensatz",
            isStandardEntity: true,
            redirect: true,
            selectWithInformation: "*",
            historyItemHolder: "hourrate",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "purchase_price",
                    label: "Einkauspreis",
                    inputType: "number",
                    component: purchasePrice,
                    sortable: true
                },
                {
                    key: "sellingPrice",
                    label: "Verkaufspreis",
                    inputType: "number",
                    component: sellingPrice,
                    sortable: true
                },
            ],
            showTabs: [
                {
                    label: 'Informationen',
                },{
                    label: 'Wiki',
                }
            ]
        },
        events: {
            isArchivable: true,
            label: "Termine",
            labelSingle: "Termin",
            isStandardEntity: true,
            historyItemHolder: "event",
            selectWithInformation: "*, project(id,name), customer(*)",
            redirect: true,
            filters:[{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: 'name',
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "quick",
                    label: "Quick-Eintrag",
                    inputType: "bool",
                    sortable: true
                },
                {
                    key: "state",
                    label: "Status",
                    inputType: "select",
                    selectManualOptions: ["Entwurf", "Final"],
                    sortable: true
                },
                {
                    key: "repeatInterval",
                    label: "Wiederholung",
                    inputType: "select",
                    selectManualOptions: ["Keine Wiederholung", "Täglich", "Wöchentlich", "2-wöchentlich", "Monatlich", "Jährlich"],
                    sortable: true
                },
                {
                    key: "color",
                    label: "Farbe",
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "startDate",
                    label: "Start",
                    required: true,
                    inputType: "datetime",
                    component: startDateTime,
                    sortable: true
                },
                {
                    key: "endDate",
                    label: "Ende",
                    required: true,
                    inputType: "datetime",
                    component: endDateTime,
                    sortable: true
                },/*{
                    key: "eventtype",
                    label: "Typ",
                    inputType: "select",
                    selectManualOptions: ["Umsetzung","Vor Ort Termin", "Büro", "Sonstiges"],
                },*/{
                    key: "link",
                    label: "Link",
                    inputType: "text"
                },{
                    key: "notes",
                    label: "Notizen",
                    inputType: "textarea"
                },
                {
                    key: "project",
                    label: "Projekt",
                    component: project,
                    inputType: "select",
                    selectDataType: "projects",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                },{
                    key: "vehicles",
                    label: "Fahrzeuge",
                    inputType: "select",
                    selectDataType: "vehicles",
                    selectOptionAttribute: "license_plate",
                    selectSearchAttributes: ['license_plate'],
                    selectMultiple: true,
                    component: vehiclesWithLoad,
                },{
                    key: "inventoryitems",
                    label: "Inventarartikel",
                    inputType: "select",
                    selectDataType: "inventoryitems",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    selectMultiple: true,
                    component: inventoryitemsWithLoad
                },{
                    key: "inventoryitemgroups",
                    label: "Inventarartikelgruppen",
                    inputType: "select",
                    selectDataType: "inventoryitemgroups",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    selectMultiple: true,
                    component: inventoryitemgroupsWithLoad
                },{
                    key: "customer",
                    label: "Kunde",
                    inputType: "select",
                    selectDataType: "customers",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                    component: customer,
                },{
                    key: "vendor",
                    label: "Lieferant",
                    inputType: "select",
                    selectDataType: "vendors",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                },{
                    key: "profiles",
                    label: "Beteiligte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,
                    component: profiles
                }
            ],
            showTabs: [
                {
                    label: 'Informationen',},{
                    label: 'Wiki',}
            ]
        },
        profiles: {
            label: "Mitarbeiter",
            labelSingle: "Mitarbeiter",
            redirect: true,
            historyItemHolder: "profile"
        },
        branches: {
            isArchivable: true,
            label: "Niederlassungen",
            labelSingle: "Niederlassung",
            isStandardEntity: true,
            redirect: true,
            numberRangeHolder: "number",
            historyItemHolder: "branch",
            sortColumn: "name",
            selectWithInformation: "*",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "number",
                    label: "Nummer",
                    inputType: "text",
                    inputIsNumberRange: true,
                    sortable: true
                },
                {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea"
                }
            ],
            showTabs: [{label: 'Informationen'},{label: 'Wiki'}]
        },
        teams: {
            isArchivable: true,
            label: "Teams",
            labelSingle: "Team",
            isStandardEntity: true,
            redirect: true,
            historyItemHolder: "team",
            sortColumn: "name",
            selectWithInformation: "*",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            inputColumns: ["Allgemein"],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    inputColumn: "Allgemein",
                    sortable: true
                },
                {
                    key: "branch",
                    label: "Niederlassung",
                    inputType: "select",
                    inputColumn: "Allgemein",
                    selectDataType: "branches",
                    selectOptionAttribute: "name",
                    component: branch,
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea",
                    inputColumn: "Allgemein"
                }
            ],
            showTabs: [{label: 'Informationen'},{label: 'Wiki'}]
        },
        workingtimes: {
            isArchivable: true,
            label: "Anwesenheiten",
            labelSingle: "Anwesenheit",
            redirect: true,
            redirectToList: true
        },
        texttemplates: {
            isArchivable: true,
            label: "Textvorlagen",
            labelSingle: "Textvorlage"
        },
        letterheads: {
            isArchivable: true,
            label: "Briefpapiere",
            labelSingle: "Briefpapier"
        },
        bankstatements: {
            isArchivable: true,
            label: "Kontobewegungen",
            labelSingle: "Kontobewegung",
            historyItemHolder: "bankStatement",
        },
        statementallocations: {
            label: "Bankzuweisungen",
            labelSingle: "Bankzuweisung"
        },
        productcategories: {
            isArchivable: true,
            label: "Artikelkategorien",
            labelSingle: "Artikelkategorie",
            isStandardEntity: true,
            redirect: true,
            sortColumn: "name",
            selectWithInformation: "*",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea"
                }
            ],
            showTabs: [
                {
                    label: 'Informationen',
                },{
                    label: 'Wiki',
                }
            ]
        },
        servicecategories: {
            isArchivable: true,
            label: "Leistungskategorien",
            labelSingle: "Leistungskategorie",
            isStandardEntity: true,
            redirect: true,
            sortColumn: "name",
            selectWithInformation: "*",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea"
                }
            ],
            showTabs: [
                {
                    label: 'Informationen',
                },{
                    label: 'Wiki',
                }
            ]
        },
        trackingtrips: {
            label: "Fahrten",
            labelSingle: "Fahrt",
            redirect: true,
            historyItemHolder: "trackingtrip",
        },
        projecttypes: {
            isArchivable: true,
            label: "Projekttypen",
            labelSingle: "Projekttyp",
            redirect: true,
            historyItemHolder: "projecttype"
        },
        checks: {
            isArchivable: true,
            label: "Überprüfungen",
            labelSingle: "Überprüfung",
            isStandardEntity: true,
            selectWithInformation: "*, vehicle(id,licensePlate), profile(id, fullName), inventoryitem(name), files(*)",
            redirect: true,
            historyItemHolder: "check",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: "name",
                    label: "Name",
                    title: true,
                    required: true,
                    inputType: "text"
                },
                {
                    key: "vehicle",
                    label: "Fahrzeug",
                    component: vehicle,
                    inputType: "select",
                    selectDataType: "vehicles",
                    selectOptionAttribute: "licensePlate",
                    selectSearchAttributes: ['licensePlate'],
                },
                {
                    key: "profile",
                    label: "Person",
                    component: profile,
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                },
                {
                    key: "inventoryitem",
                    label: "Inventarartikel",
                    inputType: "select",
                    selectDataType: "inventoryitems",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea"
                }
            ],
            showTabs: [
                {
                label: 'Informationen',
            }, {label: 'Dateien'}, {label: 'Ausführungen'}]
        },
        roles: {
            label: "Rollen",
            labelSingle: "Rolle",
            redirect:true,
            historyItemHolder: "role",
            filters: [],
            templateColumns: [
                {
                    key: "name",
                    label: "Name"
                }, {
                    key: "description",
                    label: "Beschreibung"
                }
            ]
        },
        costcentres: {
            isArchivable: true,
            label: "Kostenstellen",
            labelSingle: "Kostenstelle",
            isStandardEntity: true,
            redirect:true,
            numberRangeHolder: "number",
            historyItemHolder: "costcentre",
            sortColumn: "number",
            selectWithInformation: "*, parentCostcentre(*), project(*), vehicle(*), inventoryitem(*), branch(*)",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: 'number',
                    label: "Nummer",
                    inputIsNumberRange: true,
                    inputType: "text",
                    sortable: true
                }, {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea"
                },
                {
                    key: "parentCostcentre",
                    label: "Übergeordnete Kostenstelle",
                    component: costcentre,
                    inputType: "select",
                    selectDataType: "costcentres",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ["name", "number"],
                    selectDataTypeFilter: function (option, item) {
                        return option.id !== item.value?.id
                    }
                },
                {
                    key: "vehicle",
                    label: "Fahrzeug",
                    component: vehicle,
                    inputType: "select",
                    selectDataType: "vehicles",
                    selectOptionAttribute: "license_plate",
                    selectSearchAttributes: ['license_plate','vin'],
                },
                {
                    key: "inventoryitem",
                    label: "Inventarartikel",
                    inputType: "select",
                    selectDataType: "inventoryitems",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                },
                {
                    key: "project",
                    label: "Projekt",
                    component: project,
                    inputType: "select",
                    selectDataType: "projects",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name'],
                },
                {
                    key: "branch",
                    label: "Niederlassung",
                    component: branch,
                    inputType: "select",
                    selectDataType: "branches",
                    selectOptionAttribute: "name",
                    selectSearchAttributes: ['name', 'number'],
                },
                /*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/
            ],
            showTabs: [{label: 'Informationen'},{label: 'Auswertung Kostenstelle'}]
        },
        ownaccounts: {
            isArchivable: true,
            label: "zusätzliche Buchungskonten",
            labelSingle: "zusätzliches Buchungskonto",
            isStandardEntity: true,
            redirect:true,
            historyItemHolder: "ownaccount",
            sortColumn: "number",
            selectWithInformation: "*, statementallocations(*, bs_id(*))",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    if(!row.archived) {
                        return true
                    } else {
                        return false
                    }
                }
            }],
            templateColumns: [
                {
                    key: 'number',
                    label: "Nummer",
                    inputType: "text",
                    sortable: true
                }, {
                    key: "name",
                    label: "Name",
                    required: true,
                    title: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "textarea"
                },
                /*{
                    key: "profiles",
                    label: "Berechtigte Benutzer",
                    inputType: "select",
                    selectDataType: "profiles",
                    selectOptionAttribute: "fullName",
                    selectSearchAttributes: ['fullName'],
                    selectMultiple: true,/!*
                    component: profiles,*!/
                    inputColumn: "Allgemeines"
                },*/
            ],
            showTabs: [{label: 'Informationen'},{label: 'Buchungen'},{
                label: 'Wiki',
            }]
        },
        bankaccounts: {
            label: "Bankkonten",
            labelSingle: "Bankkonto",
        },
        entitybankaccounts: {
            isArchivable: true,
            label: "Bankverbindungen",
            labelSingle: "Bankverbindung",
            isStandardEntity: false,
            redirect: false,
            sortColumn: "created_at",
            filters: [{
                name: "Archivierte ausblenden",
                default: true,
                "filterFunction": function (row) {
                    return !row.archived
                }
            }],
            templateColumns: [
                {
                    key: "displayLabel",
                    label: "Bankverbindung",
                    title: true,
                    sortable: true
                },
                {
                    key: "iban",
                    label: "IBAN",
                    required: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "bic",
                    label: "BIC",
                    required: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "bankName",
                    label: "Bankinstitut",
                    required: true,
                    inputType: "text",
                    sortable: true
                },
                {
                    key: "description",
                    label: "Beschreibung",
                    inputType: "text",
                },
            ],
        }
    }

    const documentTypesForCreation = ref({
        invoices: {
            label: "Rechnungen",
            labelSingle: "Rechnung",

        },
        serialInvoices: {
            label: "Serienrechnungen",
            labelSingle: "Serienrechnung",
        },
        advanceInvoices: {
            label: "Abschlagsrechnungen",
            labelSingle: "Abschlagsrechnung"
        },
        cancellationInvoices: {
            label: "Stornorechnungen",
            labelSingle: "Storno"
        },
        quotes: {
            label: "Angebote",
            labelSingle: "Angebot"
        },
        costEstimates: {
            label: "Kostenschätzungen",
            labelSingle: "Kostenschätzung"
        },
        deliveryNotes: {
            label: "Lieferscheine",
            labelSingle: "Lieferschein"
        },
        packingSlips: {
            label: "Packscheine",
            labelSingle: "Packschein"
        },
        confirmationOrders: {
            label: "Auftragsbestätigungen",
            labelSingle: "Auftragsbestätigung"
        }
    })









    return {
        dataTypes,
        documentTypesForCreation,
        outgoingSepaMandateTypeOptions,
        outgoingSepaSequenceTypeOptions,
    }
})
