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 paymentTypeItems = ['Überweisung', 'Lastschrift', 'Kreditkarte', 'PayPal', 'Bar', 'Sonstiges']
|
||||
const files = useFiles()
|
||||
const hasActiveBankAssignmentIn = (allocations = []) => allocations.some((allocation) => {
|
||||
if (allocation?.archived) return false
|
||||
|
||||
return Boolean(allocation?.bankstatement || allocation?.bs_id)
|
||||
})
|
||||
|
||||
const setup = async () => {
|
||||
// 1. Daten laden
|
||||
@@ -65,6 +70,18 @@ const setup = async () => {
|
||||
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
|
||||
if(itemInfo.value.accounts.length === 0) {
|
||||
itemInfo.value.accounts.push(createIncomingInvoiceAccount({ depreciationStartDate: itemInfo.value.date || null }))
|
||||
@@ -150,16 +167,19 @@ const bankBookingDateLabel = computed(() => {
|
||||
|
||||
return bankBookingDates.value.map(formatDate).join(", ")
|
||||
})
|
||||
const hasActiveBankAssignment = computed(() => (itemInfo.value.statementallocations || []).some((allocation) => {
|
||||
if (allocation?.archived) return false
|
||||
|
||||
return Boolean(allocation?.bankstatement || allocation?.bs_id)
|
||||
}))
|
||||
const hasActiveBankAssignment = computed(() => hasActiveBankAssignmentIn(itemInfo.value.statementallocations))
|
||||
const isBookedIncomingInvoice = computed(() => itemInfo.value.state === "Gebucht")
|
||||
const canEditIncomingInvoice = computed(() => (
|
||||
mode.value === "show"
|
||||
&& isBookedIncomingInvoice.value
|
||||
&& !itemInfo.value.archived
|
||||
&& !hasActiveBankAssignment.value
|
||||
))
|
||||
const canArchiveIncomingInvoice = computed(() => {
|
||||
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 eInvoiceValidation = computed(() => itemInfo.value.eInvoiceValidation || null)
|
||||
@@ -259,7 +279,9 @@ const applyTotalTaxOverride = () => {
|
||||
|
||||
// --- Saving ---
|
||||
const updateIncomingInvoice = async (setBooked = false) => {
|
||||
if (setBooked && hasBlockingIncomingInvoiceErrors.value) {
|
||||
const keepBooked = setBooked || isBookedIncomingInvoice.value
|
||||
|
||||
if (keepBooked && hasBlockingIncomingInvoiceErrors.value) {
|
||||
toast.add({
|
||||
title: "Buchen nicht möglich",
|
||||
description: "Bitte beheben Sie zuerst die rot markierten Pflichtfehler.",
|
||||
@@ -271,7 +293,7 @@ const updateIncomingInvoice = async (setBooked = false) => {
|
||||
let item = { ...itemInfo.value }
|
||||
item.accounts = (item.accounts || []).map((account) => ensureDepreciationDefaults({ ...account }, item.date))
|
||||
delete item.files
|
||||
item.state = setBooked ? "Gebucht" : "Entwurf"
|
||||
item.state = keepBooked ? "Gebucht" : "Entwurf"
|
||||
|
||||
await useEntities('incominginvoices').update(itemInfo.value.id, item, !setBooked)
|
||||
|
||||
@@ -332,6 +354,14 @@ const hasBlockingIncomingInvoiceErrors = computed(() => blockingIncomingInvoiceE
|
||||
</h1>
|
||||
</template>
|
||||
<template #right>
|
||||
<UButton
|
||||
v-if="canEditIncomingInvoice"
|
||||
icon="i-heroicons-pencil-square"
|
||||
variant="outline"
|
||||
@click="navigateTo(`/incomingInvoices/edit/${route.params.id}`)"
|
||||
>
|
||||
Bearbeiten
|
||||
</UButton>
|
||||
<ArchiveButton
|
||||
v-if="canArchiveIncomingInvoice"
|
||||
color="error"
|
||||
@@ -343,7 +373,7 @@ const hasBlockingIncomingInvoiceErrors = computed(() => blockingIncomingInvoiceE
|
||||
Speichern
|
||||
</UButton>
|
||||
<UButton
|
||||
v-if="mode !== 'show'"
|
||||
v-if="mode !== 'show' && !isBookedIncomingInvoice"
|
||||
@click="updateIncomingInvoice(true)"
|
||||
:disabled="hasBlockingIncomingInvoiceErrors"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user