namespace Books.Api.Invoicing.Services;

/// <summary>
/// Service for managing customer sub-ledger accounts.
/// Each customer gets a sub-ledger account (1900-XXXX) under the main Debitorer account (1900).
/// This enables per-customer balance tracking through the existing Ledger system.
/// </summary>
public interface ICustomerSubLedgerService
{
    /// <summary>
    /// Creates a sub-ledger account for a customer (e.g., 1900-0001 for customer 0001).
    /// The account is automatically synced to the Ledger via LedgerAccountSyncSubscriber.
    /// </summary>
    /// <returns>The created account ID</returns>
    Task<string> CreateSubLedgerAccountAsync(
        string companyId,
        string customerNumber,
        string customerName,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Gets the current balance for a customer from their sub-ledger account.
    /// Positive balance = customer owes money (asset).
    /// </summary>
    Task<decimal> GetCustomerBalanceAsync(
        string subLedgerAccountId,
        DateOnly? asOfDate = null,
        CancellationToken cancellationToken = default);
}
