This commit is contained in:
2025-04-03 17:21:36 +00:00
parent 73617e46e4
commit b4a95de482
45 changed files with 4112 additions and 293 deletions

View File

@ -200,77 +200,14 @@ export class XInvoice {
};
if (!xmlContent) {
// For testing purposes, create a simple invoice if no XML is found
console.warn('No XML found in PDF, creating a simple invoice for testing');
// Initialize with default values
this.id = `PDF-${Date.now()}`;
this.invoiceId = this.id;
this.invoiceType = 'debitnote';
this.type = 'invoice';
this.date = Date.now();
this.status = 'invoice';
this.subject = 'PDF Invoice';
this.from = {
type: 'company',
name: 'PDF Seller',
description: '',
address: {
streetName: '',
houseNumber: '0',
city: '',
country: '',
postalCode: ''
},
status: 'active',
foundedDate: {
year: 2000,
month: 1,
day: 1
},
registrationDetails: {
vatId: '',
registrationId: '',
registrationName: ''
}
};
this.to = {
type: 'company',
name: 'PDF Buyer',
description: '',
address: {
streetName: '',
houseNumber: '0',
city: '',
country: '',
postalCode: ''
},
status: 'active',
foundedDate: {
year: 2000,
month: 1,
day: 1
},
registrationDetails: {
vatId: '',
registrationId: '',
registrationName: ''
}
};
this.incidenceId = this.id;
this.language = 'en';
this.items = [];
this.dueInDays = 30;
this.reverseCharge = false;
this.currency = 'EUR';
this.notes = ['PDF without embedded XML'];
this.objectActions = [];
this.detectedFormat = InvoiceFormat.FACTURX;
} else {
// Load the extracted XML
await this.loadXml(xmlContent, validate);
// No XML found in PDF
console.warn('No XML found in PDF');
throw new Error('No XML found in PDF');
}
// Load the extracted XML
await this.loadXml(xmlContent, validate);
return this;
} catch (error) {
console.error('Error loading PDF:', error);