// Accounting-related TypeScript interfaces

export type AccountClassification =
    | 'asset'
    | 'liability'
    | 'equity'
    | 'revenue'
    | 'expense';
export type NormalBalance = 'debit' | 'credit';

export type JournalEntryStatus = 'draft' | 'posted' | 'void';
export type JournalEntryLineType = 'debit' | 'credit';

/**
 * Chart of Accounts
 */
export interface Account {
    id: number;
    code: string;
    name: string;
    parent_id: number | null;
    classification: AccountClassification;
    normal_balance: NormalBalance;
    level: number;
    description: string | null;
    is_header: boolean;
    is_active: boolean;
    balance: number;
    currency: string;
    legacy_code: string | null;
    created_at: string | null;
    updated_at: string | null;
    deleted_at: string | null;

    // Relationships
    parent?: Account;
    children?: Account[];
    journal_entry_lines?: JournalEntryLine[];
}

/**
 * Journal Entry (Header)
 */
export interface JournalEntry {
    id: number;
    voucher_number: string;
    transaction_date: string;
    reference_number: string | null;
    description: string | null;
    source_type: string | null;
    source_id: number | null;
    status: JournalEntryStatus;
    posted_at: string | null;
    voided_at: string | null;
    created_at: string | null;
    updated_at: string | null;
    deleted_at: string | null;
    created_by: number | null;
    posted_by: number | null;
    voided_by: number | null;
    total_amount: number;

    // Relationships
    lines?: JournalEntryLine[];
    creator?: {
        id: number;
        name: string;
    };
}

/**
 * Journal Entry Line Item
 */
export interface JournalEntryLine {
    id: number;
    journal_entry_id: number;
    account_id: number;
    description: string | null;
    type: JournalEntryLineType;
    amount: number;
    branch_id: number | null;
    created_at: string | null;
    updated_at: string | null;

    // Relationships
    account?: {
        id: number;
        code: string;
        name: string;
        classification: AccountClassification;
    };
    journal_entry?: JournalEntry;
}

/**
 * Filters
 */
export interface AccountFilters {
    search?: string;
    classification?: AccountClassification;
    is_header?: string;
    is_active?: string;
}

export interface JournalEntryFilters {
    search?: string;
    date_from?: string;
    date_to?: string;
    status?: JournalEntryStatus;
    branch_id?: string;
}
