diff --git a/scripts/showcase-xml.mts b/scripts/showcase-xml.mts new file mode 100644 index 0000000..c8472e3 --- /dev/null +++ b/scripts/showcase-xml.mts @@ -0,0 +1,30 @@ +import { InvoiceService } from "@e-invoice-eu/core"; +import { buildEInvoiceData } from "../src/einvoice/buildEInvoiceData.js"; +import { SAMPLE_INVOICE_ORDER } from "../src/invoicePdf.js"; +import type { InvoiceSeller } from "../src/seller.js"; + +const seller: InvoiceSeller = { + sellerName: "einfach produktiv", + sellerStreet: "Musterstraße 1", + sellerZip: "10115", + sellerCity: "Berlin", + sellerCountry: "Deutschland", + sellerEmail: "hallo@einfach-produktiv.de", + vatId: "DE123456789", + taxRatePercent: 19, + iban: "DE89370400440532013000", + bic: "COBADEFFXXX", +}; + +const invoiceData = buildEInvoiceData(SAMPLE_INVOICE_ORDER, seller); +const service = new InvoiceService(console); + +async function main() { + const xml = await service.generate(invoiceData, { format: "CII", lang: "de" }); + if (typeof xml !== "string") throw new Error("expected string"); + const fs = await import("node:fs/promises"); + await fs.writeFile("/tmp/showcase-invoice.xml", xml); + console.log("wrote /tmp/showcase-invoice.xml,", xml.length, "bytes"); +} + +main();