From ea31a15eac82e9e7bbd9908ab22b49dd645f1e22 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 25 Oct 2026 12:47:34 +0100 Subject: [PATCH] fix(accounting): Kostenstellen-Auswertung wertet Einnahmen positiv und Ausgaben negativ Co-Authored-By: Claude Opus 5.5 --- frontend/components/costcentreDisplay.vue | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/components/costcentreDisplay.vue b/frontend/components/costcentreDisplay.vue index 138dc130..4ef32c54 100644 --- a/frontend/components/costcentreDisplay.vue +++ b/frontend/components/costcentreDisplay.vue @@ -119,10 +119,13 @@ const reportRows = computed(() => { relevantCostCentreIds.value.has(account.costCentre) ) + // Expenses reduce the cost centre result; incoming documents marked as income increase it. + const sign = invoice.expense === false ? 1 : -1 + return matchingAccounts.map((account, index) => { - const amountNet = Number(account.amountNet || 0) - const amountTax = Number(account.amountTax || 0) - const amountGross = Number(account.amountGross || amountNet + amountTax || 0) + const amountNet = Number(account.amountNet || 0) * sign + const amountTax = Number(account.amountTax || 0) * sign + const amountGross = Number(account.amountGross || Number(account.amountNet || 0) + Number(account.amountTax || 0) || 0) * sign const accountCostCentre = costCentreMap.value.get(getCostCentreId(account.costCentre)) return { @@ -196,8 +199,7 @@ const reportRows = computed(() => { const centre = costCentreMap.value.get(getCostCentreId(allocation.costcentre)) const account = accounts.value.find(account => account.id === (allocation.account?.id || allocation.account)) || allocation.ownaccount const amounts = getBankAllocationAmounts(allocation) - // As for incoming documents, expenses are positive and refunds negative. - const sign = amounts.kind === "input" || (amounts.kind === "none" && amounts.amountGross < 0) ? -1 : 1 + // The bank amount is already signed: outflows (expenses) negative, inflows positive. return [{ id: `bank-${allocation.id}`, sourceLabel: "Bankbuchung", @@ -209,9 +211,9 @@ const reportRows = computed(() => { accountLabel: `${account?.number || ""} ${account?.label || account?.name || ""}`.trim() || "-", costCentreName: centre ? `${centre.number} - ${centre.name}` : "-", description: allocation.description || statement.text || "-", - amountNet: amounts.amountNet * sign, - amountTax: amounts.amountTax * sign, - amountGross: amounts.amountGross * sign, + amountNet: amounts.amountNet, + amountTax: amounts.amountTax, + amountGross: amounts.amountGross, }] }) return [...incomingRows, ...outgoingRows, ...bankRows]