using Bp.Sync.Domain.Elastics.BaseEntities;
using System;
using System.ComponentModel;

namespace Bp.Sync.Domain.Elastics.FcBusinesses.Products
{
    public class FcProductInboundElastic : ElasticBaseEntityWithKey<long>
    {
        public string InventoryCode { get; set; }
        public long ProductId { get; set; }
        public long BillId { get; set; }
        public int BranchId { get; set; }
        public int InboundUnitId { get; set; }
        public decimal InboundQuantity { get; set; }
        public decimal OriginInboundQuantity { get; set; }
        public decimal InboundBaseUnitQuantity { get; set; }
        public decimal OriginInboundBaseUnitQuantity { get; set; }
        public decimal CurrentBaseUnitTotalQuantity { get; set; }
        public int InboundBaseUnitId { get; set; }
        public decimal InboundCost { get; set; }
        public decimal InboundPrice { get; set; }
        public decimal InboundWholesalePrice { get; set; }
        public decimal InboundBaseUnitPrice { get; set; }
        public decimal InboundBaseUnitCost { get; set; }
        public decimal InboundBaseUnitAverageCost { get; set; }
        public decimal TotalCurrentBaseUnitAverageCost { get; set; }
        public float InboundDiscount { get; set; }
        public float InboundTax { get; set; }
        public decimal InboundTotalCost { get; set; }
        public long PositionId { get; set; }
        public long ProductStorageId { get; set; }
        public long ProductShipmentId { get; set; }
        public long HeadQuarterOutboundId { get; set; }
        public int NumberOfEdit { get; set; }
        public ProductInventoryStatus? InboundStatus { get; set; }

        //theem vaof
        public decimal InboundTotalPrice => InboundPrice * InboundQuantity;

        //Lợi nhuận dự kiến
        public decimal InboundRevenue => InboundTotalPrice - InboundTotalCost;

        //them vao bao cao
        public Entities.FcBusinesses.Bills.BillStatus? BillStatus { get; set; }

        public Entities.FcBusinesses.Bills.BillType? BillType { get; set; }
        public DateTimeOffset? BillCreatedTime { get; set; }
        public DateTimeOffset? BillCompletedDate { get; set; }
        public bool? BillIsDeleted { get; set; }
        public int? BillPartnerId { get; set; }
        public int? BillOriginBranchId { get; set; }
        public int? BillDestinationBranchId { get; set; }
    }

    public enum ProductInventoryStatus
    {
        [Description("Tạo mới")]
        Created = 1,

        [Description("Đang xử lý")]
        Processing = 2,

        [Description("Hoàn thành")]
        Done = 3,

        /// <summary>
        /// vận hành > kế toán > kho tổng
        /// </summary>
        [Description("Kho tổng từ chối nhận")]
        WarehouseReject = 4,

        [Description("Vận hành từ chối nhận")]
        OperatorReject = 5,

        [Description("Kế toán từ chối nhận")]
        AccountReject = 6,

        [Description("Nhập lại kho")]
        ReEnterProductOutbound = 7
    }
}