KI-AGENT: Positive Kontobuchungen mit BWA-Ausgaben verrechnen
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 21s
Build and Push Docker Images / build-frontend (push) Successful in 1m10s
Build and Push Docker Images / build-website (push) Successful in 22s
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 21s
Build and Push Docker Images / build-docs (push) Successful in 1m20s

This commit is contained in:
2026-09-07 20:50:24 +02:00
parent e4fcd79c8e
commit b89fdedeae
3 changed files with 23 additions and 19 deletions

View File

@@ -7,7 +7,8 @@ import {
import {
getIncomingInvoiceDepreciationRows,
getIncomingInvoiceImmediateExpenseNet,
getStatementAllocationImmediateExpenseAmount
getStatementAllocationImmediateExpenseAmount,
getStatementAllocationImmediateExpenseImpact
} from "~/composables/useDepreciation"
const loading = ref(true)
@@ -72,16 +73,12 @@ const loadSummary = async () => {
return date.isValid() && !date.isBefore(bounds.start, "day") && !date.isAfter(bounds.end, "day")
})
const directExpenses = (allocations || []).filter((allocation: any) => {
if (allocation?.account === null || typeof allocation?.account === "undefined") {
return false
}
const directAccountAllocations = (allocations || []).filter((allocation: any) => {
const statementDate = allocation?.bankstatement?.date || allocation?.bankstatement?.valueDate || allocation?.date || allocation?.created_at
const date = dayjs(statementDate)
const amount = getStatementAllocationImmediateExpenseAmount(allocation)
const impact = getStatementAllocationImmediateExpenseImpact(allocation)
return amount > 0 && date.isValid() && !date.isBefore(bounds.start, "day") && !date.isAfter(bounds.end, "day")
return impact !== 0 && date.isValid() && !date.isBefore(bounds.start, "day") && !date.isAfter(bounds.end, "day")
})
const income = outputDocs.reduce((sum: number, doc: any) => {
@@ -102,8 +99,8 @@ const loadSummary = async () => {
return sum + getIncomingInvoiceImmediateExpenseNet(invoice)
}, 0)
const directAccountExpenses = directExpenses.reduce((sum: number, allocation: any) => {
return sum + Number(getStatementAllocationImmediateExpenseAmount(allocation) || 0)
const directAccountExpenses = directAccountAllocations.reduce((sum: number, allocation: any) => {
return sum + Number(getStatementAllocationImmediateExpenseImpact(allocation) || 0)
}, 0)
const depreciationRows = [
@@ -132,7 +129,7 @@ const loadSummary = async () => {
result: Number((income - expenses).toFixed(2)),
taxBalance: Number((outputTax - inputTax).toFixed(2)),
incomeCount: outputDocs.length,
expenseCount: inputDocs.filter((invoice: any) => getIncomingInvoiceImmediateExpenseNet(invoice) > 0).length + directExpenses.filter((allocation: any) => getStatementAllocationImmediateExpenseAmount(allocation) > 0).length,
expenseCount: inputDocs.filter((invoice: any) => getIncomingInvoiceImmediateExpenseNet(invoice) > 0).length + directAccountAllocations.filter((allocation: any) => getStatementAllocationImmediateExpenseAmount(allocation) > 0).length,
depreciationCount: depreciationRows.length
}
} finally {

View File

@@ -301,14 +301,20 @@ export const getIncomingInvoiceDepreciationRows = (invoice: any, rangeStart: any
.filter(Boolean)
}
export const getStatementAllocationImmediateExpenseAmount = (allocation: any) => {
export const getStatementAllocationImmediateExpenseImpact = (allocation: any) => {
const hasLinkedDocument = allocation?.incominginvoice || allocation?.createddocument || allocation?.ii_id || allocation?.cd_id
if (hasLinkedDocument) return 0
if (allocation?.account === null || allocation?.account === undefined) return 0
const mode = normalizeExpenseBookingMode(allocation?.bookingMode)
const amount = Number(allocation?.amount || 0)
if (mode !== "expense" || amount >= 0) return 0
return Number(Math.abs(amount).toFixed(2))
if (mode !== "expense") return 0
return Number((-amount).toFixed(2))
}
export const getStatementAllocationImmediateExpenseAmount = (allocation: any) => {
return Math.max(0, getStatementAllocationImmediateExpenseImpact(allocation))
}
export const getStatementAllocationDepreciationAmount = (allocation: any, rangeStart: any, rangeEnd: any) => {

View File

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