BREAKING CHANGE(XInvoice): Refactor XInvoice API for XML handling and PDF export by replacing deprecated methods (addXmlString and getParsedXmlData) with fromXml and loadXml, and by introducing a new ExportFormat type for type-safe export. Update tests accordingly.

This commit is contained in:
2025-03-20 14:39:32 +00:00
parent d954fb4768
commit 9510d851af
10 changed files with 174 additions and 72 deletions

View File

@ -51,15 +51,17 @@ tap.test('CII validator should validate valid XML at syntax level', async () =>
tap.test('XInvoice class should validate invoices on load when requested', async () => {
// Import XInvoice dynamically to prevent circular dependencies
const { XInvoice } = await import('../ts/index.js');
const invoice = new XInvoice();
// Create XInvoice with validation enabled
const options = { validateOnLoad: true };
// Load a UBL invoice with validation
const path = getInvoices.invoices.XMLRechnung.UBL['EN16931_Einfach.ubl.xml'];
const invoiceBuffer = await getInvoices.getInvoice(path);
const xml = invoiceBuffer.toString('utf8');
// Add XML with validation enabled
await invoice.addXmlString(xml, true);
// Create XInvoice from XML with validation enabled
const invoice = await XInvoice.fromXml(xml, options);
// Check validation results
expect(invoice.isValid()).toBeTrue();