Fix BWA Calc

This commit is contained in:
2026-04-08 18:52:16 +02:00
parent f125617af0
commit 02b5769049
5 changed files with 53 additions and 38 deletions

View File

@@ -10,7 +10,6 @@ import {
getIncomingInvoiceImmediateExpenseNet,
isDepreciationBookingMode,
normalizeIncomingInvoiceAccount,
getStatementAllocationDepreciationRow,
getStatementAllocationImmediateExpenseAmount
} from "~/composables/useDepreciation"
@@ -156,7 +155,13 @@ const filteredStatementAllocations = computed(() => {
})
const filteredAccountStatementAllocations = computed(() => {
return filteredStatementAllocations.value.filter((allocation) => allocation.account !== null && allocation.account !== undefined)
return filteredStatementAllocations.value.filter((allocation) => {
if (allocation.account === null || allocation.account === undefined) {
return false
}
return getStatementAllocationImmediateExpenseAmount(allocation) > 0
})
})
const selectedPeriodBounds = computed(() => {
@@ -181,7 +186,7 @@ const expenseNetTotal = computed(() => {
}, 0)
const directAccountExpenses = filteredAccountStatementAllocations.value.reduce((sum, allocation) => {
return sum + getStatementAllocationImmediateExpenseAmount(allocation)
return sum + Number(getStatementAllocationImmediateExpenseAmount(allocation) || 0)
}, 0)
const depreciations = depreciationTotal.value
@@ -193,7 +198,7 @@ const expenseGrossTotal = computed(() => {
const invoiceExpenses = filteredIncomingInvoices.value.reduce((sum, invoice) => sum + getIncomingInvoiceImmediateExpenseGross(invoice), 0)
const directAccountExpenses = filteredAccountStatementAllocations.value.reduce((sum, allocation) => {
return sum + getStatementAllocationImmediateExpenseAmount(allocation)
return sum + Number(getStatementAllocationImmediateExpenseAmount(allocation) || 0)
}, 0)
const depreciations = depreciationTotal.value
@@ -249,13 +254,9 @@ const expenseDocumentCount = computed(() => {
const depreciationRows = computed(() => {
const invoiceRows = filteredIncomingInvoices.value.flatMap((invoice) => getIncomingInvoiceDepreciationRows(invoice, selectedPeriodBounds.value.start, selectedPeriodBounds.value.end))
const allocationRows = filteredStatementAllocations.value
.map((allocation) => getStatementAllocationDepreciationRow(allocation, selectedPeriodBounds.value.start, selectedPeriodBounds.value.end))
.filter(Boolean)
const grouped = new Map<string, any>()
;[...invoiceRows, ...allocationRows].forEach((row: any) => {
;invoiceRows.forEach((row: any) => {
const key = row.group || `${row.mode}:${row.label}`
const current = grouped.get(key) || {
id: key,