using System.ComponentModel.DataAnnotations;

namespace CartWise.Web.ViewModels.Purchase;

public class PurchaseListViewModel
{
    public List<PurchaseSummaryViewModel> Purchases { get; set; } = [];
}

public class PurchaseSummaryViewModel
{
    public Guid PurchaseId { get; set; }

    public DateTime PurchasedUtc { get; set; }

    public bool IsCompleted { get; set; }

    public decimal? Total { get; set; }

    public int ItemCount { get; set; }
}

public class PurchaseDetailsViewModel
{
    public Guid PurchaseId { get; set; }

    public DateTime PurchasedUtc { get; set; }

    public bool IsCompleted { get; set; }

    public decimal? Subtotal { get; set; }

    public decimal? Tax { get; set; }

    public decimal? Total { get; set; }

    public List<PurchaseItemViewModel> Items { get; set; } = [];

    public AddPurchaseItemViewModel NewItem { get; set; } = new();
}

public class PurchaseItemViewModel
{
    public string Description { get; set; } = string.Empty;

    public decimal Quantity { get; set; }

    public string? Unit { get; set; }

    public decimal LinePrice { get; set; }
}

public class AddPurchaseItemViewModel
{
    [Required]
    [Display(Name = "Item")]
    [StringLength(240, MinimumLength = 1)]
    public string Description { get; set; } = string.Empty;

    [Range(0.001, 100000)]
    public decimal Quantity { get; set; } = 1m;

    [StringLength(32)]
    public string? Unit { get; set; }

    [Required]
    [Range(0, 100000)]
    [Display(Name = "Price")]
    public decimal LinePrice { get; set; }
}
