import {defineStore} from 'pinia' import dayjs from "dayjs" //import {typeOf} from "uri-js/dist/esnext/util"; import {useNumberRange} from "~/composables/useNumberRange.js"; //const supabase = createClient('https://uwppvcxflrcsibuzsbil.supabase.co','eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV3cHB2Y3hmbHJjc2lidXpzYmlsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDA5MzgxOTQsImV4cCI6MjAxNjUxNDE5NH0.CkxYSQH0uLfwx9GVUlO6AYMU2FMLAxGMrwEKvyPv7Oo') import projecttype from "~/components/columnRenderings/projecttype.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 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 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 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 {useZipCheck} from "~/composables/useZipCheck.js"; import {useFunctions} from "~/composables/useFunctions.js"; import signDate from "~/components/columnRenderings/signDate.vue"; import sepaDate from "~/components/columnRenderings/sepaDate.vue"; // @ts-ignore export const useDataStore = defineStore('data', () => { const supabase = useSupabaseClient() const profileStore = useProfileStore() const toast = useToast() const router = useRouter() const modal = useModal() const dataTypes = { tasks: { isArchivable: true, label: "Aufgaben", labelSingle: "Aufgabe", isStandardEntity: true, redirect: true, historyItemHolder: "task", supabaseSelectWithInformation: "*, 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" },{ key: "name", label: "Name", title: true, required: true, inputType: "text", inputColumn: "Allgemeines" },{ key: "categorie", label: "Kategorie", required: true, inputType: "select", selectValueAttribute: "label", selectManualOptions: [ {label:"Offen"}, {label:"In Bearbeitung"}, {label:"Abgeschlossen"} ], inputColumn: "Allgemeines" },{ 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'}] }, customers: { isArchivable: true, label: "Kunden", labelSingle: "Kunde", isStandardEntity: true, redirect:true, numberRangeHolder: "customerNumber", historyItemHolder: "customer", supabaseSortColumn: "customerNumber", supabaseSelectWithInformation: "*, projects(*), plants(*), contracts(*), contacts(*), createddocuments(*, statementallocations(*)), files(*), events(*)", 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" }, { 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" }, { key: "nameAddition", label: "Firmenname Zusatz", inputType: "text", disabledFunction: function (item) { return !item.isCompany }, showFunction: function (item) { return item.isCompany }, inputColumn: "Allgemeines" },{ key: "salutation", label: "Anrede", inputType: "text", inputChangeFunction: function (row) { row.name = "" if(row.salutation) { row.name += `${row.salutation}` } if(row.title) { row.name += ` ${row.title}` } if(row.firstname) { row.name += ` ${row.firstname}` } if(row.lastname) { row.name += ` ${row.lastname}` } }, disabledFunction: function (item) { return item.isCompany }, showFunction: function (item) { return !item.isCompany }, inputColumn: "Allgemeines" },{ key: "title", label: "Titel", inputType: "text", inputChangeFunction: function (row) { row.name = "" if(row.salutation) { row.name += `${row.salutation}` } if(row.title) { row.name += ` ${row.title}` } if(row.firstname) { row.name += ` ${row.firstname}` } if(row.lastname) { row.name += ` ${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 = "" if(row.salutation) { row.name += `${row.salutation}` } if(row.title) { row.name += ` ${row.title}` } if(row.firstname) { row.name += ` ${row.firstname}` } if(row.lastname) { row.name += ` ${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 = "" if(row.salutation) { row.name += `${row.salutation}` } if(row.title) { row.name += ` ${row.title}` } if(row.firstname) { row.name += ` ${row.firstname}` } if(row.lastname) { row.name += ` ${row.lastname}` } }, disabledFunction: function (item) { return item.isCompany }, showFunction: function (item) { return !item.isCompany }, inputColumn: "Allgemeines" },{ key: "active", label: "Aktiv", component: active, inputType: "bool", inputColumn: "Allgemeines" }, { key: "customPaymentDays", label: "Zahlungsziel in Tagen", inputType: "number", inputColumn: "Allgemeines" }, { key: "customSurchargePercentage", label: "Individueller Aufschlag", inputType: "number", inputColumn: "Allgemeines" }, { 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: "number", inputChangeFunction: async function (row) { if(row.infoData.zip) { row.infoData.city = (await useZipCheck(row.infoData.zip)) } }, disabledInTable: true, inputColumn: "Kontaktdaten" }, { key: "infoData.city", label: "Stadt", inputType: "text", disabledInTable: true, inputColumn: "Kontaktdaten" }, { key: "infoData.country", label: "Land", inputType: "select", selectDataType: "countrys", selectOptionAttribute: "name", selectValueAttribute: "name", disabledInTable: true, inputColumn: "Kontaktdaten" }, { key: "address", label: "Adresse", component: address, inputColumn: "Kontaktdaten" }, { key: "infoData.tel", label: "Telefon", 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.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'}] }, contacts: { isArchivable: true, label: "Kontakte", labelSingle: "Kontakt", isStandardEntity: true, redirect:true, historyItemHolder: "contact", supabaseSelectWithInformation: "*, 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, },{ key: "salutation", label: "Anrede", inputType: "text", inputChangeFunction: function (row) { row.fullName = `${row.firstName} ${row.lastName}` } },{ 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" }, { 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", }, { key: "notes", label: "Notizen", inputType: "textarea", }, ], showTabs:[ { label: 'Informationen', } ] }, 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" ], supabaseSelectWithInformation: "*, customer(*), files(*)", templateColumns: [ { key: 'contractNumber', label: "Vertragsnummer", inputIsNumberRange: true, inputType: "text", inputColumn: "Allgemeines" }, { key: "name", required: true, label: "Name", title: true, inputType: "text", inputColumn: "Allgemeines" },{ key: "active", label: "Aktiv", component: active, inputType: "bool", inputColumn: "Allgemeines" },{ key: "recurring", label: "Wiederkehrend", component: recurring, inputType: "bool", inputColumn: "Allgemeines" },{ 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" },{ key: 'invoiceDispatch', label: "Rechnungsversand", inputType: "select", selectValueAttribute: "label", selectManualOptions: [ {label:'E-Mail'}, {label:'Post'} ], inputColumn: "Abrechnung" },{ key: 'paymentType', label: "Zahlungsart", inputType: "select", selectValueAttribute: "label", selectManualOptions: [ {label:'Einzug'}, {label:'Überweisung'} ], inputColumn: "Abrechnung" },{ key: 'startDate', label: "Vertragsstart", inputType: "date", inputColumn: "Allgemeines", component: startDate },{ key: 'endDate', label: "Vertragsende", inputType: "date", inputColumn: "Allgemeines", component: endDate },{ key: 'signDate', label: "Unterschrieben am", inputType: "date", inputColumn: "Allgemeines", component: signDate },{ 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: 'bankinBIC', label: "BIC", inputType: "text", inputColumn: "Abrechnung" },{ key: "notes", label: "Notizen", inputType: "textarea", } ], showTabs: [{label: 'Informationen'},{label: 'Dateien'}] }, absencerequests: { isArchivable: true, label: "Abwesenheiten", labelSingle: "Abwesenheit", isStandardEntity: true, supabaseSortColumn:"startDate", supabaseSortAscending: false, supabaseSelectWithInformation: "*", 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 },{ key: "endDate", required: true, label: "Ende", inputType: "date", component: endDate },{ key: "note", label: "Notizen", inputType: "textarea" } ], showTabs: [{label: 'Informationen'}] }, plants: { isArchivable: true, label: "Objekte", labelSingle: "Objekt", isStandardEntity: true, redirect:true, historyItemHolder: "plant", supabaseSelectWithInformation: "*, 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 }, { key: "customer", label: "Kunde", component: customer, inputType: "select", selectDataType: "customers", selectOptionAttribute: "name", selectSearchAttributes: ['name'], },{ key: "description", label: "Beschreibung", inputType:"editor", component: description }, ], showTabs: [ { label: "Informationen" },{ label: "Projekte" },{ label: "Aufgaben" },{ label: "Dateien" }] }, products: { isArchivable: true, label: "Artikel", labelSingle: "Artikel", isStandardEntity: true, redirect:true, supabaseSelectWithInformation: "*, 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: "purchasePrice", label: "Einkaufspreis", component: purchasePrice, inputType: "number", inputTrailing: "EUR", inputChangeFunction: function (row) { if(row.markupPercentage) { row.sellingPrice = (row.purchasePrice * (1+row.markupPercentage/100)).toFixed(4) } else { row.sellingPrice = row.purchasePrice.toFixed(4) } } },{ key: "markupPercentage", label: "Aufschlag", inputType: "number", inputTrailing: "%", inputChangeFunction: function (row) { if(row.purchasePrice && ! row.sellingPrice) { row.sellingPrice = (row.purchasePrice * (1+row.markupPercentage/100)).toFixed(4) } else if(row.sellingPrice && !row.purchasePrice) { row.purchasePrice = (row.sellingPrice / (1+row.markupPercentage/100)).toFixed(4) } else { row.sellingPrice = (row.purchasePrice * (1+row.markupPercentage/100)).toFixed(4) } } },{ key: "sellingPrice", label: "Verkaufpreispreis", required: true, component: sellingPrice, inputType: "number", inputTrailing: "EUR", inputChangeFunction: function (row) { if(row.purchasePrice ) { row.markupPercentage = ((row.sellingPrice / row.purchasePrice - 1) * 100 ).toFixed(2) } else{ row.purchasePrice = (row.sellingPrice / (1+row.markupPercentage/100)).toFixed(4) } } },{ 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}] }, /*{ key: "tags", label: "Tags" },*/ { key: "productcategories", label: "Artikelkategorien", inputType: "select", selectDataType: "productcategories", selectOptionAttribute: "name", selectSearchAttributes: ['name'], selectMultiple: true }, { key: "description", label: "Beschreibung", inputType:"textarea" }, ], showTabs: [ { label: "Informationen" } ] }, projects: { isArchivable: true, label: "Projekte", labelSingle: "Projekt", isStandardEntity: true, redirect:true, historyItemHolder: "project", numberRangeHolder: "projectNumber", supabaseSelectWithInformation: "*, 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))", supabaseSortColumn: "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" }, { key: "projecttype", label: "Typ", required: true, component: projecttype, inputType: "select", selectDataType: "projecttypes", selectOptionAttribute: "name", selectSearchAttributes: ['name'], inputChangeFunction: function (item,loadedOptions = {}) { item.phases = loadedOptions.projecttypes.find(i => i.id === item.projecttype).initialPhases } },{ key: "phase", label: "Phase", component: phase },{ key: "name", label: "Name", required: true, title: true, inputType: "text" }, { 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" }/*,{ 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", supabaseSelectWithInformation: "*, 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" },{ key: 'licensePlate', label: "Kennzeichen", required: true, inputType: "text", title: true },{ key: 'vin', label: "Identifikationnummer", inputType: "text" }, { key: "type", label: "Typ", inputType: "text" }, { key: "driver", label: "Fahrer", inputType: "select", selectDataType: "profiles", selectOptionAttribute: "fullName", component: driver }, { key: "tankSize", label: "Tankvolumen", unit: "L", inputType: "number" }, { key: "buildYear", label: "Baujahr", inputType: "number" }, { key: "towingCapacity", label: "Anhängelast", unit: "Kg", inputType: "number" }, { key: "color", label: "Farbe", inputType: "text" }, { key: "powerInKW", label: "Leistung", unit: "kW", inputType: "number" }, /*{ 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', } ] }, vendors: { isArchivable: true, label: "Lieferanten", labelSingle: "Lieferant", isStandardEntity: true, redirect:true, numberRangeHolder: "vendorNumber", historyItemHolder: "vendor", supabaseSortColumn: "vendorNumber", supabaseSelectWithInformation: "*, 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 }, { key: "name", required: true, label: "Name", title: true, inputType: "text" }, { 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: "number", disabledInTable: true, inputChangeFunction: async function (row) { if(row.infoData.zip) { row.infoData.city = (await useZipCheck(row.infoData.zip)) } }, }, { 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.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', } ] }, messages: { label: "Nachrichten", labelSingle: "Nachricht" }, spaces: { isArchivable: true, label: "Lagerplätze", labelSingle: "Lagerplatz", isStandardEntity: true, supabaseSelectWithInformation: "*, files(*)", supabaseSortColumn: "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" }, { key: 'spaceNumber', label: "Lagerplatznr.", inputType: "text", inputIsNumberRange: true, inputColumn: "Allgemeines" }, { key: "type", label: "Typ", inputType: "select", required: true, selectValueAttribute: "label", selectManualOptions: [ {label:"Standort"}, {label:"Regalplatz"}, {label:"Kiste"}, {label:"Palettenplatz"}, {label:"Sonstiges"} ], inputColumn: "Allgemeines" }, { key: "parentSpace", label: "Übergeordneter Lagerplatz", inputType: "select", selectDataType: "spaces", selectOptionAttribute: "spaceNumber", selectValueAttribute: "id", inputColumn: "Allgemeines" }, { key: "infoData.streetNumber", label: "Straße + Hausnummer", inputType: "text", disabledInTable: true, inputColumn: "Ort" }, { key: "infoData.special", label: "Adresszusatz", inputType: "text", disabledInTable: true, inputColumn: "Ort" }, { key: "infoData.zip", label: "Postleitzahl", inputType: "number", disabledInTable: true, inputColumn: "Ort", inputChangeFunction: async function (row) { if(row.infoData.zip) { row.infoData.city = (await useZipCheck(row.infoData.zip)) } }, }, { key: "infoData.city", label: "Stadt", inputType: "text", disabledInTable: true, inputColumn: "Ort" }, { key: "infoData.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'} ] }, users: { label: "Benutzer", labelSingle: "Benutzer" }, createddocuments: { isArchivable: true, label: "Dokumente", labelSingle: "Dokument", supabaseSelectWithInformation: "*, files(*), statementallocations(*)", }, incominginvoices: { label: "Eingangsrechnungen", labelSingle: "Eingangsrechnung", redirect:true }, inventoryitems: { isArchivable: true, label: "Inventarartikel", labelSingle: "Inventarartikel", isStandardEntity: true, supabaseSelectWithInformation: "*, 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" }, { key: "usePlanning", label: "In Plantafel anzeigen", inputType: "bool", inputColumn: "Allgemeines", component: usePlanning }, { key: "description", label: "Beschreibung", inputType: "textarea", }, { 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" }, { key: "serialNumber", label: "Seriennummer", inputType: "text", inputColumn: "Allgemeines" }, { key: "purchaseDate", label: "Kaufdatum", inputType: "date", inputColumn: "Anschaffung" }, { 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 }, { key: "purchasePrice", label: "Kaufpreis", inputType: "number", inputStepSize: "0.01", inputColumn: "Anschaffung" }, { 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" }, ], showTabs: [ { label: 'Informationen', }, { label: 'Dateien', } ] }, inventoryitemgroups: { isArchivable: true, label: "Inventarartikelgruppen", labelSingle: "Inventarartikelgruppe", isStandardEntity: true, historyItemHolder: "inventoryitemgroup", supabaseSelectWithInformation: "*", 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", }, { 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', } ] }, documentboxes: { isArchivable: true, label: "Dokumentenboxen", labelSingle: "Dokumentenbox", isStandardEntity: true, supabaseSelectWithInformation: "*, 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, supabaseSelectWithInformation: "*, unit(*)", 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" }, { key: "unit", label: "Einheit", component: unit, inputType: "select", selectDataType: "units", selectOptionAttribute: "name", required: true, selectSearchAttributes: ['name'], }, { key: "sellingPrice", label: "Verkaufspreis", component: sellingPrice, }, { 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: "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', } ] }, hourrates: { isArchivable: true, label: "Stundensätze", labelSingle: "Stundensatz", isStandardEntity: true, redirect: true, supabaseSelectWithInformation: "*", 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" }, { key: "purchasePrice", label: "Einkauspreis", inputType: "number", component: purchasePrice, }, { key: "sellingPrice", label: "Verkaufspreis", inputType: "number", component: sellingPrice, }, ], showTabs: [ { label: 'Informationen', } ] }, events: { isArchivable: true, label: "Termine", labelSingle: "Termin", isStandardEntity: true, historyItemHolder: "event", supabaseSelectWithInformation: "*, 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" }, { key: "startDate", label: "Start", required: true, inputType: "datetime", component: startDateTime }, { key: "endDate", label: "Ende", required: true, inputType: "datetime", component: endDateTime },/*{ 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: "licensePlate", selectSearchAttributes: ['licensePlate'], 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',} ] }, profiles: { label: "Mitarbeiter", labelSingle: "Mitarbeiter", redirect: true, historyItemHolder: "profile" }, workingtimes: { isArchivable: true, label: "Anwesenheiten", labelSingle: "Anwesenheit", redirect: true, redirectToList: true }, texttemplates: { isArchivable: true, label: "Textvorlagen", labelSingle: "Textvorlage" }, 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, supabaseSelectWithInformation: "*", 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: "description", label: "Beschreibung", inputType: "textarea" } ], showTabs: [ { label: 'Informationen', } ] }, servicecategories: { isArchivable: true, label: "Leistungskategorien", labelSingle: "Leistungskategorie", isStandardEntity: true, redirect: true, supabaseSelectWithInformation: "*", 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: "description", label: "Beschreibung", inputType: "textarea" } ], showTabs: [ { label: 'Informationen', } ] }, 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, supabaseSelectWithInformation: "*, 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", supabaseSortColumn: "number", supabaseSelectWithInformation: "*, project(*), vehicle(*), inventoryitem(*)", 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" }, { key: "name", label: "Name", required: true, title: true, inputType: "text", }, { key: "description", label: "Beschreibung", inputType: "textarea" }, { key: "vehicle", label: "Fahrzeug", component: vehicle, inputType: "select", selectDataType: "vehicles", selectOptionAttribute: "licensePlate", selectSearchAttributes: ['licensePlate'], }, { 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: "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", supabaseSortColumn: "number", supabaseSelectWithInformation: "*, 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" }, { key: "name", label: "Name", required: true, title: true, inputType: "text", }, { 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'}] }, } const documentTypesForCreation = ref({ invoices: { label: "Rechnungen", labelSingle: "Rechnung", }, serialInvoices: { label: "Serienrechnungen", labelSingle: "Serienrechnung", }, advanceInvoices: { label: "Abschlagsrechnungen", labelSingle: "Abschlagsrechnung" }, cancellationInvoices: { label: "Stornorechnungen", labelSingle: "Stornorechnung" }, quotes: { label: "Angebote", labelSingle: "Angebot" }, deliveryNotes: { label: "Lieferscheine", labelSingle: "Lieferschein" }, confirmationOrders: { label: "Auftragsbestätigungen", labelSingle: "Auftragsbestätigung" } }) async function createNewItem (dataType,data,noRedirect=false){ if(typeof(data) === 'object') { data = {...data, tenant: profileStore.currentTenant} } else if(typeof(data) === 'array') { data.map(i => { return { ...i, tenant: profileStore.currentTenant } }) } console.log(dataType) if(dataTypes[dataType].numberRangeHolder) { if(!data[dataTypes[dataType].numberRangeHolder]) { data[dataTypes[dataType].numberRangeHolder] = await useFunctions().useNextNumber(dataType) } } else if(dataType === "createddocuments" && data.type !== "serialInvoices") { /*if(data.state !== "Entwurf") { console.log(data.type) let type = "" if(data.type === "advanceInvoices"){ type = "invoices" } else { type = data.type } const numberRange = useNumberRange(type) data.documentNumber = await numberRange.useNextNumber() }*/ } const {data:supabaseData,error:supabaseError} = await supabase .from(dataType) .insert(data) .select() if(supabaseError) { console.log(supabaseError) toast.add({title: "Es ist ein Fehler bei der Erstellung aufgetreten", color: "rose"}) } else if (supabaseData) { console.log(supabaseData) let returnData = supabaseData[0] await generateHistoryItems(dataType, supabaseData[0]) /*if(!["statementallocations","absencerequests", "productcategories", "servicecategories", "projecttypes", "checks", "profiles","services", "inventoryitems", "inventoryitemgroups", "incominginvoices", "costcentres", "ownaccounts"].includes(dataType) ){ await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')') }*/ toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`}) if(dataTypes[dataType].redirect && !noRedirect) { if(dataTypes[dataType].isStandardEntity) { await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${returnData.id}`) } else { await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${returnData.id}`) } } modal.close() return supabaseData[0] } } async function updateItem (dataType, data, oldData = null, noRedirect = false) { //console.log(dataType, data) //Temporary Fix TODO: Remove and build Solution data = JSON.parse(JSON.stringify(data)) delete data.users if(oldData) { oldData = JSON.parse(JSON.stringify(oldData)) delete oldData.users } const {tenants, ...newData} = data /*if(dataType === "createddocuments" && data.type !== "serialInvoices") { if(data.state !== "Entwurf") { console.log(data.type) let type = "" if(data.type === "advanceInvoices"){ type = "invoices" } else { type = data.type } const numberRange = useNumberRange(type) data.documentNumber = await numberRange.useNextNumber() } }*/ await generateHistoryItems(dataType,data,oldData) const {data:supabaseData,error: supabaseError} = await supabase .from(dataType) .update(newData) .eq('id',newData.id) .select() if(supabaseError) { console.log(supabaseError) toast.add({title: `Fehler beim Speichern`, color: 'rose'}) } else if(supabaseData) { //await eval(dataType + '.value[' + dataType + '.value.findIndex(i => i.id === ' + JSON.stringify(data.id) + ')] = ' + JSON.stringify(supabaseData[0])) //if(dataType === 'profiles') await fetchProfiles() toast.add({title: `${dataTypes[dataType].labelSingle} gespeichert`}) if(dataTypes[dataType].redirect && !noRedirect) { if(dataTypes[dataType].isStandardEntity) { await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${data.id}`) } else { await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${data.id}`) } } modal.close() return supabaseData[0] } } return { dataTypes, documentTypesForCreation, createNewItem, updateItem, } })