@fin.cx/einvoice
Version:
A TypeScript module for creating, manipulating, and embedding XML data within PDF files specifically tailored for electronic invoice (einvoice) packages.
88 lines (87 loc) • 2.2 kB
TypeScript
export interface IEInvoice {
InvoiceNumber: string;
DateIssued: string;
Seller: IParty;
Buyer: IParty;
Items: IInvoiceItem[];
TotalAmount: number;
}
export interface IParty {
Name: string;
Address: IAddress;
Contact: IContact;
TaxRegistration?: string;
}
export interface IAddress {
Street: string;
City: string;
PostalCode: string;
Country: string;
}
export interface IContact {
Email: string;
Phone: string;
}
export interface IInvoiceItem {
Description: string;
Quantity: number;
UnitPrice: number;
TotalPrice: number;
}
/**
* Supported electronic invoice formats
*/
export declare enum InvoiceFormat {
UNKNOWN = "unknown",
UBL = "ubl",// Universal Business Language
CII = "cii",// Cross-Industry Invoice
ZUGFERD = "zugferd",// ZUGFeRD (German e-invoice format)
FACTURX = "facturx",// Factur-X (French e-invoice format)
XRECHNUNG = "xrechnung",// XRechnung (German e-invoice implementation of EN16931)
FATTURAPA = "fatturapa"
}
/**
* Formats supported for export operations
* This is a subset of InvoiceFormat that only includes formats
* that can be generated and embedded in PDFs
*/
export type ExportFormat = 'facturx' | 'zugferd' | 'xrechnung' | 'ubl' | 'cii';
/**
* Describes a validation level for invoice validation
*/
export declare enum ValidationLevel {
SYNTAX = "syntax",// Schema validation only
SEMANTIC = "semantic",// Semantic validation (field types, required fields, etc.)
BUSINESS = "business"
}
/**
* Describes a validation error
*/
export interface ValidationError {
code: string;
message: string;
location?: string;
}
/**
* Result of a validation operation
*/
export interface ValidationResult {
valid: boolean;
errors: ValidationError[];
level: ValidationLevel;
}
/**
* Options for the EInvoice class
*/
export interface EInvoiceOptions {
validateOnLoad?: boolean;
validationLevel?: ValidationLevel;
}
/**
* Interface for validator implementations
*/
export interface IValidator {
validate(level?: ValidationLevel): ValidationResult;
isValid(): boolean;
getValidationErrors(): ValidationError[];
}