export interface JournalEntryLine {
  id?: number;
  account_id: number;
  debit: number;
  credit: number;
  currency_id?: number | null;
  exchange_rate?: number | null;
  cost_center_id?: number | null;
  description?: string | null;
  account?: {
    id: number;
    code: string;
    name: string;
    name_ar: string;
    name_en: string;
  };
  currency?: {
    id: number;
    code: string;
    symbol: string;
  } | null;
  cost_center?: {
    id: number;
    code: string;
    name: string;
    name_ar: string;
  } | null;
}

export interface JournalEntry {
  id: number;
  entry_number: string | null;
  date: string;
  reference?: string | null;
  description?: string | null;
  status: 'draft' | 'approved' | 'posted' | 'reversed';
  total_debit: number | string;
  total_credit: number | string;
  source_type?: string | null;
  source_id?: number | null;
  fiscal_year_id?: number | null;
  fiscal_period_id?: number | null;
  branch_id?: number | null;
  created_by?: number;
  approved_by?: number | null;
  posted_by?: number | null;
  lines: JournalEntryLine[];
  fiscal_year?: { id: number; name: string } | null;
  fiscal_period?: { id: number; name: string } | null;
  created_at?: string;
  updated_at?: string;
}

export interface CreateJournalEntry {
  date: string;
  reference?: string;
  description?: string;
  fiscal_year_id?: number | null;
  lines: {
    account_id: number;
    debit: number;
    credit: number;
    currency_id?: number | null;
    exchange_rate?: number | null;
    cost_center_id?: number | null;
    description?: string;
  }[];
}

export interface UpdateJournalEntry extends Partial<CreateJournalEntry> {}
