@fin.cx/einvoice
Version:
A TypeScript module for creating, manipulating, and embedding XML data within PDF files specifically tailored for electronic invoice (einvoice) packages.
83 lines (82 loc) • 2.5 kB
TypeScript
import { BaseValidator } from './base.validator.js';
import { ValidationLevel } from '../interfaces.js';
import type { ValidationResult } from '../interfaces.js';
/**
* Validator for UBL (Universal Business Language) invoice format
* Implements validation rules according to EN16931 and UBL 2.1 specification
*/
export declare class UBLValidator extends BaseValidator {
private static NS_INVOICE;
private static NS_CAC;
private static NS_CBC;
private xmlDoc;
private customizationId;
constructor(xml: string);
/**
* Validates the UBL invoice against the specified level
* @param level Validation level
* @returns Validation result
*/
validate(level?: ValidationLevel): ValidationResult;
/**
* Validates XML against schema
* @returns True if schema validation passed
*/
protected validateSchema(): boolean;
/**
* Validates structure of the XML document
* @returns True if structure validation passed
*/
private validateStructure;
/**
* Validates business rules
* @returns True if business rule validation passed
*/
protected validateBusinessRules(): boolean;
/**
* Gets the root node name (Invoice or CreditNote)
* @returns Root node name
*/
private getRootNodeName;
/**
* Detects UBL customization ID from the XML
*/
private detectCustomizationId;
/**
* Checks if invoice is an XRechnung
* @returns True if XRechnung customization ID is present
*/
private isXRechnung;
/**
* Validates amount calculations in the invoice
* @returns True if amount validation passed
*/
private validateAmounts;
/**
* Validates mutually exclusive fields
* @returns True if validation passed
*/
private validateMutuallyExclusiveFields;
/**
* Validates seller VAT identifier requirements
* @returns True if validation passed
*/
private validateSellerVatIdentifier;
/**
* Validates XRechnung specific rules
* @returns True if validation passed
*/
private validateXRechnungRules;
/**
* Helper method to check if a node exists
* @param xpathExpression XPath to check
* @returns True if node exists
*/
private exists;
/**
* Helper method to get a number value from XPath
* @param xpathExpression XPath to get number from
* @returns Number value or NaN if not found
*/
private getNumberValue;
}