namespace Books.Api.Invoicing.Services;

/// <summary>
/// Service for generating sequential numbers for customers, invoices, and credit notes.
/// Uses atomic PostgreSQL UPSERT for thread-safe number generation.
/// Invoices and credit notes use year-based sequences per Momsloven §52.
/// </summary>
public interface IInvoiceNumberService
{
    /// <summary>
    /// Gets the next customer number for a company (e.g., "0001", "0002").
    /// </summary>
    Task<string> GetNextCustomerNumberAsync(string companyId, CancellationToken cancellationToken = default);

    /// <summary>
    /// Gets the next invoice number for a company and year (e.g., "INV-2024-0001").
    /// Invoice numbers reset at the start of each year per Momsloven §52.
    /// </summary>
    Task<string> GetNextInvoiceNumberAsync(string companyId, int year, CancellationToken cancellationToken = default);

    /// <summary>
    /// Gets the next credit note number for a company and year (e.g., "CN-2024-0001").
    /// Credit note numbers reset at the start of each year.
    /// </summary>
    Task<string> GetNextCreditNoteNumberAsync(string companyId, int year, CancellationToken cancellationToken = default);
}
