using Books.Api.EventFlow.ReadModels;

namespace Books.Api.EventFlow.Repositories;

public interface IBankTransactionRepository
{
    /// <summary>
    /// Get all pending (unbooked) transactions for a company.
    /// Used by Hurtig Bogføring to display transactions awaiting booking.
    /// </summary>
    Task<IReadOnlyList<BankTransactionDto>> GetPendingByCompanyIdAsync(
        string companyId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Get all transactions for a company, optionally filtered by status.
    /// </summary>
    Task<IReadOnlyList<BankTransactionDto>> GetByCompanyIdAsync(
        string companyId,
        string? status = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Get a single transaction by ID.
    /// </summary>
    Task<BankTransactionDto?> GetByIdAsync(
        string id,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Check if a transaction with the given external ID already exists.
    /// Used during sync to avoid duplicates.
    /// </summary>
    Task<bool> ExistsAsync(
        string companyId,
        string externalId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Insert a new bank transaction.
    /// </summary>
    Task InsertAsync(
        BankTransactionDto transaction,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Insert multiple bank transactions in a batch.
    /// </summary>
    Task InsertBatchAsync(
        IEnumerable<BankTransactionDto> transactions,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Update transaction status (e.g., pending -> booked).
    /// </summary>
    Task UpdateStatusAsync(
        string id,
        string status,
        string? journalEntryDraftId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Get transactions for a specific bank account.
    /// </summary>
    Task<IReadOnlyList<BankTransactionDto>> GetByBankAccountIdAsync(
        string bankAccountId,
        string? status = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Check if any transactions exist for a specific bank account.
    /// </summary>
    Task<bool> HasAnyAsync(string bankAccountId, CancellationToken cancellationToken = default);
}
