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

@@ -124,6 +124,16 @@ const invoiceDeliveryNotes = () => {
router.push(`/createDocument/edit?type=invoices&loadMode=deliveryNotes&linkedDocuments=[${props.item.createddocuments.filter(i => deliveryNoteLikeDocumentTypes.includes(i.type)).map(i => i.id)}]`)
}
const createAdvanceInvoice = () => {
if (props.topLevelType !== 'projects' || !props.item.id) return
const query = new URLSearchParams(props.queryStringData)
query.set('type', 'advanceInvoices')
query.set('loadMode', 'advanceInvoice')
query.set('project', props.item.id)
router.push(`/createDocument/edit?${query.toString()}`)
}
const showFinalInvoiceConfig = ref(false)
const referenceDocument = ref(null)
const advanceInvoicesToAdd = ref([])
@@ -169,6 +179,13 @@ const selectItem = (item) => {
>
Dokument aus Vorlage
</UButton>
<UButton
v-if="props.topLevelType === 'projects'"
icon="i-heroicons-plus"
@click="createAdvanceInvoice"
>
Abschlagsrechnung
</UButton>
<UButton
@click="showFinalInvoiceConfig = true"
v-if="props.topLevelType === 'projects'"

View File

@@ -18,9 +18,9 @@ const props = defineProps({
const emit = defineEmits(["updateNeeded","returnData"])
const documentTypeToUse = ref(props.type)
const documentTypeToUse = ref(props.type === 'advanceInvoices' ? null : props.type)
const documentTypeItems = computed(() => {
return Object.keys(dataStore.documentTypesForCreation).map((key) => ({
return Object.keys(dataStore.documentTypesForCreation).filter(key => key !== 'advanceInvoices').map((key) => ({
...dataStore.documentTypesForCreation[key],
key
}))
@@ -83,6 +83,8 @@ const mappings = ref({
})
const startImport = () => {
if (!selectedDocumentType.value) return
router.push(`/createDocument/edit/?createddocument=${props.id}&type=${documentTypeToUse.value}&optionsToImport=${encodeURIComponent(JSON.stringify(optionsToImport.value))}`)
modal.close()
}
@@ -147,7 +149,7 @@ const startImport = () => {
<UButton color="neutral" variant="ghost" @click="modal.close()">
Abbrechen
</UButton>
<UButton @click="startImport">
<UButton :disabled="!selectedDocumentType" @click="startImport">
Kopieren
</UButton>
</div>

View File

@@ -10,10 +10,11 @@ const props = defineProps({
})
const documentTypes = computed(() => Object.entries(dataStore.documentTypesForCreation || {})
.filter(([key]) => key !== 'serialInvoices')
.filter(([key]) => !['serialInvoices', 'advanceInvoices'].includes(key))
.map(([key, value]) => ({ key, ...value })))
const visibleTemplates = computed(() => templates.value.filter(template => {
return !selectedType.value || template.documentType === selectedType.value
return template.documentType !== 'advanceInvoices'
&& (!selectedType.value || template.documentType === selectedType.value)
}))
const loadTemplates = async () => {
@@ -25,6 +26,8 @@ const loadTemplates = async () => {
}
const selectTemplate = (template) => {
if (template.documentType === 'advanceInvoices') return
const query = new URLSearchParams(props.queryStringData)
query.set('templateId', template.id)
query.set('type', template.documentType)

View File

@@ -9,10 +9,12 @@ const props = defineProps({
})
const documentTypes = computed(() => Object.entries(dataStore.documentTypesForCreation || {})
.filter(([key]) => key !== 'serialInvoices')
.filter(([key]) => !['serialInvoices', 'advanceInvoices'].includes(key))
.map(([key, value]) => ({ key, ...value })))
const createDocument = (type) => {
if (!documentTypes.value.some(documentType => documentType.key === type)) return
const query = new URLSearchParams(props.queryStringData)
query.set('type', type)
if (props.projectId) query.set('project', props.projectId)