using Books.Api.EventFlow.ReadModels;

namespace Books.Api.EventFlow.Repositories;

public interface IOrderRepository
{
    Task<OrderReadModelDto?> GetByIdAsync(string id, CancellationToken cancellationToken = default);

    Task<IReadOnlyList<OrderReadModelDto>> GetByCompanyIdAsync(
        string companyId,
        string? status = null,
        CancellationToken cancellationToken = default);

    Task<IReadOnlyList<OrderReadModelDto>> GetByCustomerIdAsync(
        string customerId,
        string? status = null,
        CancellationToken cancellationToken = default);

    Task<IReadOnlyList<OrderReadModelDto>> GetByFiscalYearIdAsync(
        string fiscalYearId,
        string? status = null,
        CancellationToken cancellationToken = default);

    Task<OrderReadModelDto?> GetByOrderNumberAsync(
        string companyId,
        string orderNumber,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Gets orders that can be converted to invoices (status = confirmed).
    /// </summary>
    Task<IReadOnlyList<OrderReadModelDto>> GetConfirmedOrdersAsync(
        string companyId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Gets orders linked to a specific invoice.
    /// </summary>
    Task<OrderReadModelDto?> GetByInvoiceIdAsync(
        string invoiceId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Gets the next order number for a company within a year.
    /// </summary>
    Task<int> GetNextOrderNumberAsync(
        string companyId,
        int year,
        CancellationToken cancellationToken = default);
}
