From bb61caed6d6e73eb3f28142b6bfe1f3e7cc5c893 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Fri, 24 Apr 2026 23:03:23 +0200 Subject: [PATCH] =?UTF-8?q?Unterkostenstellen=20in=20der=20Kostenstellenau?= =?UTF-8?q?swertung=20korrekt=20aufl=C3=B6sen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/components/costcentreDisplay.vue | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/components/costcentreDisplay.vue b/frontend/components/costcentreDisplay.vue index 0b226e8..be146fc 100644 --- a/frontend/components/costcentreDisplay.vue +++ b/frontend/components/costcentreDisplay.vue @@ -16,6 +16,14 @@ const selectedMonth = ref("all") const currency = (value) => `${Number(value || 0).toFixed(2).replace(".", ",")} EUR` +const getCostCentreId = (value) => { + if (!value) { + return null + } + + return typeof value === "object" ? value.id : value +} + const costCentreMap = computed(() => { return new Map(costcentres.value.map((costcentre) => [costcentre.id, costcentre])) }) @@ -30,15 +38,17 @@ const relevantCostCentreIds = computed(() => { const childrenByParent = new Map() costcentres.value.forEach((costcentre) => { - if (!costcentre.parentCostcentre) { + const parentId = getCostCentreId(costcentre.parentCostcentre) + + if (!parentId) { return } - if (!childrenByParent.has(costcentre.parentCostcentre)) { - childrenByParent.set(costcentre.parentCostcentre, []) + if (!childrenByParent.has(parentId)) { + childrenByParent.set(parentId, []) } - childrenByParent.get(costcentre.parentCostcentre).push(costcentre.id) + childrenByParent.get(parentId).push(costcentre.id) }) const collectedIds = new Set([rootId]) @@ -107,7 +117,7 @@ const reportRows = computed(() => { const amountNet = Number(account.amountNet || 0) const amountTax = Number(account.amountTax || 0) const amountGross = Number(account.amountGross || amountNet + amountTax || 0) - const accountCostCentre = costCentreMap.value.get(account.costCentre) + const accountCostCentre = costCentreMap.value.get(getCostCentreId(account.costCentre)) return { id: `${invoice.id}-${index}`,