BREAKING CHANGE(core): Rebrand XInvoice to EInvoice: update package name, class names, imports, and documentation
This commit is contained in:
@ -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, ValidationLevel } from '../ts/interfaces/common.js';
|
||||
import * as fs from 'fs/promises';
|
||||
import * as path from 'path';
|
||||
|
||||
// Test XML-Rechnung corpus (CII and UBL)
|
||||
tap.test('XInvoice should handle XML-Rechnung corpus', async () => {
|
||||
tap.test('EInvoice should handle XML-Rechnung corpus', async () => {
|
||||
// Get all XML-Rechnung files
|
||||
const ciiFiles = await findFiles(path.join(process.cwd(), 'test/assets/corpus/XML-Rechnung/CII'), '.xml');
|
||||
const ublFiles = await findFiles(path.join(process.cwd(), 'test/assets/corpus/XML-Rechnung/UBL'), '.xml');
|
||||
@ -73,13 +73,13 @@ async function testFiles(files: string[], expectedFormat: InvoiceFormat): Promis
|
||||
// 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);
|
||||
|
||||
// Check that the XInvoice instance has the expected properties
|
||||
if (xinvoice && xinvoice.from && xinvoice.to && xinvoice.items) {
|
||||
// Check that the EInvoice instance has the expected properties
|
||||
if (einvoice && einvoice.from && einvoice.to && einvoice.items) {
|
||||
// Check that the format is detected correctly
|
||||
const format = xinvoice.getFormat();
|
||||
const format = einvoice.getFormat();
|
||||
const isCorrectFormat = format === expectedFormat ||
|
||||
(expectedFormat === InvoiceFormat.CII && format === InvoiceFormat.FACTURX) ||
|
||||
(expectedFormat === InvoiceFormat.FACTURX && format === InvoiceFormat.CII) ||
|
||||
@ -94,7 +94,7 @@ async function testFiles(files: string[], expectedFormat: InvoiceFormat): Promis
|
||||
exportFormat = 'xrechnung';
|
||||
}
|
||||
|
||||
const exportedXml = await xinvoice.exportXml(exportFormat as any);
|
||||
const exportedXml = await einvoice.exportXml(exportFormat as any);
|
||||
|
||||
if (exportedXml) {
|
||||
// Success
|
||||
|
Reference in New Issue
Block a user