fix(compliance): Improve compliance
This commit is contained in:
@ -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];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user