feat(core): Improve XML processing and error handling for PDF invoice attachments
This commit is contained in:
@ -5,18 +5,77 @@ export async function getInvoice(filePath: string): Promise<Buffer> {
|
||||
return file;
|
||||
}
|
||||
|
||||
// Maps of predefined invoice formats for easy test access
|
||||
export const invoices = {
|
||||
// ZUGFeRD 2.x format invoices
|
||||
ZUGFeRDv2: {
|
||||
correct: {
|
||||
intarsys: {
|
||||
BASIC: {
|
||||
'zugferd_2p0_BASIC_Einfach.pdf': 'ZUGFeRDv2/correct/intarsys/BASIC/zugferd_2p0_BASIC_Einfach.pdf'
|
||||
'zugferd_2p0_BASIC_Einfach.pdf': 'ZUGFeRDv2/correct/intarsys/BASIC/zugferd_2p0_BASIC_Einfach.pdf',
|
||||
'zugferd_2p0_BASIC_Rechnungskorrektur.pdf': 'ZUGFeRDv2/correct/intarsys/BASIC/zugferd_2p0_BASIC_Rechnungskorrektur.pdf',
|
||||
'zugferd_2p0_BASIC_Taxifahrt.pdf': 'ZUGFeRDv2/correct/intarsys/BASIC/zugferd_2p0_BASIC_Taxifahrt.pdf'
|
||||
},
|
||||
EN16931: {
|
||||
'zugferd_2p0_EN16931_Einfach.pdf': 'ZUGFeRDv2/correct/intarsys/EN16931/zugferd_2p0_EN16931_Einfach.pdf',
|
||||
'zugferd_2p0_EN16931_Elektron.pdf': 'ZUGFeRDv2/correct/intarsys/EN16931/zugferd_2p0_EN16931_Elektron.pdf',
|
||||
'zugferd_2p0_EN16931_Gutschrift.pdf': 'ZUGFeRDv2/correct/intarsys/EN16931/zugferd_2p0_EN16931_Gutschrift.pdf'
|
||||
},
|
||||
EXTENDED: {
|
||||
'zugferd_2p0_EXTENDED_Warenrechnung.pdf': 'ZUGFeRDv2/correct/intarsys/EXTENDED/zugferd_2p0_EXTENDED_Warenrechnung.pdf'
|
||||
}
|
||||
},
|
||||
Mustangproject: {
|
||||
'MustangGnuaccountingBeispielRE-20201121_508.pdf': 'ZUGFeRDv2/correct/Mustangproject/MustangGnuaccountingBeispielRE-20201121_508.pdf'
|
||||
}
|
||||
},
|
||||
fail: {
|
||||
Mustangproject: {
|
||||
'MustangGnuaccountingBeispielRE-20190610_507a.pdf': 'ZUGFeRDv2/fail/Mustangproject/MustangGnuaccountingBeispielRE-20190610_507a.pdf'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// ZUGFeRD 1.0 format invoices
|
||||
ZUGFeRDv1: {
|
||||
correct: {
|
||||
Intarsys: {
|
||||
'ZUGFeRD_1p0_BASIC_Einfach.pdf': 'ZUGFeRDv1/correct/Intarsys/ZUGFeRD_1p0_BASIC_Einfach.pdf',
|
||||
'ZUGFeRD_1p0_COMFORT_Einfach.pdf': 'ZUGFeRDv1/correct/Intarsys/ZUGFeRD_1p0_COMFORT_Einfach.pdf'
|
||||
},
|
||||
Mustangproject: {
|
||||
'MustangGnuaccountingBeispielRE-20140519_499.pdf': 'ZUGFeRDv1/correct/Mustangproject/MustangGnuaccountingBeispielRE-20140519_499.pdf'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// XML-Rechnung format invoices
|
||||
XMLRechnung: {
|
||||
UBL: {
|
||||
'EN16931_Einfach.ubl.xml': 'XML-Rechnung/UBL/EN16931_Einfach.ubl.xml',
|
||||
'EN16931_Gutschrift.ubl.xml': 'XML-Rechnung/UBL/EN16931_Gutschrift.ubl.xml'
|
||||
},
|
||||
CII: {
|
||||
'EN16931_Einfach.cii.xml': 'XML-Rechnung/CII/EN16931_Einfach.cii.xml',
|
||||
'EN16931_Gutschrift.cii.xml': 'XML-Rechnung/CII/EN16931_Gutschrift.cii.xml'
|
||||
}
|
||||
},
|
||||
|
||||
// Factura PA format invoices
|
||||
fatturaPA: {
|
||||
valid: {
|
||||
'IT01234567890_FPA01.xml': 'fatturaPA/official/valid/IT01234567890_FPA01.xml',
|
||||
'IT01234567890_FPR01.xml': 'fatturaPA/official/valid/IT01234567890_FPR01.xml'
|
||||
}
|
||||
},
|
||||
|
||||
// Plain PDFs without embedded XML for testing embedding
|
||||
unstructured: {
|
||||
'RE-E-974-Hetzner_2016-01-19_R0005532486.pdf': 'unstructured/RE-E-974-Hetzner_2016-01-19_R0005532486.pdf'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Test data objects for use in tests
|
||||
export const letterObjects = {
|
||||
letter1: await import('./letter/letter1.js'),
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user