Added Errors to IncomingInvoices

Added Vorbereitet to IncomingInvoices
This commit is contained in:
2025-06-30 13:45:06 +02:00
parent 93d0f97a56
commit ff6ee91075
4 changed files with 85 additions and 9 deletions

View File

@@ -12,7 +12,7 @@ let unpaidOverdueInvoicesCount = ref(0)
let draftInvoicesSum = ref(0)
let draftInvoicesCount = ref(0)
let countUnfinishedOpenIncomingInvoices = ref(0)
let countPreparedOpenIncomingInvoices = ref(0)
const setupPage = async () => {
let items = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name), linkedDocument(*)")).filter(i => !i.archived)
@@ -45,8 +45,7 @@ const setupPage = async () => {
})
draftInvoicesCount.value = draftDocuments.length
let filetype = (await supabase.from("filetags").select().eq("tenant",profileStore.currentTenant).eq("incomingDocumentType","invoices").single()).data.id
countUnfinishedOpenIncomingInvoices.value = (await supabase.from("files").select("id").eq("tenant",profileStore.currentTenant).eq("type", filetype).is("incominginvoice",null)).data.length
countPreparedOpenIncomingInvoices.value = (await supabase.from("incominginvoices").select("id").eq("tenant",profileStore.currentTenant).eq("state", "Vorbereitet")).data.length
}
@@ -84,9 +83,9 @@ setupPage()
<tr>
<td class="break-all">ToDo Eingangsrechnungsrechnungen:</td>
<td
v-if="countUnfinishedOpenIncomingInvoices > 0"
v-if="countPreparedOpenIncomingInvoices > 0"
class="text-orange-500 font-bold text-nowrap"
>{{countUnfinishedOpenIncomingInvoices}} Stk </td>
>{{countPreparedOpenIncomingInvoices}} Stk </td>
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk</td>
</tr>
</table>

View File

@@ -125,14 +125,43 @@ const totalCalculated = computed(() => {
})
const updateIncomingInvoice = async () => {
const updateIncomingInvoice = async (setBooked = false) => {
let item = itemInfo.value
delete item.files
if(item.state === "Vorbereitet" && !setBooked) {
item.state = "Entwurf"
} else if(item.state === "Vorbereitet" && setBooked) {
item.state = "Gebucht"
}
const data = await dataStore.updateItem('incominginvoices',item)
}
const findIncomingInvoiceErrors = computed(() => {
let errors = []
if(itemInfo.value.vendor === null) errors.push({message: "Es ist kein Lieferant ausgewählt", type: "breaking"})
if(itemInfo.value.reference === null) errors.push({message: "Es ist keine Referenz angegeben", type: "breaking"})
if(itemInfo.value.date === null) errors.push({message: "Es ist kein Datum ausgewählt", type: "breaking"})
if(itemInfo.value.dueDate === null) errors.push({message: "Es ist kein Fälligkeitsdatum ausgewählt", type: "breaking"})
if(itemInfo.value.paymentType === null) errors.push({message: "Es ist keine Zahlart ausgewählt", type: "breaking"})
if(itemInfo.value.description === null) errors.push({message: "Es ist keine Beschreibung angegeben", type: "info"})
itemInfo.value.accounts.forEach(account => {
if(account.account === null) errors.push({message: "Es ist keine Kategorie ausgewählt", type: "breaking"})
if(account.amountNet === null) errors.push({message: "Es ist kein Nettobetrag angegeben", type: "breaking"})
if(account.taxType === null) errors.push({message: "Es ist kein Steuertyp ausgewählt", type: "breaking"})
if(account.costCentre === null) errors.push({message: "Es ist keine Kostenstelle ausgewählt", type: "info"})
})
return errors.sort((a,b) => (a.type === "breaking") ? -1 : 1)
})
</script>
@@ -144,6 +173,12 @@ const updateIncomingInvoice = async () => {
>
Speichern
</UButton>
<UButton
@click="updateIncomingInvoice(true)"
:disabled="findIncomingInvoiceErrors.filter(i => i.type === 'breaking').length > 0"
>
Speichern & Buchen
</UButton>
</template>
</UDashboardNavbar>
<UDashboardPanelContent>
@@ -158,7 +193,22 @@ const updateIncomingInvoice = async () => {
/>
<div class="w-3/5 mx-5">
<UAlert
class="mb-5"
title="Vorhandene Probleme und Informationen:"
:color="findIncomingInvoiceErrors.filter(i => i.type === 'breaking').length > 0 ? 'rose' : 'white'"
variant="outline"
v-if="findIncomingInvoiceErrors.length > 0"
>
<template #description>
<ul class="list-disc ml-5">
<li v-for="error in findIncomingInvoiceErrors" :class="[...error.type === 'breaking' ? ['text-rose-600'] : ['dark:text-white','text-black']]">
{{error.message}}
</li>
</ul>
</template>
</UAlert>
<div class=" scrollContainer">
<InputGroup class="mb-3">
@@ -470,7 +520,7 @@ const updateIncomingInvoice = async () => {
overflow-y: scroll;
padding-left: 1em;
padding-right: 1em;
height: 75vh;
height: 70vh;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}

View File

@@ -93,7 +93,10 @@ const columns = computed(() => templateColumns.filter((column) => selectedColumn
const searchString = ref('')
const filteredRows = computed(() => {
return useSearch(searchString.value, items.value)
let filteredItems = useSearch(searchString.value, items.value)
return [...filteredItems.filter(i => i.state === "Vorbereitet"), ...filteredItems.filter(i => i.state !== "Vorbereitet")]
})
@@ -115,6 +118,16 @@ const isPaid = (item) => {
return Math.abs(amountPaid) === Math.abs(Number(getInvoiceSum(item)))
}
const selectIncomingInvoice = (invoice) => {
if(invoice.state === "Vorbereitet") {
router.push(`/incomingInvoices/edit/${invoice.id}`)
} else {
router.push(`/incomingInvoices/show/${invoice.id}`)
}
}
</script>
@@ -162,13 +175,18 @@ const isPaid = (item) => {
:columns="columns"
class="w-full"
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
@select="(i) => router.push(`/incomingInvoices/show/${i.id}`) "
@select="(i) => selectIncomingInvoice(i) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Belege anzuzeigen' }"
>
<template #reference-data="{row}">
<span v-if="row === filteredRows[selectedItem]" class="text-primary-500 font-bold">{{row.reference}}</span>
<span v-else>{{row.reference}}</span>
</template>
<template #state-data="{row}">
<span v-if="row.state === 'Vorbereitet'" class="text-cyan-500">{{row.state}}</span>
<span v-else-if="row.state === 'Entwurf'" class="text-red-500">{{row.state}}</span>
<span v-else-if="row.state === 'Gebucht'" class="text-primary-500">{{row.state}}</span>
</template>
<template #date-data="{row}">
{{dayjs(row.date).format("DD.MM.YYYY")}}
</template>

View File

@@ -71,6 +71,15 @@ setupPage()
<template>
<UDashboardNavbar :title="'Eingangsbeleg anzeigen'">
<template #left>
<UButton
to="/incominginvoices"
icon="i-heroicons-chevron-left"
variant="outline"
>
Übersicht
</UButton>
</template>
<template #right>
<UButton
@click="router.push(`/incomingInvoices/edit/${itemInfo.id}`)"