Gebuchte Eingangsbelege bearbeitbar machen
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 35s
Build and Push Docker Images / build-central-services-api (push) Successful in 35s
Build and Push Docker Images / build-docs (push) Successful in 33s
Build and Push Docker Images / build-frontend (push) Successful in 1m54s
Build and Push Docker Images / build-website (push) Successful in 35s
Build and Push Docker Images / build-central-services-admin (push) Successful in 34s
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 35s
Build and Push Docker Images / build-central-services-api (push) Successful in 35s
Build and Push Docker Images / build-docs (push) Successful in 33s
Build and Push Docker Images / build-frontend (push) Successful in 1m54s
Build and Push Docker Images / build-website (push) Successful in 35s
Build and Push Docker Images / build-central-services-admin (push) Successful in 34s
This commit is contained in:
@@ -49,6 +49,11 @@ const loadedFileId = ref(null)
|
|||||||
const invoiceFiles = ref([])
|
const invoiceFiles = ref([])
|
||||||
const paymentTypeItems = ['Überweisung', 'Lastschrift', 'Kreditkarte', 'PayPal', 'Bar', 'Sonstiges']
|
const paymentTypeItems = ['Überweisung', 'Lastschrift', 'Kreditkarte', 'PayPal', 'Bar', 'Sonstiges']
|
||||||
const files = useFiles()
|
const files = useFiles()
|
||||||
|
const hasActiveBankAssignmentIn = (allocations = []) => allocations.some((allocation) => {
|
||||||
|
if (allocation?.archived) return false
|
||||||
|
|
||||||
|
return Boolean(allocation?.bankstatement || allocation?.bs_id)
|
||||||
|
})
|
||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
// 1. Daten laden
|
// 1. Daten laden
|
||||||
@@ -65,6 +70,18 @@ const setup = async () => {
|
|||||||
accounts: normalizeIncomingInvoiceAccounts(invoiceData.accounts || [], invoiceData.date)
|
accounts: normalizeIncomingInvoiceAccounts(invoiceData.accounts || [], invoiceData.date)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode.value === "edit" && invoiceData.state === "Gebucht" && (invoiceData.archived || hasActiveBankAssignmentIn(invoiceData.statementallocations))) {
|
||||||
|
toast.add({
|
||||||
|
title: "Bearbeiten nicht möglich",
|
||||||
|
description: invoiceData.archived
|
||||||
|
? "Archivierte Eingangsbelege können nicht bearbeitet werden."
|
||||||
|
: "Der Eingangsbeleg ist bereits einer Bankbuchung zugewiesen.",
|
||||||
|
color: "error"
|
||||||
|
})
|
||||||
|
await navigateTo(`/incomingInvoices/show/${invoiceData.id}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Fallback Accounts
|
// Fallback Accounts
|
||||||
if(itemInfo.value.accounts.length === 0) {
|
if(itemInfo.value.accounts.length === 0) {
|
||||||
itemInfo.value.accounts.push(createIncomingInvoiceAccount({ depreciationStartDate: itemInfo.value.date || null }))
|
itemInfo.value.accounts.push(createIncomingInvoiceAccount({ depreciationStartDate: itemInfo.value.date || null }))
|
||||||
@@ -150,16 +167,19 @@ const bankBookingDateLabel = computed(() => {
|
|||||||
|
|
||||||
return bankBookingDates.value.map(formatDate).join(", ")
|
return bankBookingDates.value.map(formatDate).join(", ")
|
||||||
})
|
})
|
||||||
const hasActiveBankAssignment = computed(() => (itemInfo.value.statementallocations || []).some((allocation) => {
|
const hasActiveBankAssignment = computed(() => hasActiveBankAssignmentIn(itemInfo.value.statementallocations))
|
||||||
if (allocation?.archived) return false
|
const isBookedIncomingInvoice = computed(() => itemInfo.value.state === "Gebucht")
|
||||||
|
const canEditIncomingInvoice = computed(() => (
|
||||||
return Boolean(allocation?.bankstatement || allocation?.bs_id)
|
mode.value === "show"
|
||||||
}))
|
&& isBookedIncomingInvoice.value
|
||||||
|
&& !itemInfo.value.archived
|
||||||
|
&& !hasActiveBankAssignment.value
|
||||||
|
))
|
||||||
const canArchiveIncomingInvoice = computed(() => {
|
const canArchiveIncomingInvoice = computed(() => {
|
||||||
if (itemInfo.value.archived) return false
|
if (itemInfo.value.archived) return false
|
||||||
if (mode.value !== "show") return true
|
if (isBookedIncomingInvoice.value) return !hasActiveBankAssignment.value
|
||||||
|
|
||||||
return itemInfo.value.state === "Gebucht" && !hasActiveBankAssignment.value
|
return mode.value !== "show"
|
||||||
})
|
})
|
||||||
const vendorName = computed(() => vendors.value.find((vendor) => vendor.id === itemInfo.value.vendor)?.name || "-")
|
const vendorName = computed(() => vendors.value.find((vendor) => vendor.id === itemInfo.value.vendor)?.name || "-")
|
||||||
const eInvoiceValidation = computed(() => itemInfo.value.eInvoiceValidation || null)
|
const eInvoiceValidation = computed(() => itemInfo.value.eInvoiceValidation || null)
|
||||||
@@ -259,7 +279,9 @@ const applyTotalTaxOverride = () => {
|
|||||||
|
|
||||||
// --- Saving ---
|
// --- Saving ---
|
||||||
const updateIncomingInvoice = async (setBooked = false) => {
|
const updateIncomingInvoice = async (setBooked = false) => {
|
||||||
if (setBooked && hasBlockingIncomingInvoiceErrors.value) {
|
const keepBooked = setBooked || isBookedIncomingInvoice.value
|
||||||
|
|
||||||
|
if (keepBooked && hasBlockingIncomingInvoiceErrors.value) {
|
||||||
toast.add({
|
toast.add({
|
||||||
title: "Buchen nicht möglich",
|
title: "Buchen nicht möglich",
|
||||||
description: "Bitte beheben Sie zuerst die rot markierten Pflichtfehler.",
|
description: "Bitte beheben Sie zuerst die rot markierten Pflichtfehler.",
|
||||||
@@ -271,7 +293,7 @@ const updateIncomingInvoice = async (setBooked = false) => {
|
|||||||
let item = { ...itemInfo.value }
|
let item = { ...itemInfo.value }
|
||||||
item.accounts = (item.accounts || []).map((account) => ensureDepreciationDefaults({ ...account }, item.date))
|
item.accounts = (item.accounts || []).map((account) => ensureDepreciationDefaults({ ...account }, item.date))
|
||||||
delete item.files
|
delete item.files
|
||||||
item.state = setBooked ? "Gebucht" : "Entwurf"
|
item.state = keepBooked ? "Gebucht" : "Entwurf"
|
||||||
|
|
||||||
await useEntities('incominginvoices').update(itemInfo.value.id, item, !setBooked)
|
await useEntities('incominginvoices').update(itemInfo.value.id, item, !setBooked)
|
||||||
|
|
||||||
@@ -332,6 +354,14 @@ const hasBlockingIncomingInvoiceErrors = computed(() => blockingIncomingInvoiceE
|
|||||||
</h1>
|
</h1>
|
||||||
</template>
|
</template>
|
||||||
<template #right>
|
<template #right>
|
||||||
|
<UButton
|
||||||
|
v-if="canEditIncomingInvoice"
|
||||||
|
icon="i-heroicons-pencil-square"
|
||||||
|
variant="outline"
|
||||||
|
@click="navigateTo(`/incomingInvoices/edit/${route.params.id}`)"
|
||||||
|
>
|
||||||
|
Bearbeiten
|
||||||
|
</UButton>
|
||||||
<ArchiveButton
|
<ArchiveButton
|
||||||
v-if="canArchiveIncomingInvoice"
|
v-if="canArchiveIncomingInvoice"
|
||||||
color="error"
|
color="error"
|
||||||
@@ -343,7 +373,7 @@ const hasBlockingIncomingInvoiceErrors = computed(() => blockingIncomingInvoiceE
|
|||||||
Speichern
|
Speichern
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="mode !== 'show'"
|
v-if="mode !== 'show' && !isBookedIncomingInvoice"
|
||||||
@click="updateIncomingInvoice(true)"
|
@click="updateIncomingInvoice(true)"
|
||||||
:disabled="hasBlockingIncomingInvoiceErrors"
|
:disabled="hasBlockingIncomingInvoiceErrors"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user