BREAKING CHANGE(core): Refactor contact and PDF handling across the library by replacing IContact with TContact and updating PDF processing to use a structured IPdf object. These changes ensure that empty contact objects include registration details, founded/closed dates, and status, and that PDF loading/exporting uniformly wraps buffers in a proper object.

This commit is contained in:
2025-03-20 13:57:45 +00:00
parent 75b720a98d
commit 6906e2f778
8 changed files with 164 additions and 31 deletions

View File

@ -118,21 +118,37 @@ export class XInvoiceDecoder extends BaseDecoder {
'Unknown Buyer';
// Create seller contact
const seller: plugins.tsclass.business.IContact = {
const seller: plugins.tsclass.business.TContact = {
name: sellerName,
type: 'company',
description: sellerName,
address: {
streetName: sellerStreet,
houseNumber: '0', // Required by IAddress interface
houseNumber: '0',
city: sellerCity,
country: sellerCountry,
postalCode: sellerPostcode,
},
registrationDetails: {
vatId: this.getElementText('cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID') || 'Unknown',
registrationId: this.getElementText('cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyID') || 'Unknown',
registrationName: sellerName
},
foundedDate: {
year: 2000,
month: 1,
day: 1
},
closedDate: {
year: 9999,
month: 12,
day: 31
},
status: 'active'
};
// Create buyer contact
const buyer: plugins.tsclass.business.IContact = {
const buyer: plugins.tsclass.business.TContact = {
name: buyerName,
type: 'company',
description: buyerName,
@ -143,6 +159,22 @@ export class XInvoiceDecoder extends BaseDecoder {
country: 'Unknown',
postalCode: 'Unknown',
},
registrationDetails: {
vatId: this.getElementText('cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID') || 'Unknown',
registrationId: this.getElementText('cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyID') || 'Unknown',
registrationName: buyerName
},
foundedDate: {
year: 2000,
month: 1,
day: 1
},
closedDate: {
year: 9999,
month: 12,
day: 31
},
status: 'active'
};
// Extract invoice type