feat: allow manual input tax adjustments

This commit is contained in:
2026-08-09 14:17:31 +02:00
parent 09431a87c7
commit ae4ff9aad0

View File

@@ -194,6 +194,16 @@ const totalCalculated = computed(() => {
const hasAmount = (value) => value !== null && value !== undefined && value !== "" const hasAmount = (value) => value !== null && value !== undefined && value !== ""
const hasValidNumber = (value) => hasAmount(value) && Number.isFinite(Number(value)) const hasValidNumber = (value) => hasAmount(value) && Number.isFinite(Number(value))
const isDepreciationItem = (item) => isDepreciationBookingMode(item?.bookingMode) const isDepreciationItem = (item) => isDepreciationBookingMode(item?.bookingMode)
const getCalculatedTax = (item) => {
const taxRate = Number(taxOptions.value.find((tax) => tax.key === item.taxType)?.percentage || 0)
return Number((Number(item.amountNet || 0) * (taxRate / 100)).toFixed(2))
}
const hasManualTaxDifference = (item) => {
if (!hasValidNumber(item.amountTax) || !hasValidNumber(item.amountNet)) return false
return Math.abs(Number(item.amountTax) - getCalculatedTax(item)) >= 0.005
}
const updateBookingMode = (item) => { const updateBookingMode = (item) => {
ensureDepreciationDefaults(item, itemInfo.value.date) ensureDepreciationDefaults(item, itemInfo.value.date)
@@ -216,6 +226,14 @@ const recalculateItem = (item, source) => {
calculateFromNet() calculateFromNet()
} else if (source === 'gross') { } else if (source === 'gross') {
calculateFromGross() calculateFromGross()
} else if (source === 'tax') {
if(!hasValidNumber(item.amountTax)) return
if((useNetMode.value || !hasAmount(item.amountGross)) && hasAmount(item.amountNet)) {
item.amountGross = Number((Number(item.amountNet) + Number(item.amountTax)).toFixed(2))
} else if(hasAmount(item.amountGross)) {
item.amountNet = Number((Number(item.amountGross) - Number(item.amountTax)).toFixed(2))
}
} else if (source === 'taxType' || source === 'manual') { } else if (source === 'taxType' || source === 'manual') {
if(hasAmount(item.amountNet)) calculateFromNet() if(hasAmount(item.amountNet)) calculateFromNet()
else if(hasAmount(item.amountGross)) calculateFromGross() else if(hasAmount(item.amountGross)) calculateFromGross()
@@ -871,13 +889,30 @@ const hasBlockingIncomingInvoiceErrors = computed(() => blockingIncomingInvoiceE
</div> </div>
<div class="col-span-6 md:col-span-3"> <div class="col-span-6 md:col-span-3">
<UFormField label="Steuerbetrag" help="Automatisch berechnet"> <UFormField label="Steuerbetrag" help="Kann bei Rundungsabweichungen angepasst werden">
<UInput class="w-full" :model-value="item.amountTax" disabled color="gray" > <UInput
class="w-full"
type="number"
step="0.01"
:model-value="item.amountTax"
:disabled="mode === 'show'"
@update:model-value="(val) => { item.amountTax = Number(val); recalculateItem(item, 'tax') }"
>
<template #trailing>€</template> <template #trailing>€</template>
</UInput> </UInput>
</UFormField> </UFormField>
</div> </div>
<div v-if="hasManualTaxDifference(item)" class="col-span-12">
<UAlert
color="warning"
variant="soft"
icon="i-heroicons-exclamation-triangle"
title="Steuerbetrag manuell angepasst"
description="FEDEO verwendet diesen Betrag für Auswertungen und Summen. Im DATEV-Export wird bei der Automatikbuchung nur der Bruttobetrag mit Steuerschlüssel übertragen; DATEV berechnet die Steuer dort erneut."
/>
</div>
<div class="col-span-12 flex justify-end gap-2"> <div class="col-span-12 flex justify-end gap-2">
<UButton <UButton
size="xs" size="xs"