Serienrechnungen ausführung sowie Anwahl und liste

This commit is contained in:
2026-03-04 19:54:12 +01:00
parent cf0fb724a2
commit 9cef3964e9

View File

@@ -158,13 +158,24 @@
<UDivider label="Vorlagen auswählen" />
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3">
<UInput
v-model="modalSearch"
icon="i-heroicons-magnifying-glass"
placeholder="Kunde oder Vertrag suchen..."
class="w-full sm:w-64"
size="sm"
/>
<div class="flex flex-col sm:flex-row gap-2 w-full sm:w-auto">
<UInput
v-model="modalSearch"
icon="i-heroicons-magnifying-glass"
placeholder="Kunde oder Vertrag suchen..."
class="w-full sm:w-64"
size="sm"
/>
<USelectMenu
v-model="selectedExecutionIntervall"
:options="executionIntervallOptions"
option-attribute="label"
value-attribute="value"
size="sm"
class="w-full sm:w-52"
/>
</div>
<div class="flex items-center gap-2">
<span class="text-xs text-gray-500 hidden sm:inline">
@@ -201,11 +212,14 @@
{{displayCurrency(calculateDocSum(row))}}
</template>
<template #serialConfig.intervall-data="{row}">
{{ row.serialConfig?.intervall }}
{{ getIntervallLabel(row.serialConfig?.intervall) }}
</template>
<template #contract-data="{row}">
{{row.contract?.contractNumber}} - {{row.contract?.name}}
</template>
<template #plant-data="{row}">
{{ row.plant?.name || "-" }}
</template>
</UTable>
</div>
@@ -287,6 +301,7 @@ const executionDate = ref(dayjs().format('YYYY-MM-DD'))
const selectedExecutionRows = ref([])
const isExecuting = ref(false)
const modalSearch = ref("") // NEU: Suchstring für das Modal
const selectedExecutionIntervall = ref("all")
// --- SerialExecutions State ---
const showExecutionsSlideover = ref(false)
@@ -295,7 +310,7 @@ const executionsLoading = ref(false)
const finishingId = ref(null)
const setupPage = async () => {
items.value = await useEntities("createddocuments").select("*, customer(id,name), contract(id,name, contractNumber)","documentDate",undefined,true)
items.value = await useEntities("createddocuments").select("*, customer(id,name), contract(id,name, contractNumber), plant(id,name)","documentDate",undefined,true)
await fetchExecutions()
}
@@ -390,30 +405,78 @@ const filteredRows = computed(() => {
return useSearch(searchString.value, temp.slice().reverse())
})
// Basis Liste für das Modal (nur Aktive)
// Basis Liste für das Modal (nur aktive und nicht archivierte Vorlagen)
const activeTemplates = computed(() => {
return items.value
.filter(i => i.type === "serialInvoices" && !!i.serialConfig?.active)
.filter(i => i.type === "serialInvoices" && !!i.serialConfig?.active && !i.archived)
.map(i => ({...i}))
})
const intervallLabelMap = {
"wöchentlich": "Wöchentlich",
"2 - wöchentlich": "Alle 2 Wochen",
"monatlich": "Monatlich",
"vierteljährlich": "Quartalsweise",
"halbjährlich": "Halbjährlich",
"jährlich": "Jährlich"
}
const getIntervallLabel = (intervall) => {
if (!intervall) return "-"
return intervallLabelMap[intervall] || intervall
}
const executionIntervallOptions = computed(() => {
const availableIntervals = [...new Set(
activeTemplates.value
.map(row => row.serialConfig?.intervall)
.filter(Boolean)
)]
const sorted = availableIntervals.sort((a, b) =>
getIntervallLabel(a).localeCompare(getIntervallLabel(b), 'de')
)
return [
{label: 'Alle Intervalle', value: 'all'},
...sorted.map(intervall => ({
label: getIntervallLabel(intervall),
value: intervall
}))
]
})
// NEU: Gefilterte Liste für das Modal basierend auf der Suche
const filteredExecutionList = computed(() => {
if (!modalSearch.value) return activeTemplates.value
let filtered = [...activeTemplates.value]
if (selectedExecutionIntervall.value !== 'all') {
filtered = filtered.filter(
row => row.serialConfig?.intervall === selectedExecutionIntervall.value
)
}
if (!modalSearch.value) return filtered
const term = modalSearch.value.toLowerCase()
return activeTemplates.value.filter(row => {
return filtered.filter(row => {
const customerName = row.customer?.name?.toLowerCase() || ""
const contractNum = row.contract?.contractNumber?.toLowerCase() || ""
const contractName = row.contract?.name?.toLowerCase() || ""
const plantName = row.plant?.name?.toLowerCase() || ""
return customerName.includes(term) ||
contractNum.includes(term) ||
contractName.includes(term)
contractName.includes(term) ||
plantName.includes(term)
})
})
watch(selectedExecutionIntervall, () => {
selectedExecutionRows.value = [...filteredExecutionList.value]
})
// NEU: Alle auswählen (nur die aktuell sichtbaren/gefilterten)
const selectAllTemplates = () => {
// WICHTIG: Überschreibt nicht bestehende Auswahl, sondern fügt hinzu oder ersetzt.
@@ -469,6 +532,7 @@ const templateColumns = [
const executionColumns = [
{key: 'partner', label: "Kunde"},
{key: 'plant', label: "Objekt"},
{key: 'contract', label: "Vertrag"},
{key: 'serialConfig.intervall', label: "Intervall"},
{key: "amount", label: "Betrag"},
@@ -509,8 +573,9 @@ const calculateDocSum = (row) => {
const openExecutionModal = () => {
executionDate.value = dayjs().format('YYYY-MM-DD')
selectedExecutionRows.value = []
modalSearch.value = "" // Reset Search
selectedExecutionIntervall.value = "all"
selectedExecutionRows.value = []
showExecutionModal.value = true
}
@@ -557,4 +622,4 @@ const executeSerialInvoices = async () => {
}
setupPage()
</script>
</script>