Ausgangsbelege um Kostenstellenzuordnung erweitern
This commit is contained in:
@@ -54,6 +54,7 @@ const optionsToImport = ref({
|
||||
contactPerson: true,
|
||||
plant: true,
|
||||
project:true,
|
||||
costcentre: true,
|
||||
description: true,
|
||||
startText: false,
|
||||
rows: true,
|
||||
@@ -74,6 +75,7 @@ const mappings = ref({
|
||||
contactPerson: "Ansprechpartner Mitarbeiter",
|
||||
plant: "Objekt",
|
||||
project: "Projekt",
|
||||
costcentre: "Kostenstelle",
|
||||
description: "Beschreibung",
|
||||
startText: "Einleitung",
|
||||
rows: "Positionen",
|
||||
|
||||
@@ -10,6 +10,7 @@ const props = defineProps({
|
||||
|
||||
const loading = ref(true)
|
||||
const incomingInvoices = ref([])
|
||||
const createddocuments = ref([])
|
||||
const costcentres = ref([])
|
||||
const selectedYear = ref(String(dayjs().year()))
|
||||
const selectedMonth = ref("all")
|
||||
@@ -98,7 +99,7 @@ const monthItems = [
|
||||
]
|
||||
|
||||
const reportRows = computed(() => {
|
||||
return incomingInvoices.value.flatMap((invoice) => {
|
||||
const incomingRows = incomingInvoices.value.flatMap((invoice) => {
|
||||
const invoiceDate = invoice.date ? dayjs(invoice.date) : null
|
||||
|
||||
if (invoiceDate && invoiceDate.year().toString() !== selectedYear.value) {
|
||||
@@ -120,7 +121,8 @@ const reportRows = computed(() => {
|
||||
const accountCostCentre = costCentreMap.value.get(getCostCentreId(account.costCentre))
|
||||
|
||||
return {
|
||||
id: `${invoice.id}-${index}`,
|
||||
id: `incoming-${invoice.id}-${index}`,
|
||||
sourceLabel: "Eingangsbeleg",
|
||||
invoiceId: invoice.id,
|
||||
reference: invoice.reference || "-",
|
||||
date: invoice.date,
|
||||
@@ -135,6 +137,53 @@ const reportRows = computed(() => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const outgoingRows = createddocuments.value.flatMap((document) => {
|
||||
const documentDate = document.documentDate ? dayjs(document.documentDate) : null
|
||||
|
||||
if (documentDate && documentDate.year().toString() !== selectedYear.value) {
|
||||
return []
|
||||
}
|
||||
|
||||
if (documentDate && selectedMonth.value !== "all" && documentDate.month() + 1 !== Number(selectedMonth.value)) {
|
||||
return []
|
||||
}
|
||||
|
||||
return (document.rows || [])
|
||||
.filter((row) => !["pagebreak", "title", "text"].includes(row.mode))
|
||||
.map((row, index) => {
|
||||
const costCentreId = getCostCentreId(row.costCentre || row.costcentre || document.costcentre)
|
||||
|
||||
if (!relevantCostCentreIds.value.has(costCentreId)) {
|
||||
return null
|
||||
}
|
||||
|
||||
const amountNet = Number((Number(row.quantity || 0) * Number(row.price || 0) * (1 - Number(row.discountPercent || 0) / 100)).toFixed(2))
|
||||
const taxPercent = Number(row.taxPercent || 0)
|
||||
const amountTax = Number((amountNet * (taxPercent / 100)).toFixed(2))
|
||||
const amountGross = Number((amountNet + amountTax).toFixed(2))
|
||||
const accountCostCentre = costCentreMap.value.get(costCentreId)
|
||||
|
||||
return {
|
||||
id: `outgoing-${document.id}-${index}`,
|
||||
sourceLabel: "Ausgangsbeleg",
|
||||
invoiceId: document.id,
|
||||
reference: document.documentNumber || document.title || "-",
|
||||
date: document.documentDate,
|
||||
state: document.state || "-",
|
||||
vendorName: document.customer?.name || "-",
|
||||
accountLabel: "Umsatz",
|
||||
costCentreName: accountCostCentre ? `${accountCostCentre.number} - ${accountCostCentre.name}` : "-",
|
||||
description: row.text || row.description || document.description || "-",
|
||||
amountNet,
|
||||
amountTax,
|
||||
amountGross
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
})
|
||||
|
||||
return [...incomingRows, ...outgoingRows]
|
||||
})
|
||||
|
||||
const totals = computed(() => {
|
||||
@@ -147,9 +196,10 @@ const totals = computed(() => {
|
||||
})
|
||||
|
||||
const columns = [
|
||||
{ accessorKey: "sourceLabel", header: "Art" },
|
||||
{ accessorKey: "reference", header: "Beleg" },
|
||||
{ accessorKey: "date", header: "Datum" },
|
||||
{ accessorKey: "vendorName", header: "Lieferant" },
|
||||
{ accessorKey: "vendorName", header: "Kontakt" },
|
||||
{ accessorKey: "accountLabel", header: "Konto" },
|
||||
{ accessorKey: "costCentreName", header: "Kostenstelle" },
|
||||
{ accessorKey: "description", header: "Beschreibung" },
|
||||
@@ -163,10 +213,16 @@ const setupPage = async () => {
|
||||
|
||||
costcentres.value = await useEntities("costcentres").select("*", null, false, true)
|
||||
const invoices = await useEntities("incominginvoices").select("*, vendor(id,name)")
|
||||
const documents = await useEntities("createddocuments").select("*, customer(id,name)")
|
||||
|
||||
incomingInvoices.value = invoices.filter((invoice) =>
|
||||
(invoice.accounts || []).some((account) => relevantCostCentreIds.value.has(account.costCentre))
|
||||
)
|
||||
createddocuments.value = documents.filter((document) =>
|
||||
["invoices", "advanceInvoices", "cancellationInvoices"].includes(document.type)
|
||||
&& document.state === "Gebucht"
|
||||
&& (document.rows || []).some((row) => relevantCostCentreIds.value.has(getCostCentreId(row.costCentre || row.costcentre || document.costcentre)))
|
||||
)
|
||||
|
||||
const firstYear = yearItems.value[0]?.value
|
||||
if (firstYear && !yearItems.value.some((item) => item.value === selectedYear.value)) {
|
||||
@@ -264,7 +320,7 @@ setupPage()
|
||||
<div class="text-right font-medium tabular-nums">{{ currency(row.original.amountGross) }}</div>
|
||||
</template>
|
||||
<template #empty>
|
||||
<TableEmptyState label="Keine Eingangsbelege mit dieser Kostenstelle oder ihren Unterkostenstellen gefunden" />
|
||||
<TableEmptyState label="Keine Belege mit dieser Kostenstelle oder ihren Unterkostenstellen gefunden" />
|
||||
</template>
|
||||
</UTable>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user