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);
|
||||
|
Reference in New Issue
Block a user