using System.ComponentModel.DataAnnotations;
using ERPCore.Domain.Enums;

namespace ERPCore.Dtos.Procurement;

// Responses (docs/11 §3.1) ------------------------------------------------------

public sealed record RequisitionLineDto(int ReqLineId, int ItemId, decimal Qty, DateOnly? RequiredBy);

public sealed record RequisitionDto(
    int RequisitionId, string DocNo, RequisitionStatus Status, int RequestedBy,
    DateTime CreatedAt, IReadOnlyList<RequisitionLineDto> Lines);

public sealed record RequisitionSummaryDto(
    int RequisitionId, string DocNo, RequisitionStatus Status, int RequestedBy, DateTime CreatedAt, int LineCount);

// Requests — server sets docNo, status, requestedBy (audit actor), timestamps ----

public sealed class CreateRequisitionLineInput
{
    [Required] public int ItemId { get; set; }
    [Range(0.0001, double.MaxValue)] public decimal Qty { get; set; }
    public DateOnly? RequiredBy { get; set; }
}

public sealed class CreateRequisitionRequest
{
    [Required, MinLength(1)] public List<CreateRequisitionLineInput> Lines { get; set; } = new();
}
