import { LedgerEntry } from '@/domain/aggregates';
import { LedgerEntryType, AssetType } from '@/domain/value-objects';
import { RepositorySaveOptions } from '@/infrastructure/persistence/unit-of-work';

export interface LedgerFilters {
  entryType?: LedgerEntryType;
  assetType?: AssetType;
  startDate?: Date;
  endDate?: Date;
}

export interface Pagination {
  page: number;
  pageSize: number;
}

export interface PaginatedResult<T> {
  data: T[];
  total: number;
  page: number;
  pageSize: number;
  totalPages: number;
}

export interface ILedgerEntryRepository {
  save(entry: LedgerEntry, options?: RepositorySaveOptions): Promise<LedgerEntry>;
  saveAll(entries: LedgerEntry[], options?: RepositorySaveOptions): Promise<void>;
  findByUserId(userId: bigint, filters?: LedgerFilters, pagination?: Pagination): Promise<PaginatedResult<LedgerEntry>>;
  findByAccountSequence(accountSequence: string, filters?: LedgerFilters, pagination?: Pagination): Promise<PaginatedResult<LedgerEntry>>;
  findByRefOrderId(refOrderId: string): Promise<LedgerEntry[]>;
  findByRefTxHash(refTxHash: string): Promise<LedgerEntry[]>;
}

export const LEDGER_ENTRY_REPOSITORY = Symbol('ILedgerEntryRepository');
