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

@ -23,8 +23,8 @@ export class XInvoiceEncoder {
}
const invoice: plugins.tsclass.finance.IInvoice = letterArg.content.invoiceData;
const billedBy: plugins.tsclass.business.IContact = invoice.billedBy;
const billedTo: plugins.tsclass.business.IContact = invoice.billedTo;
const billedBy: plugins.tsclass.business.TContact = invoice.billedBy;
const billedTo: plugins.tsclass.business.TContact = invoice.billedTo;
// Create the XML document
const doc = smartxmlInstance
@ -76,9 +76,9 @@ export class XInvoiceEncoder {
const supplierPartyDetails = supplierParty.ele('cac:Party');
// Seller VAT ID
if (billedBy.vatId) {
if (billedBy.type === 'company' && billedBy.registrationDetails?.vatId) {
const partyTaxScheme = supplierPartyDetails.ele('cac:PartyTaxScheme');
partyTaxScheme.ele('cbc:CompanyID').txt(billedBy.vatId).up();
partyTaxScheme.ele('cbc:CompanyID').txt(billedBy.registrationDetails.vatId).up();
partyTaxScheme.ele('cac:TaxScheme')
.ele('cbc:ID').txt('VAT').up()
.up();
@ -117,9 +117,9 @@ export class XInvoiceEncoder {
const customerPartyDetails = customerParty.ele('cac:Party');
// Buyer VAT ID
if (billedTo.vatId) {
if (billedTo.type === 'company' && billedTo.registrationDetails?.vatId) {
const partyTaxScheme = customerPartyDetails.ele('cac:PartyTaxScheme');
partyTaxScheme.ele('cbc:CompanyID').txt(billedTo.vatId).up();
partyTaxScheme.ele('cbc:CompanyID').txt(billedTo.registrationDetails.vatId).up();
partyTaxScheme.ele('cac:TaxScheme')
.ele('cbc:ID').txt('VAT').up()
.up();