UNPKG

@fin.cx/einvoice

Version:

A TypeScript module for creating, manipulating, and embedding XML data within PDF files specifically tailored for electronic invoice (einvoice) packages.

62 lines (61 loc) 2.22 kB
import { BaseDecoder } from '../base/base.decoder.js'; import type { TInvoice, TCreditNote, TDebitNote } from '../../interfaces/common.js'; import { CIIProfile } from './cii.types.js'; import { xpath } from '../../plugins.js'; /** * Base decoder for CII-based invoice formats */ export declare abstract class CIIBaseDecoder extends BaseDecoder { protected doc: Document; protected namespaces: Record<string, string>; protected select: xpath.XPathSelect; protected profile: CIIProfile; constructor(xml: string, skipValidation?: boolean); /** * Decodes CII XML into a TInvoice object * @returns Promise resolving to a TInvoice object */ decode(): Promise<TInvoice>; /** * Detects the CII profile from the XML */ protected detectProfile(): void; /** * Decodes a CII credit note * @returns Promise resolving to a TCreditNote object */ protected abstract decodeCreditNote(): Promise<TCreditNote>; /** * Decodes a CII debit note (invoice) * @returns Promise resolving to a TDebitNote object */ protected abstract decodeDebitNote(): Promise<TDebitNote>; /** * Gets a text value from an XPath expression * @param xpath XPath expression * @param context Optional context node * @returns Text value or empty string if not found */ protected getText(xpathExpr: string, context?: Node): string; /** * Gets a number value from an XPath expression * @param xpath XPath expression * @param context Optional context node * @returns Number value or 0 if not found or not a number */ protected getNumber(xpathExpr: string, context?: Node): number; /** * Gets a date value from an XPath expression * @param xpath XPath expression * @param context Optional context node * @returns Date timestamp or current time if not found or invalid */ protected getDate(xpathExpr: string, context?: Node): number; /** * Checks if a node exists * @param xpath XPath expression * @param context Optional context node * @returns True if node exists */ protected exists(xpathExpr: string, context?: Node): boolean; }