import { createEntityHook } from './useEntityBase';

export type JournalHeaderRead = {
  id: string;
  journal_number: string;
  journal_date?: string;
  description?: string | null;
  source: string;
  reference_type?: string | null;
  reference_id?: string | null;
  status: string;
  fiscal_period_id?: string | null;
  branch_id?: string | null;
  created_by?: string;
  posted_by?: string | null;
  reversal_of_id?: string | null;
  updated_at?: string;
  posted_at: string | null;
  created_at: string;
  total_debit?: number | string | null;
  total_credit?: number | string | null;
  lines: JournalLineRead[];
};

export type JournalLineRead = {
  id: string;
  journal_header_id: string;
  line_order: number;
  entry_type: "debit" | "credit" | string;
  account_id: string;
  amount: number | string;
  gold_grams?: number | string | null;
  currency_id?: string | null;
  purity_id?: string | null;
  description?: string | null;
  created_at: string;
  updated_at: string;
};

import { ENDPOINTS } from '@/constants/endpoints';

export const useLedger = createEntityHook<JournalHeaderRead, any, any>('LEDGER', ENDPOINTS.LEDGER.LIST);
