using ERPCore.Common.Http;
using ERPCore.Domain.Enums;
using ERPCore.Dtos.Common;
using ERPCore.Dtos.Procurement;

namespace ERPCore.Services.Interfaces;

/// <summary>Purchase-order business logic (docs/11 §3.3; FR-PROC-03..07).</summary>
public interface IPurchaseOrderService
{
    Task<PagedResponse<PurchaseOrderSummaryDto>> ListAsync(
        PageQuery query, PurchaseOrderStatus? status, int? vendorId, CancellationToken ct = default);

    Task<ETagged<PurchaseOrderDto>?> GetAsync(int poId, CancellationToken ct = default);
    Task<ETagged<PurchaseOrderDto>> CreateAsync(CreatePurchaseOrderRequest request, CancellationToken ct = default);
    Task<ETagged<PurchaseOrderDto>> UpdateAsync(int poId, UpdatePurchaseOrderRequest request, uint expectedRowVersion, CancellationToken ct = default);
    Task<PurchaseOrderDto> ApproveAsync(int poId, CancellationToken ct = default);
    Task<PurchaseOrderDto> CancelAsync(int poId, string? reason, CancellationToken ct = default);

    /// <summary>Submit a Draft PO (Draft → Approved). 409 PO_NOT_EDITABLE if not Draft.</summary>
    Task<PurchaseOrderDto> SubmitAsync(int poId, CancellationToken ct = default);

    /// <summary>Delete a PO — permitted only while Draft, else 409 PO_NOT_EDITABLE.</summary>
    Task DeleteAsync(int poId, CancellationToken ct = default);
}
