export interface IXInvoice {
  InvoiceNumber: string;
  DateIssued: string; // Date in ISO 8601 format
  Seller: IParty;
  Buyer: IParty;
  Items: IInvoiceItem[];
  TotalAmount: number;
}

export interface IParty {
  Name: string;
  Address: IAddress;
  Contact: IContact;
}

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 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)
}

/**
 * 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[];
}
