86 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { business, finance } from '@tsclass/tsclass';
 | |
| 
 | |
| /**
 | |
|  * Supported electronic invoice formats
 | |
|  */
 | |
| export 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' // FatturaPA (Italian e-invoice format)
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * 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';
 | |
| 
 | |
| /**
 | |
|  * Describes a validation level for invoice validation
 | |
|  */
 | |
| export enum ValidationLevel {
 | |
|   SYNTAX = 'syntax', // Schema validation only
 | |
|   SEMANTIC = 'semantic', // Semantic validation (field types, required fields, etc.)
 | |
|   BUSINESS = 'business' // Business rule validation
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * Describes a validation error
 | |
|  */
 | |
| export interface ValidationError {
 | |
|   code: string; // Error code (e.g. "BR-16")
 | |
|   message: string; // Error message
 | |
|   location?: string; // XPath or location in the document
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * Result of a validation operation
 | |
|  */
 | |
| export interface ValidationResult {
 | |
|   valid: boolean; // Overall validation result
 | |
|   errors: ValidationError[]; // List of validation errors
 | |
|   level: ValidationLevel; // The level that was validated
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * Options for the XInvoice class
 | |
|  */
 | |
| export interface XInvoiceOptions {
 | |
|   validateOnLoad?: boolean; // Whether to validate when loading an invoice
 | |
|   validationLevel?: ValidationLevel; // Level of validation to perform
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * Interface for validator implementations
 | |
|  */
 | |
| export interface IValidator {
 | |
|   validate(level?: ValidationLevel): ValidationResult;
 | |
|   isValid(): boolean;
 | |
|   getValidationErrors(): ValidationError[];
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * PDF interface
 | |
|  */
 | |
| export interface IPdf {
 | |
|   name: string;
 | |
|   id: string;
 | |
|   metadata: {
 | |
|     textExtraction: string;
 | |
|   };
 | |
|   buffer: Uint8Array;
 | |
| }
 | |
| 
 | |
| // Re-export types from tsclass for convenience
 | |
| export type { TInvoice } from '@tsclass/tsclass/dist_ts/finance';
 | |
| export type { TCreditNote } from '@tsclass/tsclass/dist_ts/finance';
 | |
| export type { TDebitNote } from '@tsclass/tsclass/dist_ts/finance';
 | |
| export type { TContact } from '@tsclass/tsclass/dist_ts/business';
 | |
| export type { TLetterEnvelope } from '@tsclass/tsclass/dist_ts/business';
 | |
| export type { TDocumentEnvelope } from '@tsclass/tsclass/dist_ts/business';
 |