fix(compliance): Improve compliance

This commit is contained in:
2025-05-26 10:17:50 +00:00
parent 113ae22c42
commit e7c3a774a3
26 changed files with 2435 additions and 2010 deletions

View File

@ -17,8 +17,8 @@ export class ZUGFeRDDecoder extends CIIBaseDecoder {
// Create a credit note with the common data
return {
...commonData,
invoiceType: 'creditnote'
} as TCreditNote;
accountingDocType: 'creditnote' as const
} as unknown as TCreditNote;
}
/**
@ -32,8 +32,8 @@ export class ZUGFeRDDecoder extends CIIBaseDecoder {
// Create a debit note with the common data
return {
...commonData,
invoiceType: 'debitnote'
} as TDebitNote;
accountingDocType: 'debitnote' as const
} as unknown as TDebitNote;
}
/**
@ -46,7 +46,8 @@ export class ZUGFeRDDecoder extends CIIBaseDecoder {
// Extract issue date
const issueDateStr = this.getText('//ram:IssueDateTime/udt:DateTimeString');
const issueDate = issueDateStr ? new Date(issueDateStr).getTime() : Date.now();
const issueDateFormat = this.getText('//ram:IssueDateTime/udt:DateTimeString/@format');
const issueDate = this.parseCIIDate(issueDateStr, issueDateFormat);
// Extract seller information
const seller = this.extractParty('//ram:SellerTradeParty');
@ -76,10 +77,12 @@ export class ZUGFeRDDecoder extends CIIBaseDecoder {
// Create the common invoice data
return {
type: 'invoice',
type: 'accounting-doc' as const,
accountingDocType: 'invoice' as const,
id: invoiceId,
accountingDocId: invoiceId,
date: issueDate,
status: 'invoice',
accountingDocStatus: 'issued' as const,
versionInfo: {
type: 'final',
version: '1.0.0'
@ -95,8 +98,7 @@ export class ZUGFeRDDecoder extends CIIBaseDecoder {
currency: currencyCode as finance.TCurrency,
notes: notes,
deliveryDate: issueDate,
objectActions: [],
invoiceType: 'debitnote' // Default to debit note, will be overridden in decode methods
objectActions: []
};
}
@ -129,7 +131,7 @@ export class ZUGFeRDDecoder extends CIIBaseDecoder {
houseNumber: houseNumber,
city: city,
postalCode: postalCode,
country: country
countryCode: country
};
// Extract VAT ID
@ -158,8 +160,8 @@ export class ZUGFeRDDecoder extends CIIBaseDecoder {
* Extracts invoice items from ZUGFeRD XML
* @returns Array of invoice items
*/
private extractItems(): finance.TInvoiceItem[] {
const items: finance.TInvoiceItem[] = [];
private extractItems(): finance.TAccountingDocItem[] {
const items: finance.TAccountingDocItem[] = [];
// Get all item nodes
const itemNodes = this.select('//ram:IncludedSupplyChainTradeLineItem', this.doc);

View File

@ -27,7 +27,7 @@ export class ZUGFeRDEncoder extends CIIBaseEncoder {
this.setDocumentTypeCode(xmlDoc, '381');
// Add common invoice data
this.addCommonInvoiceData(xmlDoc, creditNote);
this.addCommonInvoiceData(xmlDoc, creditNote as unknown as TInvoice);
// Serialize to string
return new XMLSerializer().serializeToString(xmlDoc);
@ -46,7 +46,7 @@ export class ZUGFeRDEncoder extends CIIBaseEncoder {
this.setDocumentTypeCode(xmlDoc, '380');
// Add common invoice data
this.addCommonInvoiceData(xmlDoc, debitNote);
this.addCommonInvoiceData(xmlDoc, debitNote as unknown as TInvoice);
// Serialize to string
return new XMLSerializer().serializeToString(xmlDoc);

View File

@ -32,8 +32,8 @@ export class ZUGFeRDV1Decoder extends CIIBaseDecoder {
// Create a credit note with the common data
return {
...commonData,
invoiceType: 'creditnote'
} as TCreditNote;
accountingDocType: 'creditnote' as const
} as unknown as TCreditNote;
}
/**
@ -47,8 +47,8 @@ export class ZUGFeRDV1Decoder extends CIIBaseDecoder {
// Create a debit note with the common data
return {
...commonData,
invoiceType: 'debitnote'
} as TDebitNote;
accountingDocType: 'debitnote' as const
} as unknown as TDebitNote;
}
/**
@ -61,7 +61,8 @@ export class ZUGFeRDV1Decoder extends CIIBaseDecoder {
// Extract issue date
const issueDateStr = this.getText('//ram:IssueDateTime/udt:DateTimeString');
const issueDate = issueDateStr ? new Date(issueDateStr).getTime() : Date.now();
const issueDateFormat = this.getText('//ram:IssueDateTime/udt:DateTimeString/@format');
const issueDate = this.parseCIIDate(issueDateStr, issueDateFormat);
// Extract seller information
const seller = this.extractParty('//ram:SellerTradeParty');
@ -91,10 +92,12 @@ export class ZUGFeRDV1Decoder extends CIIBaseDecoder {
// Create the common invoice data
return {
type: 'invoice',
type: 'accounting-doc' as const,
accountingDocType: 'invoice' as const,
id: invoiceId,
accountingDocId: invoiceId,
date: issueDate,
status: 'invoice',
accountingDocStatus: 'issued' as const,
versionInfo: {
type: 'final',
version: '1.0.0'
@ -110,8 +113,7 @@ export class ZUGFeRDV1Decoder extends CIIBaseDecoder {
currency: currencyCode as finance.TCurrency,
notes: notes,
deliveryDate: issueDate,
objectActions: [],
invoiceType: 'debitnote' // Default to debit note, will be overridden in decode methods
objectActions: []
};
}
@ -144,7 +146,7 @@ export class ZUGFeRDV1Decoder extends CIIBaseDecoder {
houseNumber: houseNumber,
city: city,
postalCode: postalCode,
country: country
countryCode: country
};
// Extract VAT ID
@ -173,8 +175,8 @@ export class ZUGFeRDV1Decoder extends CIIBaseDecoder {
* Extracts invoice items from ZUGFeRD v1 XML
* @returns Array of invoice items
*/
private extractItems(): finance.TInvoiceItem[] {
const items: finance.TInvoiceItem[] = [];
private extractItems(): finance.TAccountingDocItem[] {
const items: finance.TAccountingDocItem[] = [];
// Get all item nodes
const itemNodes = this.select('//ram:IncludedSupplyChainTradeLineItem', this.doc);