feat(ZUGFERD): Add dedicated ZUGFERD v1/v2 support and refine invoice format detection logic
This commit is contained in:
@ -5,7 +5,8 @@ import { FormatDetector } from '../utils/format.detector.js';
|
||||
// Import specific decoders
|
||||
import { XRechnungDecoder } from '../ubl/xrechnung/xrechnung.decoder.js';
|
||||
import { FacturXDecoder } from '../cii/facturx/facturx.decoder.js';
|
||||
// import { ZUGFeRDDecoder } from '../cii/zugferd/zugferd.decoder.js';
|
||||
import { ZUGFeRDDecoder } from '../cii/zugferd/zugferd.decoder.js';
|
||||
import { ZUGFeRDV1Decoder } from '../cii/zugferd/zugferd.v1.decoder.js';
|
||||
|
||||
/**
|
||||
* Factory to create the appropriate decoder based on the XML format
|
||||
@ -29,8 +30,12 @@ export class DecoderFactory {
|
||||
return new FacturXDecoder(xml);
|
||||
|
||||
case InvoiceFormat.ZUGFERD:
|
||||
// For now, use Factur-X decoder for ZUGFeRD
|
||||
return new FacturXDecoder(xml);
|
||||
// Determine if it's ZUGFeRD v1 or v2 based on root element
|
||||
if (xml.includes('CrossIndustryDocument')) {
|
||||
return new ZUGFeRDV1Decoder(xml);
|
||||
} else {
|
||||
return new ZUGFeRDDecoder(xml);
|
||||
}
|
||||
|
||||
case InvoiceFormat.FACTURX:
|
||||
return new FacturXDecoder(xml);
|
||||
|
@ -5,7 +5,7 @@ import type { ExportFormat } from '../../interfaces/common.js';
|
||||
// Import specific encoders
|
||||
import { XRechnungEncoder } from '../ubl/xrechnung/xrechnung.encoder.js';
|
||||
import { FacturXEncoder } from '../cii/facturx/facturx.encoder.js';
|
||||
// import { ZUGFeRDEncoder } from '../cii/zugferd/zugferd.encoder.js';
|
||||
import { ZUGFeRDEncoder } from '../cii/zugferd/zugferd.encoder.js';
|
||||
|
||||
/**
|
||||
* Factory to create the appropriate encoder based on the target format
|
||||
@ -33,8 +33,8 @@ export class EncoderFactory {
|
||||
|
||||
case InvoiceFormat.ZUGFERD:
|
||||
case 'zugferd':
|
||||
// For now, use Factur-X encoder for ZUGFeRD
|
||||
return new FacturXEncoder();
|
||||
// Use dedicated ZUGFeRD encoder
|
||||
return new ZUGFeRDEncoder();
|
||||
|
||||
case InvoiceFormat.FACTURX:
|
||||
case 'facturx':
|
||||
|
@ -6,7 +6,7 @@ import { FormatDetector } from '../utils/format.detector.js';
|
||||
// import { UBLValidator } from '../ubl/ubl.validator.js';
|
||||
// import { XRechnungValidator } from '../ubl/xrechnung/xrechnung.validator.js';
|
||||
import { FacturXValidator } from '../cii/facturx/facturx.validator.js';
|
||||
// import { ZUGFeRDValidator } from '../cii/zugferd/zugferd.validator.js';
|
||||
import { ZUGFeRDValidator } from '../cii/zugferd/zugferd.validator.js';
|
||||
|
||||
/**
|
||||
* Factory to create the appropriate validator based on the XML format
|
||||
@ -34,8 +34,8 @@ export class ValidatorFactory {
|
||||
return new FacturXValidator(xml);
|
||||
|
||||
case InvoiceFormat.ZUGFERD:
|
||||
// For now, use Factur-X validator for ZUGFeRD
|
||||
return new FacturXValidator(xml);
|
||||
// Use dedicated ZUGFeRD validator
|
||||
return new ZUGFeRDValidator(xml);
|
||||
|
||||
case InvoiceFormat.FACTURX:
|
||||
return new FacturXValidator(xml);
|
||||
|
Reference in New Issue
Block a user