/**
 * Country adapter type contract — system-i18n.
 *
 * These types encode the legal/fiscal requirements per country. The `CountryAdapter`
 * interface provides a synchronous `getVatRate(date)` so consuming code (invoice
 * calculation, PDF rendering) never needs to await inside a tight loop.
 *
 * NOTE: No DB or React imports allowed here — pure types only.
 */

export type Locale = 'en' | 'he'
export const SUPPORTED_LOCALES: readonly Locale[] = ['en', 'he'] as const

export interface InvoiceRequirements {
  /** IL: business must show its tax/VAT ID on every invoice */
  requiresTaxId: boolean
  /** "ע.מ / ח.פ" for IL, "Tax ID" otherwise */
  taxIdLabel: string
  /** IL law requires sequential invoice numbering with no gaps */
  requiresSequentialNumbering: boolean
  /** IL allows 0% VAT for zero-rated / exempt transactions */
  allowsVatExemptZeroRate: boolean
  /** IL: 7 years retention; EU: 10 years; etc. */
  retentionYears: number
}

export interface CountryAdapter {
  /** ISO 3166-1 alpha-2, e.g. "IL" */
  code: string
  name: string
  /** ISO 4217, e.g. "ILS" */
  defaultCurrency: string
  /** IANA timezone string, e.g. "Asia/Jerusalem" */
  defaultTimezone: string
  /**
   * Returns the VAT rate as a decimal (e.g. 0.18 for 18%) effective on `date`.
   * Synchronous — implementations must preload history at adapter construction.
   */
  getVatRate(date: Date): number
  /** Localised VAT label: "מע\"מ" for IL, "VAT" for others */
  vatLabel: string
  invoiceRequirements: InvoiceRequirements
}
