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

namespace Bp.Sync.Domain.Elastics.FcBusinesses
{
    public class InboundStatisticElastic : ElasticBaseEntityWithKey<long>
    {
        public long UUID { get; set; }
        public string InventoryCode { get; set; }
        public long ProductId { get; set; }
        public long ProductInboundId { get; set; }
        public long BillId { get; set; }
        public int BranchId { get; set; }
        public int InboundUnitId { get; set; }
        public decimal InboundQuantity { get; set; }
        public decimal InboundBaseUnitQuantity { get; set; }
        public decimal InboundCost { get; set; }
        public decimal InboundPrice { get; set; }
        public decimal InboundBaseUnitPrice { get; set; }
        public decimal InboundBaseUnitCost { get; set; }
        public decimal InboundWholesalePrice { get; set; }
        public float InboundDiscount { get; set; }
        public float InboundTax { get; set; }

        public decimal InboundTotalCost
        {
            get
            {
                var a = InboundCost * InboundQuantity;
                if (InboundDiscount > 0) a *= 1 - (decimal)InboundDiscount / 100m;
                if (InboundTax > 0) a *= 1 + (decimal)InboundTax / 100m;
                return a;
            }
        }

        public decimal InboundTotalPrice => InboundPrice * InboundQuantity;

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

        public int PositionId { get; set; }
        public long ProductShipmentId { get; set; }
        public long HeadQuarterOutboundId { get; set; }
        public long ProductStorageId { get; set; }

        //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; }
    }
}