From 15a889dfcf3417a46e479b23c1f9ee100b935bf3 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 16 Mar 2025 17:36:16 +0100 Subject: [PATCH 1/8] Added Archivable Prop to Datatypes wich are archivable Added Filtering to SupabaseSelect Composable for Archived --- composables/useSupabase.js | 7 +++++++ stores/data.js | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/composables/useSupabase.js b/composables/useSupabase.js index b45e94e..688d307 100644 --- a/composables/useSupabase.js +++ b/composables/useSupabase.js @@ -1,10 +1,13 @@ +import {useDataStore} from "~/stores/data.js"; export const useSupabaseSelect = async (relation,select = '*', sortColumn = null, ascending = true) => { const supabase = useSupabaseClient() const profileStore = useProfileStore() let data = null + const dataStore = useDataStore() + const dataType = dataStore.dataTypes[relation] if(sortColumn !== null ) { data = (await supabase @@ -19,6 +22,10 @@ export const useSupabaseSelect = async (relation,select = '*', sortColumn = null .eq("tenant", profileStore.currentTenant)).data } + if(dataType && dataType.isArchivable) { + data = data.filter(i => !i.archived) + } + return data } diff --git a/stores/data.js b/stores/data.js index ad2769c..ebfebea 100644 --- a/stores/data.js +++ b/stores/data.js @@ -55,6 +55,7 @@ export const useDataStore = defineStore('data', () => { const dataTypes = { tasks: { + isArchivable: true, label: "Aufgaben", labelSingle: "Aufgabe", isStandardEntity: true, @@ -146,6 +147,7 @@ export const useDataStore = defineStore('data', () => { showTabs: [{label: 'Informationen'}] }, customers: { + isArchivable: true, label: "Kunden", labelSingle: "Kunde", isStandardEntity: true, @@ -310,6 +312,7 @@ export const useDataStore = defineStore('data', () => { showTabs: [{label: 'Informationen'},{label: 'Ansprechpartner'},{label: 'Dateien'},{label: 'Ausgangsbelege'},{label: 'Projekte'},{label: 'Objekte'},{label: 'Verträge'}] }, contacts: { + isArchivable: true, label: "Kontakte", labelSingle: "Kontakt", isStandardEntity: true, @@ -414,6 +417,7 @@ export const useDataStore = defineStore('data', () => { ] }, contracts: { + isArchivable: true, label: "Verträge", labelSingle: "Vertrag", isStandardEntity: true, @@ -561,6 +565,7 @@ export const useDataStore = defineStore('data', () => { showTabs: [{label: 'Informationen'},{label: 'Dateien'}] }, absencerequests: { + isArchivable: true, label: "Abwesenheiten", labelSingle: "Abwesenheit", isStandardEntity: true, @@ -650,6 +655,7 @@ export const useDataStore = defineStore('data', () => { showTabs: [{label: 'Informationen'}] }, plants: { + isArchivable: true, label: "Objekte", labelSingle: "Objekt", isStandardEntity: true, @@ -702,6 +708,7 @@ export const useDataStore = defineStore('data', () => { }] }, products: { + isArchivable: true, label: "Artikel", labelSingle: "Artikel", isStandardEntity: true, @@ -793,6 +800,7 @@ export const useDataStore = defineStore('data', () => { ] }, projects: { + isArchivable: true, label: "Projekte", labelSingle: "Projekt", isStandardEntity: true, @@ -923,6 +931,7 @@ export const useDataStore = defineStore('data', () => { }*/] }, vehicles: { + isArchivable: true, label: "Fahrzeuge", labelSingle: "Fahrzeug", isStandardEntity: true, @@ -1020,6 +1029,7 @@ export const useDataStore = defineStore('data', () => { ] }, vendors: { + isArchivable: true, label: "Lieferanten", labelSingle: "Lieferant", isStandardEntity: true, @@ -1158,6 +1168,7 @@ export const useDataStore = defineStore('data', () => { labelSingle: "Nachricht" }, spaces: { + isArchivable: true, label: "Lagerplätze", labelSingle: "Lagerplatz", isStandardEntity: true, @@ -1288,6 +1299,7 @@ export const useDataStore = defineStore('data', () => { labelSingle: "Benutzer" }, createddocuments: { + isArchivable: true, label: "Dokumente", labelSingle: "Dokument" }, @@ -1297,6 +1309,7 @@ export const useDataStore = defineStore('data', () => { redirect:true }, inventoryitems: { + isArchivable: true, label: "Inventarartikel", labelSingle: "Inventarartikel", isStandardEntity: true, @@ -1436,6 +1449,7 @@ export const useDataStore = defineStore('data', () => { ] }, inventoryitemgroups: { + isArchivable: true, label: "Inventarartikelgruppen", labelSingle: "Inventarartikelgruppe", isStandardEntity: true, @@ -1500,6 +1514,7 @@ export const useDataStore = defineStore('data', () => { ] }, services: { + isArchivable: true, label: "Leistungen", labelSingle: "Leistung", isStandardEntity: true, @@ -1626,6 +1641,7 @@ export const useDataStore = defineStore('data', () => { ] }, events: { + isArchivable: true, label: "Termine", labelSingle: "Termin", isStandardEntity: true, @@ -1750,16 +1766,19 @@ export const useDataStore = defineStore('data', () => { 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", @@ -1769,6 +1788,7 @@ export const useDataStore = defineStore('data', () => { labelSingle: "Bankzuweisung" }, productcategories: { + isArchivable: true, label: "Artikelkategorien", labelSingle: "Artikelkategorie", isStandardEntity: true, @@ -1806,6 +1826,7 @@ export const useDataStore = defineStore('data', () => { ] }, servicecategories: { + isArchivable: true, label: "Leistungskategorien", labelSingle: "Leistungskategorie", isStandardEntity: true, @@ -1849,12 +1870,14 @@ export const useDataStore = defineStore('data', () => { historyItemHolder: "trackingtrip", }, projecttypes: { + isArchivable: true, label: "Projekttypen", labelSingle: "Projekttyp", redirect: true, historyItemHolder: "projecttype" }, checks: { + isArchivable: true, label: "Überprüfungen", labelSingle: "Überprüfung", isStandardEntity: true, From 898663344b23c4dbae3ba98fa6415a7a86c3e5f9 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 16 Mar 2025 18:00:37 +0100 Subject: [PATCH 2/8] Added Create,Edit,Show to Products and Services --- pages/createDocument/edit/[[id]].vue | 45 +++++++++++++++++++--------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index c11fda1..3362f1f 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -3,7 +3,6 @@ import dayjs from "dayjs" import Handlebars from "handlebars" import { v4 as uuidv4 } from 'uuid'; import {useFunctions} from "~/composables/useFunctions.js"; -import StandardEntityModal from "~/components/StandardEntityModal.vue"; import EntityModalButtons from "~/components/EntityModalButtons.vue"; const dataStore = useDataStore() @@ -1144,33 +1143,41 @@ const updateCustomSurcharge = () => { }) } -const setRowData = (row) => { - console.log(row) +const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {}) => { + + if(service && service.id) { + row.service = service.id + services.value = await useSupabaseSelect("services","*") + } + + if(product && product.id) { + row.product = product.id + product.value = await useSupabaseSelect("products","*") + } + if(row.service) { - row.unit = services.value.find(i => i.id === row.service).unit - row.price = (services.value.find(i => i.id === row.service).sellingPriceComposed.total || services.value.find(i => i.id === row.service).sellingPrice) * (1 + itemInfo.value.customSurchargePercentage /100) - row.description = services.value.find(i => i.id === row.service).description + row.unit = service.unit ? service.unit : services.value.find(i => i.id === row.service).unit + row.price = ((service.sellingPriceComposed.total || service.sellingPrice) ? (service.sellingPriceComposed.total || service.sellingPrice) : (services.value.find(i => i.id === row.service).sellingPriceComposed.total || services.value.find(i => i.id === row.service).sellingPrice)) * (1 + itemInfo.value.customSurchargePercentage /100) + row.description = service.description ? service.description : (services.value.find(i => i.id === row.service) ? services.value.find(i => i.id === row.service).description : "") if(['13b UStG','19 UStG'].includes(itemInfo.value.taxType)) { row.taxPercent = 0 } else { - row.taxPercent = services.value.find(i => i.id === row.service).taxPercentage + row.taxPercent = service.taxPercentage ? service.taxPercentage : services.value.find(i => i.id === row.service).taxPercentage } } if(row.product) { - row.unit = products.value.find(i => i.id === row.product).unit - row.price = products.value.find(i => i.id === row.product).sellingPrice * (1 + itemInfo.value.customSurchargePercentage /100) - row.description = products.value.find(i => i.id === row.product).description + row.unit = product.unit ? product.unit : products.value.find(i => i.id === row.product).unit + row.price = (product.sellingPrice ? product.sellingPrice : products.value.find(i => i.id === row.product).sellingPrice) * (1 + itemInfo.value.customSurchargePercentage /100) + row.description = product.description ? product.description : (products.value.find(i => i.id === row.product) ? products.value.find(i => i.id === row.product).description : "") if(['13b UStG','19 UStG'].includes(itemInfo.value.taxType)) { row.taxPercent = 0 } else { - row.taxPercent = products.value.find(i => i.id === row.product).taxPercentage + row.taxPercent = product.taxPercentage ? product.taxPercentage : products.value.find(i => i.id === row.product).taxPercentage } } - - } @@ -1941,9 +1948,14 @@ const setRowData = (row) => { @change="setRowData(row)" > + { {{services.find(i => i.id === row.service) ? services.find(i => i.id === row.service).name : "Keine Leistung ausgewählt" }} + Date: Sun, 16 Mar 2025 18:00:57 +0100 Subject: [PATCH 3/8] Removed Steuer & Rabatt from Direct View --- pages/createDocument/edit/[[id]].vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 3362f1f..907d11d 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -1875,8 +1875,8 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = { Menge Einheit Preis - Steuer - Rabatt + Gesamt @@ -2105,7 +2105,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = { - - - --> + Date: Sun, 16 Mar 2025 18:01:21 +0100 Subject: [PATCH 4/8] Made SellingPrice Total required in Services --- stores/data.js | 1 + 1 file changed, 1 insertion(+) diff --git a/stores/data.js b/stores/data.js index ebfebea..d78c5c5 100644 --- a/stores/data.js +++ b/stores/data.js @@ -1614,6 +1614,7 @@ export const useDataStore = defineStore('data', () => { label: "Verkaufspreis Gesamt pro Einheit", inputType: "number", inputTrailing: "EUR", + required: true, /*disabledFunction: function (item) { return item.sellingPriceComposed.worker || item.sellingPriceComposed.material },*/ From 11594e6dc7898c96be93d70cb8e9451d5ce26fc8 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 16 Mar 2025 18:36:00 +0100 Subject: [PATCH 5/8] Fixed Create Change --- pages/createDocument/edit/[[id]].vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 907d11d..5c8c292 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -1069,7 +1069,7 @@ const saveDocument = async (state,resetup = false) => { } else { const data = await dataStore.createNewItem("createddocuments", createData) console.log(data) - await router.push(`/createDocument/edit/${data[0].id}`) + await router.push(`/createDocument/edit/${data.id}`) } if(resetup) await setupPage() From cff5d9be298819492af2c807d0d8986e00163806 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 16 Mar 2025 18:36:12 +0100 Subject: [PATCH 6/8] Rebuild Document Copy Process --- components/copyCreatedDocumentModal.vue | 106 ++++++++++++++++++++++++ pages/createDocument/edit/[[id]].vue | 67 ++++++++++++--- pages/createDocument/show/[id].vue | 17 +++- 3 files changed, 174 insertions(+), 16 deletions(-) create mode 100644 components/copyCreatedDocumentModal.vue diff --git a/components/copyCreatedDocumentModal.vue b/components/copyCreatedDocumentModal.vue new file mode 100644 index 0000000..a06010a --- /dev/null +++ b/components/copyCreatedDocumentModal.vue @@ -0,0 +1,106 @@ + + + + + \ No newline at end of file diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 5c8c292..f73a0a7 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -198,19 +198,60 @@ const setupPage = async () => { if(route.query.linkedDocument) { itemInfo.value.linkedDocument = route.query.linkedDocument - let linkedDocument = await useSupabaseSelectSingle("createddocuments",itemInfo.value.linkedDocument) - itemInfo.value.rows = linkedDocument.rows - itemInfo.value.customer = linkedDocument.customer - itemInfo.value.project = linkedDocument.project - itemInfo.value.contact = linkedDocument.contact - itemInfo.value.description = linkedDocument.description - itemInfo.value.deliveryDate = linkedDocument.deliveryDate - itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType + + if(route.query.optionsToImport) { + //Import only true + let optionsToImport = JSON.parse(route.query.optionsToImport) + + console.log(optionsToImport) + console.log(linkedDocument) + + if(optionsToImport.taxType) itemInfo.value.taxType = linkedDocument.taxType + if(optionsToImport.customer) itemInfo.value.customer = linkedDocument.customer + if(optionsToImport.letterhead) itemInfo.value.letterhead = linkedDocument.letterhead + if(optionsToImport.contact) itemInfo.value.contact = linkedDocument.contact + if(optionsToImport.deliveryDateType) itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType + if(optionsToImport.deliveryDate) itemInfo.value.deliveryDate = linkedDocument.deliveryDate + if(optionsToImport.deliveryDateEnd) itemInfo.value.deliveryDateEnd = linkedDocument.deliveryDateEnd + if(optionsToImport.documentDate) itemInfo.value.documentDate = linkedDocument.documentDate + if(optionsToImport.paymentDays) itemInfo.value.paymentDays = linkedDocument.paymentDays + if(optionsToImport.customSurchargePercentage) itemInfo.value.customSurchargePercentage = linkedDocument.customSurchargePercentage + if(optionsToImport.contactPerson) itemInfo.value.contactPerson = linkedDocument.contactPerson + if(optionsToImport.plant) itemInfo.value.plant = linkedDocument.plant + if(optionsToImport.project) itemInfo.value.project = linkedDocument.project + if(optionsToImport.title) itemInfo.value.title = linkedDocument.title + if(optionsToImport.description) itemInfo.value.description = linkedDocument.description + if(optionsToImport.startText) itemInfo.value.startText = linkedDocument.startText + if(optionsToImport.rows) itemInfo.value.rows = linkedDocument.rows + if(optionsToImport.endText) itemInfo.value.endText = linkedDocument.endText + + } else { + // Import all + + itemInfo.value.taxType = linkedDocument.taxType + itemInfo.value.customer = linkedDocument.customer + itemInfo.value.letterhead = linkedDocument.letterhead + itemInfo.value.contact = linkedDocument.contact + itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType + itemInfo.value.deliveryDate = linkedDocument.deliveryDate + itemInfo.value.deliveryDateEnd = linkedDocument.deliveryDateEnd + itemInfo.value.documentDate = linkedDocument.documentDate + itemInfo.value.paymentDays = linkedDocument.paymentDays + itemInfo.value.customSurchargePercentage = linkedDocument.customSurchargePercentage + itemInfo.value.contactPerson = linkedDocument.contactPerson + itemInfo.value.plant = linkedDocument.plant + itemInfo.value.project = linkedDocument.project + itemInfo.value.title = linkedDocument.title + itemInfo.value.description = linkedDocument.description + itemInfo.value.startText = linkedDocument.startText + itemInfo.value.rows = linkedDocument.rows + itemInfo.value.endText = linkedDocument.endText + } - setCustomerData() + setCustomerData(null,true) if(route.query.loadMode === "storno") { itemInfo.value.rows.forEach(row => { @@ -323,7 +364,7 @@ const setTaxType = () => { } } -const setCustomerData = async (customerId) => { +const setCustomerData = async (customerId, loadOnlyAdress = false) => { if(customerId){ itemInfo.value.customer = customerId @@ -341,11 +382,11 @@ const setCustomerData = async (customerId) => { itemInfo.value.address.city = customer.infoData.city itemInfo.value.address.special = customer.infoData.special - if(customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays + if(!loadOnlyAdress && customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays - if(customer.customSurchargePercentage) itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage + if(!loadOnlyAdress && customer.customSurchargePercentage) itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage - if(contacts.value.filter(i => i.customer === itemInfo.value.customer).length === 1) { + if(!loadOnlyAdress && contacts.value.filter(i => i.customer === itemInfo.value.customer).length === 1) { itemInfo.value.contact = contacts.value.filter(i => i.customer === itemInfo.value.customer)[0].id } diff --git a/pages/createDocument/show/[id].vue b/pages/createDocument/show/[id].vue index c6064c9..200030a 100644 --- a/pages/createDocument/show/[id].vue +++ b/pages/createDocument/show/[id].vue @@ -1,4 +1,6 @@