using RB_MES_API.Context;
using System.ComponentModel.DataAnnotations;

namespace RB_MES_API.Models.Cloud
{
    /// <summary>
    /// 销售出库单
    /// </summary>
    public class SAL_OUTSTOCK
    {
        /// <summary>
        /// 实体主键（无需填写，保存时自动添加）
        /// </summary>
        public int FID { get; set; }
        /// <summary>
        /// 单据类型  (必填项)
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FBillTypeID { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        /// 单据编号
        /// </summary>
        public string FBillNo { get; set; }
        /// <summary>
        /// 日期  (必填项)
        /// </summary>
        [DataType(DataType.DateTime)]
        public string FDate { get; set; } = DateTime.Now.ToShortDateString();
        /// <summary>
        /// 销售组织  (必填项)
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FSaleOrgId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        /// 客户  (必填项)
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FCustomerID { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        ///  销售部门  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FSaledeptid { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        ///  对应组织  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FCorrespondOrgId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        ///  销售员  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FSalesManId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        ///  发货组织   (必填项)  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FStockOrgId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        ///   库存组   
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FStockerGroupId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        ///   仓管员   
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FStockerId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        /// 收货方地址
        /// </summary>
        public string FReceiveAddress { get; set; }
        /// <summary>
        /// 货主类型    
        /// </summary>
        public string FOwnerTypeIdHead { get; set; }
        /// <summary>
        ///   货主       
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FOwnerIdHead { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",LocalStaticRequest.DefaultOrg}
        };
        /// <summary>
        ///  收货人姓名      
        /// </summary>
        public string FLinkMan { get; set; }
        /// <summary>
        ///  联系电话      
        /// </summary>
        public string FLinkPhone { get; set; }
        /// <summary>
        /// MES唯一标识
        /// </summary>
        [StringLength(36)]
        public string F_SBMI_QUEUE_ID { get; set; }

        public FSubHeadEntity SubHeadEntity { get; set; } = new FSubHeadEntity();
        /// <summary>
        /// 财务信息
        /// </summary>
        public class FSubHeadEntity
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FEntryId { get; set; }
            /// <summary>
            ///   结算币别  (必填项)       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSettleCurrId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            ///   结算组织  (必填项)       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSettleOrgId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            ///   结算方式        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSettleTypeId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            ///    价目表        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FPriceListId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            ///    折扣表        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FDiscountListId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            ///    本位币        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FLocalCurrId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            ///    汇率类型        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FExchangeTypeId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            /// 汇率
            /// </summary>
            public decimal FExchangeRate { get; set; }
        }
        public List<Entity> FEntity { get; set; } = new List<Entity>();
        /// <summary>
        /// 明细信息
        /// </summary>
        public class Entity
        {
            /// <summary>
            /// 源单单号
            /// </summary>
            public string FSrcBillNo { get; set; }

            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FENTRYID { get; set; }
            /// <summary>
            /// 产品类型          
            /// </summary>
            public string FRowType { get; set; } = "Standard";
            /// <summary>
            /// 物料编码   (必填项)   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FMaterialId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 辅助属性   
            /// </summary>
            public Dictionary<string, string> FAuxpropId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            /// 库存单位  (必填项)        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FUnitID { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 应发数量
            /// </summary>
            public decimal FMustQty { get; set; }
            /// <summary>
            /// 基本单位应发数量
            /// </summary>
            public decimal FBaseMustQty { get; set; }
            /// <summary>
            /// 实发数量
            /// </summary>
            public decimal FRealQty { get; set; }
            /// <summary>
            /// 计价数量
            /// </summary>
            public decimal FPriceUnitQty { get; set; }
            /// <summary>
            /// 父项产品        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FParentMatId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 单价
            /// </summary>
            public decimal FPrice { get; set; }
            /// <summary>
            /// 含税单价
            /// </summary>
            public decimal FTaxPrice { get; set; }
            /// <summary>
            ///  是否赠品
            /// </summary>
            public bool FIsFree { get; set; } = false;
            /// <summary>
            /// 税组合        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FTaxCombination { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 税率%
            /// </summary>
            public int FEntryTaxRate { get; set; }
            /// <summary>
            /// 货主类型  (必填项)          
            /// </summary>
            public string FOwnerTypeId { get; set; }
            /// <summary>
            /// 货主  (必填项)        
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FOwnerId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",LocalStaticRequest.DefaultOrg}
        };
            /// <summary>
            /// 仓库   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FStockId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            public StocklocId FStocklocId { get; set; } = new StocklocId();
            /// <summary>
            /// 仓位   
            /// </summary>
            public class StocklocId
            {
                [StringLength(36)]
                public Dictionary<string, string> FSTOCKLOCID__FF100001 { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
                [StringLength(36)]
                public Dictionary<string, string> FSTOCKLOCID__FF100002 { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            }
            /// <summary>
            /// 库存状态   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FStockstatusId { get; set; } = new Dictionary<string, string>() {
            { "FNumber","KCZT01_SYS"}
        };
            /// <summary>
            /// 批号   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FLot { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 备注          
            /// </summary>
            public string FNote { get; set; }
            /// <summary>
            /// 折扣率%
            /// </summary>
            public decimal FDiscountRate { get; set; }
            /// <summary>
            /// 单价折扣
            /// </summary>
            public decimal FPriceDiscount { get; set; }
            /// <summary>
            /// 库存辅单位数量
            /// </summary>
            public decimal FAuxUnitQty { get; set; }
            /// <summary>
            /// 基本单位   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FBaseUnitID { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 实收数量（辅单位）
            /// </summary>
            public decimal FExtAuxUnitQty { get; set; }
            /// <summary>
            /// 消耗汇总          
            /// </summary>
            public string FISCONSUMESUM { get; set; }
            /// <summary>
            /// 销售单位   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSalUnitID { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 销售数量
            /// </summary>
            public decimal FSalUnitQty { get; set; }
            /// <summary>
            /// 销售基本数量
            /// </summary>
            public decimal FSalBaseQty { get; set; }
            /// <summary>
            /// 计价基本数量
            /// </summary>
            public decimal FPriceBaseQty { get; set; }
            /// <summary>
            /// 销售订单EntryId
            /// </summary>
            public int FSOEntryId { get; set; }
            /// <summary>
            /// 更新库存标志
            /// </summary>
            //public string FStockFlag { get; set; } = "0";
            /// <summary>
            /// 行价目表   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FPriceListEntry { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
                        
            /// <summary>
            /// 关联关系表
            /// </summary>
            public List<Entity_Link> FEntity_Link { get; set; } = new List<Entity_Link>();
            public class Entity_Link
            {
                /// <summary>
                /// 实体主键，新建时为空，由系统自动填充
                /// </summary>
                public string FLinkId { get; set; }
                public string FEntity_Link_FFlowId { get; set; } //= "f3e2a946-0f56-465c-8547-2b20a3bf9b7e";
                public string FEntity_Link_FFlowLineId { get; set; }
                public string FEntity_Link_FRuleId { get; set; } = "DeliveryNotice-OutStock";
                public int FEntity_Link_FSTableId { get; set; } = 0;
                public string FEntity_Link_FSTableName { get; set; } = "T_SAL_DELIVERYNOTICEENTRY";
                /// <summary>
                /// 系统源单内码
                /// </summary>
                public int FEntity_Link_FSBillId { get; set; }  //要二次查询，或者由MES提供。一般二次查询...
                /// <summary>
                /// 系统源单分录内码
                /// </summary>
                public int FEntity_Link_FSId { get; set; }  //要二次查询，或者由MES提供。一般二次查询...
                public decimal FEntity_Link_FBaseActualQtyOld { get; set; }     //应发数量
                public decimal FEntity_Link_FBaseActualQty { get; set; }    //实发数量

            }
        }



        /// <summary>
        /// 税务明细
        /// </summary>
        public class FTaxDetailSubEntity
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FDetailID { get; set; }
            /// <summary>
            /// 税率%
            /// </summary>
            public decimal FTaxRate { get; set; }
        }



        /// <summary>
        /// 序列号子单据体
        /// </summary>
        public class FSerialSubEntity
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FDetailID { get; set; }
            /// <summary>
            /// 序列号          
            /// </summary>
            public string FSerialNo { get; set; }
            /// <summary>
            /// 备注          
            /// </summary>
            public string FSerialNote { get; set; }
        }

        /// <summary>
        /// 物流跟踪明细
        /// </summary>
        public class FRetStockTrace
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FEntryID { get; set; }
            /// <summary>
            /// 物流公司   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FLogComId { get; set; } = new Dictionary<string, string>() {
            { "FCODE",""}
        };
            /// <summary>
            /// 物流单号  (必填项)          
            /// </summary>
            public string FCarryBillNo { get; set; }
            /// <summary>
            /// 寄件人手机号        
            /// </summary>
            public string FPhoneNumber { get; set; }
            /// <summary>
            /// 起始地点        
            /// </summary>
            public string FFrom { get; set; }
            /// <summary>
            /// 终止地点        
            /// </summary>
            public string FTo { get; set; }
            /// <summary>
            /// 发货日期  
            /// </summary>
            public DateTime FDelTime { get; set; }
            /// <summary>
            /// 物流状态        
            /// </summary>
            public string FTraceStatus { get; set; }
            /// <summary>
            /// 签收时间  
            /// </summary>
            public DateTime FReceiptTime { get; set; }
        }



        /// <summary>
        /// 物流详细信息
        /// </summary>
        public class FReturnStockTraceDetail
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FDetailID { get; set; }
            /// <summary>
            /// 时间          
            /// </summary>
            public string FTraceTime { get; set; }
            /// <summary>
            /// 物流详情          
            /// </summary>
            public string FTraceDetail { get; set; }
        }
    }
}
