From 94ed9ac34305b94be2b003327f97aa5cea17df91 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Fri, 2 Jan 2026 12:39:47 +0100 Subject: [PATCH] Added Preparing --- pages/incomingInvoices/index.vue | 50 ++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/pages/incomingInvoices/index.vue b/pages/incomingInvoices/index.vue index 8d12d6e..52e884f 100644 --- a/pages/incomingInvoices/index.vue +++ b/pages/incomingInvoices/index.vue @@ -2,6 +2,9 @@ import dayjs from "dayjs" import {useSum} from "~/composables/useSum.js"; +// Zugriff auf API und Toast +const { $api } = useNuxtApp() +const toast = useToast() defineShortcuts({ '/': () => { @@ -47,6 +50,9 @@ const sort = ref({ direction: 'desc' }) +// Status für den Button +const isPreparing = ref(false) + const type = "incominginvoices" const dataType = dataStore.dataTypes[type] @@ -54,6 +60,34 @@ const setupPage = async () => { items.value = await useEntities(type).select("*, vendor(id,name), statementallocations(id,amount)",sort.value.column,sort.value.direction === "asc") } +// Funktion zum Vorbereiten der Belege +const prepareInvoices = async () => { + isPreparing.value = true + try { + await $api('/api/functions/services/prepareincominginvoices', { method: 'POST' }) + + toast.add({ + title: 'Erfolg', + description: 'Eingangsbelege wurden vorbereitet.', + icon: 'i-heroicons-check-circle', + color: 'green' + }) + + // Liste neu laden + await setupPage() + } catch (error) { + console.error(error) + toast.add({ + title: 'Fehler', + description: 'Beim Vorbereiten der Belege ist ein Fehler aufgetreten.', + icon: 'i-heroicons-exclamation-circle', + color: 'red' + }) + } finally { + isPreparing.value = false + } +} + setupPage() const selectedColumns = ref(tempStore.columns[type] ? tempStore.columns[type] : dataType.templateColumns.filter(i => !i.disabledInTable)) @@ -128,6 +162,17 @@ const selectIncomingInvoice = (invoice) => {