using ERPCore.Domain.Enums;

namespace ERPCore.Domain.Entities;

public class BundleSale
{
    public int BundleSaleId { get; set; }
    public string BundleNo { get; set; } = string.Empty;
    public DateTime BundleDate { get; set; }
    public int CustomerId { get; set; }
    public Customer? Customer { get; set; }
    public string CustomerSnapshotName { get; set; } = string.Empty;
    public int WarehouseId { get; set; }
    public Warehouse? Warehouse { get; set; }
    public int CashierUserId { get; set; }
    public User? CashierUser { get; set; }
    public int BundleSaleTemplateId { get; set; }
    public BundleSaleTemplate? BundleSaleTemplate { get; set; }
    public string BundleName { get; set; } = string.Empty;
    public string BundleCode { get; set; } = string.Empty;
    public BundleSaleStatus Status { get; set; } = BundleSaleStatus.Draft;
    public decimal ComponentSubtotal { get; set; }
    public decimal BundlePrice { get; set; }
    public decimal MarginAmount { get; set; }
    public decimal DiscountTotal { get; set; }
    public decimal TaxTotal { get; set; }
    public decimal GrandTotal { get; set; }
    public DateTime CreatedAt { get; set; }
    public DateTime? UpdatedAt { get; set; }
    public int ConcurrencyStamp { get; set; }

    /// <summary>Set once this bundle's business date is closed by <see cref="SalesDayEnd"/> — a
    /// closed bundle sale is frozen (no further edits). Same role as <see cref="SalesSlip.DayEndId"/>;
    /// a bundle sale is a cashier document exactly like a sales slip, just priced as a set.</summary>
    public int? DayEndId { get; set; }
    public SalesDayEnd? DayEnd { get; set; }

    public ICollection<BundleSaleLine> Lines { get; set; } = new List<BundleSaleLine>();
}
