BREAKING CHANGE(core): Rebrand XInvoice to EInvoice: update package name, class names, imports, and documentation

This commit is contained in:
2025-05-24 16:33:58 +00:00
parent 805adc6d5c
commit a93ea090ce
27 changed files with 3172 additions and 295 deletions

View File

@ -1,11 +1,11 @@
import { tap, expect } from '@push.rocks/tapbundle';
import { XInvoice } from '../ts/classes.xinvoice.js';
import { EInvoice } from '../ts/einvoice.js';
import { InvoiceFormat } from '../ts/interfaces/common.js';
import * as fs from 'fs/promises';
import * as path from 'path';
// Test circular export/import of corpus files
tap.test('XInvoice should maintain data integrity through export/import cycle', async () => {
tap.test('EInvoice should maintain data integrity through export/import cycle', async () => {
// Get a subset of files for circular testing
const ciiFiles = await findFiles(path.join(process.cwd(), 'test/assets/corpus/XML-Rechnung/CII'), '.xml', 3);
const ublFiles = await findFiles(path.join(process.cwd(), 'test/assets/corpus/XML-Rechnung/UBL'), '.xml', 3);
@ -66,20 +66,20 @@ async function testCircular(files: string[], exportFormat: string): Promise<{ su
// Read the file
const xmlContent = await fs.readFile(file, 'utf8');
// Create XInvoice from XML
const xinvoice = await XInvoice.fromXml(xmlContent);
// Create EInvoice from XML
const einvoice = await EInvoice.fromXml(xmlContent);
// Export to XML
const exportedXml = await xinvoice.exportXml(exportFormat as any);
const exportedXml = await einvoice.exportXml(exportFormat as any);
// Create a new XInvoice from the exported XML
const reimportedXInvoice = await XInvoice.fromXml(exportedXml);
// Create a new EInvoice from the exported XML
const reimportedEInvoice = await EInvoice.fromXml(exportedXml);
// Check that key properties match
const keysMatch =
reimportedXInvoice.from.name === xinvoice.from.name &&
reimportedXInvoice.to.name === xinvoice.to.name &&
reimportedXInvoice.items.length === xinvoice.items.length;
reimportedEInvoice.from.name === einvoice.from.name &&
reimportedEInvoice.to.name === einvoice.to.name &&
reimportedEInvoice.items.length === einvoice.items.length;
if (keysMatch) {
// Success