using ERPCore.Dtos.Audit;
using ERPCore.Dtos.Common;
using ERPCore.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;

namespace ERPCore.Controllers;

/// <summary>
/// Read-only GL-ready journal stubs (FR-STK-13; consumed by the Accounting phase).
/// Data only — no posting in Phase 1.
/// </summary>
[Route("api/v1/journal-entries")]
public sealed class JournalEntriesController : ApiControllerBase
{
    private readonly IAuditService _audit;

    public JournalEntriesController(IAuditService audit) => _audit = audit;

    [HttpGet]
    [ProducesResponseType(typeof(PagedResponse<JournalEntryStubDto>), StatusCodes.Status200OK)]
    public async Task<ActionResult<PagedResponse<JournalEntryStubDto>>> List(
        [FromQuery] string? sourceDocType, [FromQuery] int? sourceDocId, [FromQuery] PageQuery query, CancellationToken ct)
        => Ok(await _audit.ListJournalAsync(sourceDocType, sourceDocId, query, ct));
}
