update
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user