fix(documents): restrict advance invoice creation to projects
All checks were successful
Build and Release FEDEO / verify (push) Successful in 1m8s
Build and Release FEDEO / build-and-release (push) Successful in 6m24s

This commit is contained in:
2026-10-15 13:05:06 +02:00
parent 6eea3c0687
commit 5dc9e686fc
7 changed files with 200 additions and 11 deletions

View File

@@ -104,10 +104,36 @@ const bankaccounts = ref([])
const texttemplates = ref([])
const units = ref([])
const tenantUsers = ref([])
const documentTypeItems = computed(() => Object.keys(dataStore.documentTypesForCreation).map((key) => ({
label: dataStore.documentTypesForCreation[key].labelSingle,
type: key
})))
const originalDocumentType = ref(null)
const canUseAdvanceInvoice = computed(() => originalDocumentType.value === 'advanceInvoices' || (
route.query.type === 'advanceInvoices'
&& route.query.loadMode === 'advanceInvoice'
&& Number.isSafeInteger(Number(route.query.project))
&& Number(route.query.project) > 0
&& !route.params.id
&& !route.query.createddocument
&& !route.query.optionsToImport
&& !route.query.linkedDocuments
&& !route.query.templateId
&& !isTemplateMode.value
))
const documentTypeItems = computed(() => Object.keys(dataStore.documentTypesForCreation)
.filter(key => key !== 'advanceInvoices' || canUseAdvanceInvoice.value)
.map((key) => ({
label: dataStore.documentTypesForCreation[key].labelSingle,
type: key
})))
const validateAdvanceInvoiceCreation = () => {
if (itemInfo.value.type !== 'advanceInvoices' || isTemplateMode.value) return true
if (canUseAdvanceInvoice.value && (route.params.id || normalizeEntityId(itemInfo.value.project))) return true
toast.add({
title: 'Abschlagsrechnung nur im Projekt erstellen',
description: 'Bitte den Button „Abschlagsrechnung“ innerhalb eines Projekts verwenden.',
color: 'error'
})
return false
}
const taxTypeItems = [
{ key: 'Standard', label: 'Standard' },
{ key: '13b UStG', label: '13b UStG' },
@@ -391,6 +417,7 @@ const setupPage = async () => {
if (route.params.id) {
console.log(route.params)
itemInfo.value = await useEntities("createddocuments").selectSingle(route.params.id,'',false)
originalDocumentType.value = itemInfo.value.type
itemInfo.value.rows = normalizeCreatedDocumentRows(itemInfo.value.rows)
itemInfo.value.taxType = normalizeTaxTypeValue(itemInfo.value.taxType)
await setContactPersonData()
@@ -699,6 +726,10 @@ const setupPage = async () => {
itemInfo.value.rows = normalizeCreatedDocumentRows(itemInfo.value.rows)
if (!validateAdvanceInvoiceCreation()) {
await router.replace('/createDocument')
return
}
loaded.value = true
}
@@ -1817,6 +1848,7 @@ const saveDocumentTemplate = async () => {
}
const saveDocument = async (state, resetup = false) => {
if (!validateAdvanceInvoiceCreation()) return
itemInfo.value.state = state
normalizeCustomSurchargePercentage()