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

@ -12,12 +12,8 @@ export abstract class UBLBaseEncoder extends BaseEncoder {
* @returns UBL XML string
*/
public async encode(invoice: TInvoice): Promise<string> {
// Determine if it's a credit note or debit note
if (invoice.invoiceType === 'creditnote') {
return this.encodeCreditNote(invoice as TCreditNote);
} else {
return this.encodeDebitNote(invoice as TDebitNote);
}
// TInvoice is always an invoice, treat it as debit note for encoding
return this.encodeDebitNote(invoice as unknown as TDebitNote);
}
/**
@ -53,7 +49,15 @@ export abstract class UBLBaseEncoder extends BaseEncoder {
* @returns Formatted date string
*/
protected formatDate(timestamp: number): string {
// Ensure timestamp is valid
if (!timestamp || isNaN(timestamp)) {
timestamp = Date.now();
}
const date = new Date(timestamp);
// Check if date is valid
if (isNaN(date.getTime())) {
return new Date().toISOString().split('T')[0];
}
return date.toISOString().split('T')[0];
}
}