using CashLineERP.SharedKernel.Workflow;

namespace CashLineERP.Domain.Procurement;

public sealed class PurchaseRequisitionLine
{
    public long Id { get; private set; }

    public long PurchaseRequisitionId { get; private set; }

    public int LineNumber { get; private set; }

    public long ItemId { get; private set; }

    public decimal RequestedQuantity { get; private set; }

    public string UnitOfMeasureCode { get; private set; } = string.Empty;

    public DateOnly? NeedByDate { get; private set; }

    public decimal? EstimatedUnitPrice { get; private set; }

    public long StatusId { get; private set; } = WorkflowStatusSeedIds.Draft;

    public string? Notes { get; private set; }

    public PurchaseRequisitionLine(
        long requisitionId,
        int lineNumber,
        long itemId,
        decimal requestedQuantity,
        string unitOfMeasureCode,
        decimal? estimatedUnitPrice,
        DateOnly? needByDate,
        string? notes)
    {
        PurchaseRequisitionId = requisitionId;
        LineNumber = lineNumber;
        ItemId = itemId;
        RequestedQuantity = requestedQuantity;
        UnitOfMeasureCode = unitOfMeasureCode;
        EstimatedUnitPrice = estimatedUnitPrice;
        NeedByDate = needByDate;
        Notes = notes;
    }

    private PurchaseRequisitionLine()
    {
    }

    internal void AttachToRequisition(long requisitionId)
    {
        PurchaseRequisitionId = requisitionId;
    }
}
