update
This commit is contained in:
@ -8,8 +8,9 @@ import {
|
||||
PDFArray,
|
||||
PDFString,
|
||||
} from 'pdf-lib';
|
||||
import { FacturXEncoder } from './classes.encoder.js';
|
||||
import { ZUGFeRDXmlDecoder } from './classes.decoder.js';
|
||||
import { FacturXEncoder } from './formats/facturx.encoder.js';
|
||||
import { DecoderFactory } from './formats/decoder.factory.js';
|
||||
import { BaseDecoder } from './formats/base.decoder.js';
|
||||
|
||||
export class XInvoice {
|
||||
private xmlString: string;
|
||||
@ -17,7 +18,7 @@ export class XInvoice {
|
||||
private pdfUint8Array: Uint8Array;
|
||||
|
||||
private encoderInstance = new FacturXEncoder();
|
||||
private decoderInstance: ZUGFeRDXmlDecoder;
|
||||
private decoderInstance: BaseDecoder;
|
||||
|
||||
constructor() {
|
||||
// Decoder will be initialized when we have XML data
|
||||
@ -36,8 +37,8 @@ export class XInvoice {
|
||||
// Store the XML string
|
||||
this.xmlString = xmlString;
|
||||
|
||||
// Initialize the decoder with the XML string
|
||||
this.decoderInstance = new ZUGFeRDXmlDecoder(xmlString);
|
||||
// Initialize the decoder with the XML string using the factory
|
||||
this.decoderInstance = DecoderFactory.createDecoder(xmlString);
|
||||
}
|
||||
|
||||
public async addLetterData(letterData: plugins.tsclass.business.ILetter): Promise<void> {
|
||||
@ -156,7 +157,7 @@ export class XInvoice {
|
||||
|
||||
// Initialize the decoder with the XML string if needed
|
||||
if (!this.decoderInstance) {
|
||||
this.decoderInstance = new ZUGFeRDXmlDecoder(xmlContent);
|
||||
this.decoderInstance = DecoderFactory.createDecoder(xmlContent);
|
||||
}
|
||||
|
||||
// Validate the XML format
|
||||
@ -226,7 +227,7 @@ export class XInvoice {
|
||||
|
||||
try {
|
||||
// Initialize the decoder with XML content if not already done
|
||||
this.decoderInstance = new ZUGFeRDXmlDecoder(xmlContent);
|
||||
this.decoderInstance = DecoderFactory.createDecoder(xmlContent);
|
||||
|
||||
// First, attempt to identify the XML format
|
||||
const format = this.identifyXmlFormat(xmlContent);
|
||||
|
Reference in New Issue
Block a user