feat(banking): add cost centres and VAT to account allocations

This commit is contained in:
2026-09-23 18:08:09 +02:00
parent 847a616285
commit cbec5b058d
21 changed files with 517 additions and 42 deletions

View File

@@ -0,0 +1,43 @@
export const BANK_ALLOCATION_TAX_ITEMS = [
{ value: "9", label: "19 % Vorsteuer", rate: 19, kind: "input" },
{ value: "8", label: "7 % Vorsteuer", rate: 7, kind: "input" },
{ value: "3", label: "19 % Umsatzsteuer", rate: 19, kind: "output" },
{ value: "2", label: "7 % Umsatzsteuer", rate: 7, kind: "output" },
{ value: "40", label: "Ohne Umsatzsteuer", rate: 0, kind: "none" },
]
export const isDirectBankAllocation = (allocation: any) => Boolean(
allocation?.bankstatement && (allocation.account || allocation.ownaccount)
&& !allocation.createddocument && !allocation.incominginvoice
&& !allocation.customer && !allocation.vendor && !allocation.archived
)
// The signed bank amount always remains gross. Refunds retain their sign.
export function getBankAllocationAmounts(allocation: any) {
const amountGross = Number(allocation?.amount || 0)
const tax = isDirectBankAllocation(allocation)
? BANK_ALLOCATION_TAX_ITEMS.find(item => item.value === String(allocation.datevTaxKey))
: undefined
const rate = tax?.rate || 0
const amountNet = Number((amountGross / (1 + rate / 100)).toFixed(2))
const amountTax = Number((amountGross - amountNet).toFixed(2))
return { amountGross, amountNet, amountTax, rate, kind: tax?.kind || "none" }
}
export function getBankAllocationTaxBreakdown(allocation: any) {
const output = { net19: 0, tax19: 0, net7: 0, tax7: 0, net0: 0 }
const input = { ...output }
if (!isDirectBankAllocation(allocation)) return { output, input }
const { amountNet, amountTax, rate, kind } = getBankAllocationAmounts(allocation)
if (kind === "none") return { output, input }
const target = kind === "input" ? input : output
const sign = kind === "input" ? -1 : 1
if (rate === 19) {
target.net19 = amountNet * sign
target.tax19 = amountTax * sign
} else if (rate === 7) {
target.net7 = amountNet * sign
target.tax7 = amountTax * sign
}
return { output, input }
}