using ERPCore.Infra.Gl;
using ERPCore.Services.Gl;

namespace ERPCore.Services.Interfaces;

/// <summary>
/// Single entry point into the external General Ledger service — the one function
/// used both by <see cref="ERPCore.Controllers.GeneralLedgerController"/> (frontend
/// requests, forwarded verbatim) and by other ERPCore services that post directly to
/// GL (docs/12-GENERAL-LEDGER-INTEGRATION.md §5/§6). <see cref="ForwardAsync"/> stays a
/// byte-for-byte passthrough; the three typed methods below are the first internal
/// callers (GRN receipt + payment posting) and model only what those flows need.
/// </summary>
public interface IGeneralLedgerService
{
    Task<GeneralLedgerResponse> ForwardAsync(
        HttpMethod method, string path, string? queryString, string? contentType, Stream? body, CancellationToken ct);

    /// <summary>Creates and posts a balanced journal entry. Throws <see cref="ERPCore.System.Errors.DomainException"/> on rejection/unreachability.</summary>
    Task<GlJournalEntryResult> PostJournalEntryAsync(GlJournalEntryRequest request, CancellationToken ct);

    /// <summary>Resolves the accounting period covering <paramref name="date"/>.</summary>
    Task<GlPeriod> GetPeriodByDateAsync(DateOnly date, CancellationToken ct);

    /// <summary>Lists GL's cash and bank accounts (default: both types).</summary>
    Task<IReadOnlyList<GlBankAccount>> ListBankAccountsAsync(CancellationToken ct);
}
