Pushed Serial Invoices

This commit is contained in:
2024-09-29 19:02:35 +02:00
parent 082573f6d9
commit 5d7714519a
3 changed files with 173 additions and 17 deletions

View File

@@ -100,6 +100,10 @@ const links = computed(() => {
label: "Ausgangsbelege",
to: "/createDocument",
icon: "i-heroicons-document-text"
},{
label: "Serienvorlagen",
to: "/createDocument/serialInvoice",
icon: "i-heroicons-document-text"
},{
label: "Eingangsbelege",
to: "/incomingInvoices",

View File

@@ -44,15 +44,25 @@ const itemInfo = ref({
contactPersonName: null,
contactTel: null,
contactEMail: null,
serialConfig: {
firstExecution: "",
intervall: "monatlich",
executionUntil: "",
active: true,
dateDirection: "Rückwirkend",
},
letterhead: null
})
const letterheads = ref([])
const createdDocuments = ref([])
const setupPage = async () => {
letterheads.value = (await useSupabaseSelect("letterheads","*")).filter(i => i.documentTypes.length === 0 || i.documentTypes.includes(itemInfo.value.type))
createdDocuments.value = (await useSupabaseSelect("createddocuments","*"))
if(route.params) {
if(route.params.id) itemInfo.value = dataStore.getCreatedDocumentById(Number(route.params.id))
@@ -292,6 +302,13 @@ const findDocumentErrors = computed(() => {
if(row.mode === "title" && !row.text) errors.push({message: `In Position ${row.pos} ist kein Titel hinterlegt ausgewählt`, type: "breaking"})
})
if(itemInfo.value.type === "serialInvoices") {
if(!itemInfo.value.serialConfig.intervall) errors.push({message: `Kein Intervall für die Ausführung festgelegt`, type: "breaking"})
if(!itemInfo.value.serialConfig.dateDirection) errors.push({message: `Kein Richtung für die Datierung festgelegt`, type: "breaking"})
if(!itemInfo.value.serialConfig.firstExecution) errors.push({message: `Kein Datum für die erste Ausführung festgelegt`, type: "breaking"})
if(!itemInfo.value.serialConfig.executionUntil) errors.push({message: `Kein Datum für die letzte Ausführung festgelegt`, type: "info"})
}
return errors
})
@@ -460,6 +477,37 @@ const setPosNumbers = () => {
})
}
const saveSerialInvoice = async () => {
let createData = {
type: itemInfo.value.type,
state: 'Erstellt',
customer: itemInfo.value.customer,
contact: itemInfo.value.contact,
address: itemInfo.value.address,
project: itemInfo.value.project,
paymentDays: itemInfo.value.paymentDays,
deliveryDateType: itemInfo.value.deliveryDateType,
createdBy: itemInfo.value.createdBy,
title: itemInfo.value.title,
description: itemInfo.value.description,
startText: itemInfo.value.startText,
endText: itemInfo.value.endText,
rows: itemInfo.value.rows,
contactPerson: itemInfo.value.contactPerson,
serialConfig: itemInfo.value.serialConfig
}
let data = null
if(route.params.id) {
data = await dataStore.updateItem("createddocuments", {...createData, id: itemInfo.value.id})
} else {
data = await dataStore.createNewItem("createddocuments", createData)
}
await router.push(`/createDocument/edit/${data[0].id}`)
}
const saveDocument = async () => {
let createData = {
type: itemInfo.value.type,
@@ -482,7 +530,8 @@ const saveDocument = async () => {
startText: itemInfo.value.startText,
endText: itemInfo.value.endText,
rows: itemInfo.value.rows,
contactPerson: itemInfo.value.contactPerson
contactPerson: itemInfo.value.contactPerson,
linkedDocument: itemInfo.value.linkedDocument
}
let data = null
@@ -547,15 +596,24 @@ setupPage()
<UButton
icon="i-mdi-content-save"
@click="saveDocument"
v-if="itemInfo.type !== 'serialInvoices' "
:disabled="!itemInfo.customer"
>
Entwurf
</UButton>
<UButton
@click="closeDocument"
v-if="itemInfo.id"
v-if="itemInfo.id && itemInfo.type !== 'serialInvoices'"
>
Fertigstellen
</UButton>
<UButton
icon="i-mdi-content-save"
@click="saveSerialInvoice"
v-if="itemInfo.type === 'serialInvoices'"
>
Serienrechnung
</UButton>
</template>
</UDashboardNavbar>
@@ -586,6 +644,29 @@ setupPage()
<InputGroup>
<div class="w-1/3 mr-5">
<UFormGroup
v-if="itemInfo.linkedDocument"
label="Verknüpftes Dokument:"
>
<InputGroup class="w-full">
<USelectMenu
class="flex-auto"
:options="createdDocuments"
v-model="itemInfo.linkedDocument"
option-attribute="documentNumber"
value-attribute="id"
disabled
/>
<UButton
variant="outline"
color="rose"
v-if="itemInfo.linkedDocument"
icon="i-heroicons-x-mark"
@click="itemInfo.linkedDocument = null"
/>
</InputGroup>
</UFormGroup>
<UFormGroup
label="Dokumenttyp:"
>
@@ -781,6 +862,7 @@ setupPage()
<div class="w-2/3">
<UFormGroup
:label="itemInfo.documentNumberTitle + ':'"
v-if="itemInfo.type !== 'serialInvoices'"
>
<UInput
v-model="itemInfo.documentNumber"
@@ -793,6 +875,7 @@ setupPage()
<InputGroup class="w-full">
<UFormGroup
label="Datum:"
v-if="itemInfo.type !== 'serialInvoices'"
>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton
@@ -809,6 +892,7 @@ setupPage()
<UFormGroup
class="mt-3 w-80"
label="Lieferdatumsart:"
v-if="itemInfo.type !== 'serialInvoices'"
>
<USelectMenu
:options="['Lieferdatum'/*,'Lieferzeitraum'*/,'Leistungsdatum'/*,'Leistungszeitraum'*/,'Kein Lieferdatum anzeigen']"
@@ -820,6 +904,7 @@ setupPage()
</UFormGroup>
<UFormGroup
:label="itemInfo.deliveryDateType"
v-if="itemInfo.type !== 'serialInvoices'"
>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton
@@ -844,13 +929,6 @@ setupPage()
/>
</UFormGroup>
</InputGroup>
<UFormGroup
label="Ansprechpartner:"
>
@@ -936,6 +1014,82 @@ setupPage()
</div>
</InputGroup>
<div v-if="itemInfo.type === 'serialInvoices'" class="mb-5">
<UDivider class="mt-5 mb-3">
Einstellungen für die Serienrechnung
</UDivider>
<div class="flex flex-row">
<div class="w-1/3">
<UFormGroup
label="Datum erste Ausführung:"
>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton
icon="i-heroicons-calendar-days-20-solid"
:label="itemInfo.serialConfig.firstExecution ? dayjs(itemInfo.serialConfig.firstExecution).format('DD.MM.YYYY') : 'Datum auswählen'"
variant="outline"
/>
<template #panel="{ close }">
<LazyDatePicker v-model="itemInfo.serialConfig.firstExecution" @close="close" />
</template>
</UPopover>
</UFormGroup>
<UFormGroup
label="Datum letzte Ausführung:"
>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton
icon="i-heroicons-calendar-days-20-solid"
:label="itemInfo.serialConfig.executionUntil ? dayjs(itemInfo.serialConfig.executionUntil).format('DD.MM.YYYY') : 'Datum auswählen'"
variant="outline"
/>
<template #panel="{ close }">
<LazyDatePicker v-model="itemInfo.serialConfig.executionUntil" @close="close" />
</template>
</UPopover>
</UFormGroup>
<UCheckbox
v-model="itemInfo.serialConfig.active"
label="Aktiv"
class="mt-3"
/>
</div>
<div class="w-2/3">
<UFormGroup
label="Intervall:"
>
<USelectMenu
v-model="itemInfo.serialConfig.intervall"
:options="['wöchentlich','2 - wöchentlich', 'monatlich', 'vierteljährlich','halbjährlich', 'jährlich']"
/>
</UFormGroup>
<UFormGroup
label="Richtung:"
>
<USelectMenu
v-model="itemInfo.serialConfig.dateDirection"
:options="['Rückwirkend','Im Voraus']"
/>
</UFormGroup>
<UAlert
title="Anfangs- und Enddatum"
description="Für das Anfangs- und Enddatum werden jeweils der ersten und letzte Tag des ausgewählten Intervalls und der Richtung automatisch ausgewählt"
class="mt-5"
/>
</div>
</div>
</div>
<UDivider
class="my-3"
/>
@@ -969,7 +1123,7 @@ setupPage()
{{option.name}} - {{option.text}}
</template>
<template #label>
{{dataStore.texttemplates.find(i => i.text === itemInfo.startText && i.documentType === itemInfo.type) ? dataStore.texttemplates.find(i => i.text === itemInfo.startText && i.documentType === itemInfo.type).name : "Keine Vorlage ausgewählt oder Vorlage verändert"}}
{{dataStore.texttemplates.find(i => i.text === itemInfo.startText && (itemInfo.type === "serialInvoices" ? i.documentType === "invoices" : i.documentType === itemInfo.type)) ? dataStore.texttemplates.find(i => i.text === itemInfo.startText && (itemInfo.type === "serialInvoices" ? i.documentType === "invoices" : i.documentType === itemInfo.type)).name : "Keine Vorlage ausgewählt oder Vorlage verändert"}}
</template>
</USelectMenu>
</UFormGroup>
@@ -1305,7 +1459,7 @@ setupPage()
{{option.name}} - {{option.text}}
</template>
<template #label>
{{dataStore.texttemplates.find(i => i.text === itemInfo.endText) ? dataStore.texttemplates.find(i => i.text === itemInfo.endText).name : "Keine Vorlage ausgewählt oder Vorlage verändert"}}
{{dataStore.texttemplates.find(i => i.text === itemInfo.endText && (itemInfo.type === "serialInvoices" ? i.documentType === "invoices" : i.documentType === itemInfo.type)) ? dataStore.texttemplates.find(i => i.text === itemInfo.endText && (itemInfo.type === "serialInvoices" ? i.documentType === "invoices" : i.documentType === itemInfo.type)).name : "Keine Vorlage ausgewählt oder Vorlage verändert"}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -224,6 +224,9 @@ const templateTypes = [
}, {
key: "deliveryNotes",
label: "Lieferscheine"
}, {
key: "confirmationOrders",
label: "Auftragsbestätigungen"
}
]
const selectedTypes = ref(templateTypes)
@@ -237,12 +240,6 @@ const selectItem = (item) => {
} else if(item.state !== "Entwurf") {
router.push(`/createDocument/show/${item.id}`)
}
}
const displayCurrency = (value, currency = "€") => {
@@ -255,6 +252,7 @@ const showDrafts = ref(false)
const filteredRows = computed(() => {
let temp = items.value.filter(i => types.value.find(x => x.key === i.type))
temp = temp.filter(i => i.type !== "serialInvoices")
/*if(showDrafts.value === true) {
temp = temp.filter(i => i.state === "Entwurf")