fix(corpus-tests, format-detection): Adjust corpus test thresholds and improve XML format detection for invoice documents
This commit is contained in:
@ -31,7 +31,9 @@ export class DecoderFactory {
|
||||
|
||||
case InvoiceFormat.ZUGFERD:
|
||||
// Determine if it's ZUGFeRD v1 or v2 based on root element
|
||||
if (xml.includes('CrossIndustryDocument')) {
|
||||
if (xml.includes('CrossIndustryDocument') ||
|
||||
xml.includes('urn:ferd:CrossIndustryDocument:invoice:1p0') ||
|
||||
(xml.includes('ZUGFeRD') && !xml.includes('CrossIndustryInvoice'))) {
|
||||
return new ZUGFeRDV1Decoder(xml);
|
||||
} else {
|
||||
return new ZUGFeRDDecoder(xml);
|
||||
@ -45,6 +47,14 @@ export class DecoderFactory {
|
||||
throw new Error('FatturaPA decoder not yet implemented');
|
||||
|
||||
default:
|
||||
// If format is unknown but contains CrossIndustryInvoice, try ZUGFeRD decoder
|
||||
if (xml.includes('CrossIndustryInvoice')) {
|
||||
return new ZUGFeRDDecoder(xml);
|
||||
}
|
||||
// If format is unknown but contains CrossIndustryDocument, try ZUGFeRD v1 decoder
|
||||
if (xml.includes('CrossIndustryDocument')) {
|
||||
return new ZUGFeRDV1Decoder(xml);
|
||||
}
|
||||
throw new Error(`Unsupported invoice format: ${format}`);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user