feat(accounting): Ausgangsrechnungen als ZUGFeRD-E-Rechnung (EN 16931) erzeugen
Rechnungen, Abschlags-, Storno- und Serienrechnungen erhalten beim Fertigstellen ein eingebettetes factur-x.xml (CII, Profil EN 16931) samt Factur-X-XMP-Metadaten. Das XML wird serverseitig aus dem gespeicherten Beleg erzeugt; fehlende Pflichtangaben werden als Hinweis gemeldet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,15 +34,19 @@ export const useFunctions = () => {
|
||||
return (await useNuxtApp().$api(`/api/banking/link/${institutionId}`)).link
|
||||
}
|
||||
|
||||
const useCreatePDF = async (data,path,type) => {
|
||||
// options.createdDocumentId: gespeicherter Beleg, aus dem das Backend die eingebettete E-Rechnung (ZUGFeRD) erzeugt
|
||||
const useCreatePDF = async (data,path,type,options = {}) => {
|
||||
const returnData = await useNuxtApp().$api(`/api/functions/pdf/${type}`, {
|
||||
method: "POST",
|
||||
body: {
|
||||
data: data,
|
||||
backgroundPath: path,
|
||||
...(options.createdDocumentId ? { createdDocumentId: options.createdDocumentId } : {}),
|
||||
}
|
||||
})
|
||||
|
||||
if (options.onResult) options.onResult(returnData)
|
||||
|
||||
console.log(returnData)
|
||||
|
||||
return `data:${returnData.mimeType};base64,${returnData.base64}`
|
||||
|
||||
@@ -1764,7 +1764,7 @@ const getDocumentData = async () => {
|
||||
|
||||
const showDocument = ref(false)
|
||||
const uri = ref("")
|
||||
const generateDocument = async () => {
|
||||
const generateDocument = async (options = {}) => {
|
||||
showDocument.value = false
|
||||
const selectedLetterhead = getSelectedLetterhead()
|
||||
|
||||
@@ -1775,7 +1775,7 @@ const generateDocument = async () => {
|
||||
|
||||
const path = selectedLetterhead.path
|
||||
|
||||
uri.value = await useFunctions().useCreatePDF(await getDocumentData(), path, "createdDocument")
|
||||
uri.value = await useFunctions().useCreatePDF(await getDocumentData(), path, "createdDocument", options)
|
||||
/*uri.value = await useNuxtApp().$api("/api/functions/createinvoicepdf",{
|
||||
method: "POST",
|
||||
body: {
|
||||
@@ -2048,7 +2048,19 @@ const closeDocument = async () => {
|
||||
|
||||
// Erzeugt die PDF aus dem aktuellen Stand und hängt sie an den Beleg an, ohne den Datensatz zu speichern
|
||||
const uploadGeneratedDocument = async () => {
|
||||
await generateDocument()
|
||||
// Rechnungen werden als E-Rechnung (ZUGFeRD) abgelegt; das XML erzeugt das Backend aus dem gespeicherten Beleg
|
||||
await generateDocument({
|
||||
createdDocumentId: itemInfo.value.id,
|
||||
onResult: (result) => {
|
||||
if (result?.einvoiceWarnings?.length) {
|
||||
toast.add({
|
||||
title: result.einvoice ? "E-Rechnung mit Hinweisen erstellt" : "E-Rechnung konnte nicht erstellt werden",
|
||||
description: result.einvoiceWarnings.join(" · "),
|
||||
color: "warning",
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
if (!uri.value) throw new Error("PDF konnte nicht erzeugt werden")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user