using RB_MES_API.Context;
using System.ComponentModel.DataAnnotations;
namespace RB_MES_API.Models.Cloud
{
    /// <summary>
    /// 采购退料单
    /// </summary>
    public class PUR_MRB
    {
        /// <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 FBusinessType { get; set; }
        /// <summary>
        /// 单据编号
        /// </summary>
        public string FBillNo { get; set; }
        /// <summary>
        /// 日期  (必填项)
        /// </summary>
        [DataType(DataType.DateTime)]
        public string FDate { get; set; }
        /// <summary>
        /// 退料类型  (必填项)
        /// </summary>
        public string FMRTYPE { get; set; } = "B";
        /// <summary>
        /// 退料方式  (必填项)
        /// </summary>
        public string FMRMODE { get; set; } = "A";
        /// <summary>
        /// 退料方式  (非必填项)
        /// </summary>
        public string FACCTYPE { get; set; } = "Q";
        /// <summary>
        /// 退料组织  (必填项)
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FStockOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
        /// <summary>
        /// 退料部门  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FMRDeptId { 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>
        public bool FIsConvert { get; set; } = false;
        /// <summary>
        /// 对应组织  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FCorrespondOrgId { 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>
        [StringLength(36)]
        public Dictionary<string, string> FMRREASON { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER","CGTLYY02_SYS"}
        };
        /// <summary>
        /// 需求组织    (必填项)  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FRequireOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
        /// <summary>
        /// 采购组织      (必填项)  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FPurchaseOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
        /// <summary>
        /// 采购部门  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FPURCHASEDEPTID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 采购组  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FPURCHASERGROUPID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 采购员  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FPURCHASERID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 供应商    (必填项)  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FSupplierID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 备注
        /// </summary>
        public string FDESCRIPTION { get; set; }
        /// <summary>
        /// 接收方  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FACCEPTORID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 接收方地址
        /// </summary>
        public string FAcceptAddress { get; set; }
        /// <summary>
        /// 结算方  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FSettleId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 收款方  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FCHARGEID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 货主类型      (必填项)
        /// </summary>
        public string FOwnerTypeIdHead { get; set; } = "BD_OwnerOrg";//"BD_Supplier";
        /// <summary>
        /// 货主       (必填项)
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FOwnerIdHead { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 扫描点  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FScanPoint { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 确认人  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FConfirmerId { get; set; } = new Dictionary<string, string>() { { "FUserID", "" } };
        /// <summary>
        /// 确认日期
        /// </summary>
        [DataType(DataType.Date)]
        public string FConfirmDate { get; set; }
        /// <summary>
        /// 序列号上传
        /// </summary>
        //public string FScanBox { get; set; } 
        /// <summary>
        /// 创建日期偏移单位
        /// </summary>
        public string FCDateOffsetUnit { get; set; }
        /// <summary>
        /// 创建日期偏移量
        /// </summary>
        public int FCDateOffsetValue { get; set; }
        /// <summary>
        /// 接收方联系人  
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FAcceptorContactID { get; set; } = new Dictionary<string, string>() { { "FCONTACTNUMBER", "" } };
        /// <summary>
        /// 邮箱
        /// </summary>
        public string FAcceptEMail { get; set; }
        /// <summary>
        /// MES唯一标识
        /// </summary>
        [StringLength(36)]
        public string F_SBMI_QUEUE_ID { get; set; }
        /// <summary>
        /// 退料说明（自定义）
        /// </summary>
        public string F_Return_instructions { get; set; }
        public Dictionary<string, string> F_Material_type { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "004" } };



        public PURMRBFIN FPURMRBFIN { get; set; } = new PURMRBFIN();
        /// <summary>
        /// 财务信息
        /// </summary>
        public class PURMRBFIN
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FEntryId { get; set; }
            /// <summary>
            /// 结算组织  (必填项)       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSettleOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
            /// <summary>
            /// 结算方式    
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSETTLETYPEID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 结算币别   (必填项)    
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSettleCurrId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            ///  付款条件    
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FPAYCONDITIONID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 定价时点     (必填项)
            /// </summary>
            public string FPRICETIMEPOINT { get; set; }
            /// <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; }
            /// <summary>
            ///  价外税
            /// </summary>
            public bool FISPRICEEXCLUDETAX { get; set; } = true;
            /// <summary>
            ///  含税
            /// </summary>
            public bool FIsIncludedTax { get; set; } = true;
        }
        public List<PURMRBENTRY> FPURMRBENTRY { get; set; } = new List<PURMRBENTRY>();
        /// <summary>
        /// 明细信息
        /// </summary>
        public class PURMRBENTRY
        {
            /// <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 string FKEEPERTYPEID { get; set; } = "BD_KeeperOrg";
            /// <summary>
            ///  保管者  
            /// </summary>
            public Dictionary<string, string> FKEEPERID { get; set; } = new Dictionary<string, string>() {
                { "FNumber",LocalStaticRequest.DefaultOrg}
            };
            /// <summary>
            /// 订单单号
            /// </summary>
            public string FORDERNO { get; set; }
            /// <summary>
            /// 源单单号
            /// </summary>
            public string FSRCBillNo { get; set; }
            /// <summary>
            /// 源单类型
            /// </summary>
            public string FSRCBILLTYPEID { get; set; } = "PUR_PurchaseOrder";
            /// <summary>
            /// 订单单号分录内码
            /// </summary>
            public int FPOORDERENTRYID { get; set; }
            /// <summary>
            /// 源单分录行号
            /// </summary>
            public string FSRCSeq { get; set; }
            /// <summary>
            ///  辅助属性
            /// </summary>
            public AuxpropId FAuxPropId { get; set; }
            public class AuxpropId
            {
                public Dictionary<string, string> FAUXPROPID__FF100001 { get; set; } = new Dictionary<string, string>() {
                { "FNumber",""} };
            }
            /// <summary>
            /// 物料说明
            /// </summary>
            public string FMaterialDesc { get; set; }
            /// <summary>
            ///  父项产品      
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FParentMatId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            /// 项目编号
            /// </summary>
            public string FProjectNo { get; set; }
            /// <summary>
            ///  库存单位     (必填项)      
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FUnitID { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            /// 应退数量
            /// </summary>
            public decimal FRMMUSTQTY { get; set; }
            /// <summary>
            /// 实退数量
            /// </summary>
            public decimal FRMREALQTY { get; set; }
            /// <summary>
            /// 补料数量
            /// </summary>
            public decimal FREPLENISHQTY { get; set; }
            /// <summary>
            /// 基本补料数量
            /// </summary>
            public decimal FBASEREPLAYQTY { get; set; }
            /// <summary>
            /// 扣款数量
            /// </summary>
            public decimal FKEAPAMTQTY { get; set; }
            /// <summary>
            /// 计价单位     (必填项)      
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FPRICEUNITID { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            /// 仓库       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSTOCKID { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            /// 仓位   
            /// </summary>
            public class FStocklocId
            {
                [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>
            public Dictionary<string, string> FLot { get; set; } = new Dictionary<string, string>() { { "FNumber", "" } };
            /// <summary>
            /// 备注
            /// </summary>
            public string FNOTE { get; set; }
            /// <summary>
            /// 税组合       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FTaxCombination { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            /// 单价
            /// </summary>
            public decimal FPrice { get; set; }
            /// <summary>
            /// 辅单位       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FExtAuxUnitId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
            /// <summary>
            /// 实退数量(辅单位)
            /// </summary>
            public decimal FExtAuxUnitQty { get; set; }
            /// <summary>
            /// 需求跟踪号
            /// </summary>
            public string FREQTRACENO { get; set; }
            /// <summary>
            ///  收料更新库存
            /// </summary>
            public bool FIsReceiveUpdateStock { get; set; } = false;
            /// <summary>
            /// 已开票关联数量
            /// </summary>
            public decimal FInvoicedJoinQty { get; set; }
            /// <summary>
            ///  是否赠品
            /// </summary>
            public bool FGiveAway { get; set; } = false;
            /// <summary>
            /// 计价基本数量
            /// </summary>
            public decimal FPriceBaseQty { get; set; }
            /// <summary>
            /// 定价单位       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FSetPriceUnitID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 采购单位     (必填项)       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FCarryUnitId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 生产日期
            /// </summary>
            [DataType(DataType.Date)]
            public string FProduceDate { get; set; }
            /// <summary>
            /// 到期日
            /// </summary>
            [DataType(DataType.Date)]
            public string FEXPIRYDATE { get; set; }
            /// <summary>
            /// 库存辅单位数量
            /// </summary>
            public int FAUXUNITQTY { get; set; }
            /// <summary>
            /// 货主类型    (必填项)
            /// </summary>
            public string FOWNERTYPEID { get; set; } = "BD_Supplier";
            /// <summary>
            /// 货主     (必填项)       
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FOWNERID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            ///// <summary>
            ///// 税率
            ///// </summary>
            //public decimal FENTRYTAXRATE { get; set; } 
            /// <summary>
            ///  折扣率(%)
            /// </summary>
            public decimal FDISCOUNTRATE { get; set; }
            /// <summary>
            ///  含税单价
            /// </summary>
            public decimal FTAXPRICE { get; set; }
            /// <summary>
            /// 基本单位单价
            /// </summary>
            public decimal FBASEUNITPRICE { get; set; }
            /// <summary>
            /// 单价折扣
            /// </summary>
            public decimal FPriceDiscount { get; set; }
            /// <summary>
            ///  是否可库存
            /// </summary>
            public bool FIsStock { get; set; } = false;
            /// <summary>
            /// 费用项目   
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FChargeProjectID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 计划跟踪号
            /// </summary>
            public string FMtoNo { get; set; }
            /// <summary>
            /// 采购订单版本号
            /// </summary>
            public string FVERSIONNO { get; set; }
            ///// <summary>
            ///// 更新库存标志
            ///// </summary>
            //public string FStockFlag { get; set; } = "1";
            /// <summary>
            ///  订单需求组织
            /// </summary>
            public Dictionary<string, string> FPoRequireOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
            /// <summary>
            ///  业务流程
            /// </summary>
            public Dictionary<string, string> FBFLowId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };

            /// <summary>
            /// 关联关系表，当原单信息有提供时 new InStockEntry_Link()
            /// </summary>
            public List<PURMRBENTRY_Link>? FPURMRBENTRY_Link { get; set; }

            public class PURMRBENTRY_Link
            {

                /// <summary>
                ///  实体主键
                /// </summary>
                public string FLinkId { get; set; }
                /// <summary>
                /// 业务流程图
                /// </summary>
                public string FPURMRBENTRY_Link_FFlowId { get; set; }
                /// <summary>
                /// 推进路线
                /// </summary>
                public string FPURMRBENTRY_Link_FFlowLineId { get; set; }
                /// <summary>
                /// 转换规则:单据转换内码，必录，（在转换规则设计界面中的唯一标识）
                /// </summary>
                public string FPURMRBENTRY_Link_FRuleId { get; set; } = "PUR_PurchaseOrder-PUR_MRB";
                /// <summary>
                /// 源单表内码
                /// </summary>
                public int FPURMRBENTRY_Link_FSTableId { get; set; }
                /// <summary>
                /// 源单表
                /// </summary>
                public string FPURMRBENTRY_Link_FSTableName { get; set; } = "t_PUR_POOrderEntry";
                /// <summary>
                /// 源单内码
                /// </summary>
                public string FPURMRBENTRY_Link_FSBillId { get; set; }
                /// <summary>
                /// 源单分录内码
                /// </summary>
                public string FPURMRBENTRY_Link_FSId { get; set; }
                /// <summary>
                ///  原始携带量
                /// </summary>
                public decimal FPURMRBENTRY_Link_FRemainInStockBaseQtyOld { get; set; }
                /// <summary>
                ///  原始携带量
                /// </summary>
                public decimal FPURMRBENTRY_Link_FRemainInStockBaseQty { get; set; }
                /// <summary>
                ///  原始携带量,控制字段，必录
                /// </summary>
                public decimal FPURMRBENTRY_Link_FBaseUnitQtyOld { get; set; }
                /// <summary>
                ///  原始携带量,控制字段，必录
                /// </summary>
                public decimal FPURMRBENTRY_Link_FBaseUnitQty { get; set; }
                /// <summary>
                ///  迁移图
                /// </summary>
                public string FPURMRBENTRY_Link_FLnk1TrackerId { get; set; } = string.Empty;
                /// <summary>
                ///  上游状态
                /// </summary>
                public string FPURMRBENTRY_Link_FLnk1SState { get; set; } = string.Empty;
                /// <summary>
                ///  数量FLnk1
                /// </summary>
                public decimal FPURMRBENTRY_Link_FLnk1Amount { get; set; }
                /// <summary>
                ///  迁移图
                /// </summary>
                public string FPURMRBENTRY_Link_FLnkTrackerId { get; set; } = string.Empty;
                /// <summary>
                ///  上游状态
                /// </summary>
                public string FPURMRBENTRY_Link_FLnkSState { get; set; } = string.Empty;
                /// <summary>
                ///  数量FLnk
                /// </summary>
                public decimal FPURMRBENTRY_Link_FLnkAmount { get; set; }
                /// <summary>
                ///  迁移图
                /// </summary>
                public string FPURMRBENTRY_Link_FLnk2TrackerId { get; set; } = string.Empty;
                /// <summary>
                ///  上游状态
                /// </summary>
                public string FPURMRBENTRY_Link_FLnk2SState { get; set; } = string.Empty;
                /// <summary>
                ///  数量FLnk2
                /// </summary>
                public decimal FPURMRBENTRY_Link_FLnk2Amount { get; set; }
            }
        }



        public List<EntryPruCost> FEntryPruCost { get; set; } = new List<EntryPruCost>();
        /// <summary>
        /// 费用明细
        /// </summary>
        public class EntryPruCost
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FDetailID { 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; }
        }
    }
}
