From eae321b364a4dd7c7d8c9e19c8fa7029a1e2ee66 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Tue, 12 May 2026 11:21:09 +0200 Subject: [PATCH] =?UTF-8?q?DATEV-Steuerschl=C3=BCssel=20f=C3=BCr=2013b-Aus?= =?UTF-8?q?gangsrechnungen=20setzen=20#179?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/utils/export/datev.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/src/utils/export/datev.ts b/backend/src/utils/export/datev.ts index 26a9a00..862c2d6 100644 --- a/backend/src/utils/export/datev.ts +++ b/backend/src/utils/export/datev.ts @@ -57,6 +57,14 @@ const displayCurrency = (input: number, onlyAbs = false) => { return (onlyAbs ? Math.abs(input) : input).toFixed(2).replace(".", ","); }; +const getCreatedDocumentDatevTaxKey = (document: { taxType?: string | null }) => { + return document.taxType === "13b UStG" ? "46" : ""; +}; + +const getCreatedDocumentPaymentDatevTaxKey = (document: { taxType?: string | null }) => { + return document.taxType === "13b UStG" ? "46" : "3"; +}; + // --------------------------------------------------------- // MAIN EXPORT FUNCTION // --------------------------------------------------------- @@ -305,8 +313,9 @@ export async function buildExportZip( let shSelector = Math.sign(total) === -1 ? "H" : "S"; const cust = cd.customer; // durch Mapping verfügbar + const datevTaxKey = getCreatedDocumentDatevTaxKey(cd); - bookingLines.push(`${displayCurrency(total,true)};"${shSelector}";;;;;${cust?.customerNumber || ""};8400;"";${dayjs(cd.documentDate).format("DDMM")};"${cd.documentNumber}";;;"${`${typeString} ${cd.documentNumber} - ${cust?.name || ""}`.substring(0,59)}";;;;;;${file ? `"BEDI ""${file.id}"""` : ""};"Geschäftspartner";"${cust?.name || ""}";"Kundennummer";"${cust?.customerNumber || ""}";"Belegnummer";"${cd.documentNumber}";"Leistungsdatum";"${dayjs(cd.deliveryDate).format("DD.MM.YYYY")}";"Belegdatum";"${dayjs(cd.documentDate).format("DD.MM.YYYY")}";;;;;;;;;;"";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0;;;;"";;;;;;;`); + bookingLines.push(`${displayCurrency(total,true)};"${shSelector}";;;;;${cust?.customerNumber || ""};8400;"${datevTaxKey}";${dayjs(cd.documentDate).format("DDMM")};"${cd.documentNumber}";;;"${`${typeString} ${cd.documentNumber} - ${cust?.name || ""}`.substring(0,59)}";;;;;;${file ? `"BEDI ""${file.id}"""` : ""};"Geschäftspartner";"${cust?.name || ""}";"Kundennummer";"${cust?.customerNumber || ""}";"Belegnummer";"${cd.documentNumber}";"Leistungsdatum";"${dayjs(cd.deliveryDate).format("DD.MM.YYYY")}";"Belegdatum";"${dayjs(cd.documentDate).format("DD.MM.YYYY")}";;;;;;;;;;"";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0;;;;"";;;;;;;`); }); // ER @@ -383,7 +392,8 @@ export async function buildExportZip( if(alloc.createddocument && alloc.createddocument.customer) { const cd = alloc.createddocument; const cust = cd.customer; - bookingLines.push(`${displayCurrency(alloc.amount,true)};"H";;;;;${cust?.customerNumber};${datevKonto};"3";${dayjs(cd.documentDate).format("DDMM")};"${cd.documentNumber}";;;"${`ZE${alloc.description}${bsText}`.substring(0,59)}";;;;;;;"Geschäftspartner";"${cust?.name}";"Kundennummer";"${cust?.customerNumber}";"Belegnummer";"${cd.documentNumber}";"Leistungsdatum";"${dayjs(cd.deliveryDate).format("DD.MM.YYYY")}";"Belegdatum";"${dateFull}";;;;;;;;;;"";;;;;;;;Bank-Id;${alloc.bankstatement.id};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0;;;;"";;;;;;`); + const datevTaxKey = getCreatedDocumentPaymentDatevTaxKey(cd); + bookingLines.push(`${displayCurrency(alloc.amount,true)};"H";;;;;${cust?.customerNumber};${datevKonto};"${datevTaxKey}";${dayjs(cd.documentDate).format("DDMM")};"${cd.documentNumber}";;;"${`ZE${alloc.description}${bsText}`.substring(0,59)}";;;;;;;"Geschäftspartner";"${cust?.name}";"Kundennummer";"${cust?.customerNumber}";"Belegnummer";"${cd.documentNumber}";"Leistungsdatum";"${dayjs(cd.deliveryDate).format("DD.MM.YYYY")}";"Belegdatum";"${dateFull}";;;;;;;;;;"";;;;;;;;Bank-Id;${alloc.bankstatement.id};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0;;;;"";;;;;;`); } else if(alloc.incominginvoice && alloc.incominginvoice.vendor) { const ii = alloc.incominginvoice; const vend = ii.vendor;