KI-AGENT: BWA-Ausgaben nach Kontosaldo berechnen
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 23s
Build and Push Docker Images / build-frontend (push) Successful in 1m11s
Build and Push Docker Images / build-website (push) Successful in 23s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 1m20s

This commit is contained in:
2026-09-07 21:04:31 +02:00
parent 23d2dc0ca8
commit 252cbd496d
3 changed files with 41 additions and 14 deletions

View File

@@ -8,7 +8,7 @@ import {
getIncomingInvoiceDepreciationRows, getIncomingInvoiceDepreciationRows,
getIncomingInvoiceImmediateExpenseNet, getIncomingInvoiceImmediateExpenseNet,
getStatementAllocationImmediateExpenseAmount, getStatementAllocationImmediateExpenseAmount,
getStatementAllocationImmediateExpenseImpact getStatementAccountExpenseTotal
} from "~/composables/useDepreciation" } from "~/composables/useDepreciation"
const loading = ref(true) const loading = ref(true)
@@ -74,11 +74,19 @@ const loadSummary = async () => {
}) })
const directAccountAllocations = (allocations || []).filter((allocation: any) => { const directAccountAllocations = (allocations || []).filter((allocation: any) => {
const statementDate = allocation?.bankstatement?.date || allocation?.bankstatement?.valueDate || allocation?.date || allocation?.created_at const statementDate = allocation?.bankstatement?.date
|| allocation?.bankstatement?.valueDate
|| allocation?.date
|| allocation?.manualBookingDate
|| allocation?.created_at
const date = dayjs(statementDate) const date = dayjs(statementDate)
const impact = getStatementAllocationImmediateExpenseImpact(allocation) const touchesAccount = (
allocation?.account !== null && allocation?.account !== undefined
) || (
allocation?.contraAccount !== null && allocation?.contraAccount !== undefined
)
return impact !== 0 && date.isValid() && !date.isBefore(bounds.start, "day") && !date.isAfter(bounds.end, "day") return touchesAccount && date.isValid() && !date.isBefore(bounds.start, "day") && !date.isAfter(bounds.end, "day")
}) })
const income = outputDocs.reduce((sum: number, doc: any) => { const income = outputDocs.reduce((sum: number, doc: any) => {
@@ -99,9 +107,7 @@ const loadSummary = async () => {
return sum + getIncomingInvoiceImmediateExpenseNet(invoice) return sum + getIncomingInvoiceImmediateExpenseNet(invoice)
}, 0) }, 0)
const directAccountExpenses = directAccountAllocations.reduce((sum: number, allocation: any) => { const directAccountExpenses = getStatementAccountExpenseTotal(directAccountAllocations)
return sum + Number(getStatementAllocationImmediateExpenseImpact(allocation) || 0)
}, 0)
const depreciationRows = [ const depreciationRows = [
...inputDocs.flatMap((invoice: any) => getIncomingInvoiceDepreciationRows(invoice, bounds.start, bounds.end)) ...inputDocs.flatMap((invoice: any) => getIncomingInvoiceDepreciationRows(invoice, bounds.start, bounds.end))

View File

@@ -317,6 +317,31 @@ export const getStatementAllocationImmediateExpenseAmount = (allocation: any) =>
return Math.max(0, getStatementAllocationImmediateExpenseImpact(allocation)) return Math.max(0, getStatementAllocationImmediateExpenseImpact(allocation))
} }
export const getStatementAccountExpenseTotal = (allocations: any[] = []) => {
const balances = new Map<string, number>()
const addAmount = (account: any, amount: number) => {
const id = account?.id || account
if (id === null || id === undefined || id === "") return
const key = String(id)
balances.set(key, Number(balances.get(key) || 0) + amount)
}
;(allocations || []).forEach((allocation) => {
if (normalizeExpenseBookingMode(allocation?.bookingMode) !== "expense") return
const amount = Number(allocation?.amount || 0)
addAmount(allocation?.account, amount)
addAmount(allocation?.contraAccount, -amount)
})
const total = Array.from(balances.values()).reduce((sum, balance) => {
return balance < 0 ? sum + Math.abs(balance) : sum
}, 0)
return Number(total.toFixed(2))
}
export const getStatementAllocationDepreciationAmount = (allocation: any, rangeStart: any, rangeEnd: any) => { export const getStatementAllocationDepreciationAmount = (allocation: any, rangeStart: any, rangeEnd: any) => {
const mode = normalizeExpenseBookingMode(allocation?.bookingMode) const mode = normalizeExpenseBookingMode(allocation?.bookingMode)
const rawAmount = Number(allocation?.amount || 0) const rawAmount = Number(allocation?.amount || 0)

View File

@@ -11,7 +11,7 @@ import {
isDepreciationBookingMode, isDepreciationBookingMode,
normalizeIncomingInvoiceAccount, normalizeIncomingInvoiceAccount,
getStatementAllocationImmediateExpenseAmount, getStatementAllocationImmediateExpenseAmount,
getStatementAllocationImmediateExpenseImpact getStatementAccountExpenseTotal
} from "~/composables/useDepreciation" } from "~/composables/useDepreciation"
const router = useRouter() const router = useRouter()
@@ -191,9 +191,7 @@ const expenseNetTotal = computed(() => {
return sum + getIncomingInvoiceImmediateExpenseNet(invoice) return sum + getIncomingInvoiceImmediateExpenseNet(invoice)
}, 0) }, 0)
const directAccountExpenses = filteredStatementAllocations.value.reduce((sum, allocation) => { const directAccountExpenses = getStatementAccountExpenseTotal(filteredStatementAllocations.value)
return sum + Number(getStatementAllocationImmediateExpenseImpact(allocation) || 0)
}, 0)
const depreciations = depreciationTotal.value const depreciations = depreciationTotal.value
@@ -203,9 +201,7 @@ const expenseNetTotal = computed(() => {
const expenseGrossTotal = computed(() => { const expenseGrossTotal = computed(() => {
const invoiceExpenses = filteredIncomingInvoices.value.reduce((sum, invoice) => sum + getIncomingInvoiceImmediateExpenseGross(invoice), 0) const invoiceExpenses = filteredIncomingInvoices.value.reduce((sum, invoice) => sum + getIncomingInvoiceImmediateExpenseGross(invoice), 0)
const directAccountExpenses = filteredStatementAllocations.value.reduce((sum, allocation) => { const directAccountExpenses = getStatementAccountExpenseTotal(filteredStatementAllocations.value)
return sum + Number(getStatementAllocationImmediateExpenseImpact(allocation) || 0)
}, 0)
const depreciations = depreciationTotal.value const depreciations = depreciationTotal.value