private void CreateSOLines(Organization org, SOInfo soInfo, SaleOrderDTO dtoSO, Customer customer) { CustomerSite cs = CustomerSite.Finder.Find("Customer ='" + customer.ID + "'"); CustomerSiteMISCInfo customerSite = new CustomerSiteMISCInfo(); customerSite.CustomerSite = cs; customerSite.Code = cs.Code; customerSite.Name = cs.Name; foreach (var itemLine in soInfo.Lines) { UFIDA.U9.ISV.SM.SOLineDTO soLine = new UFIDA.U9.ISV.SM.SOLineDTO(); //料品 soLine.ItemInfo = new UFIDA.U9.CBO.SCM.Item.ItemInfo(); ItemMaster beItemMaster = ItemMaster.Finder.Find("Code = @code and Org = @orgID", new OqlParam[2] { new OqlParam(itemLine.ItemMasterCode), new OqlParam(org.ID) }); if (beItemMaster == null) { throw new Exception(string.Format("物料编码{0}在U9中不存在", itemLine.ItemMasterCode)); } soLine.ItemInfo.ItemID = beItemMaster; //soLine.BomOwner = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTO(); //soLine.BomOwner.ID = org.ID; //soLine.BomOwner.Code = org.Code; //soLine.BomOwner.Name = org.Name; //数量 soLine.ChoiceResult = 0; soLine.OrderByQtyTU = itemLine.Qty; //扩展字段 soLine.DescFlexField = new UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegments(); //收款条件 if (customer.RecervalTerm != null) { soLine.RecTerm = new CommonArchiveDataDTO(); soLine.RecTerm.Code = customer.RecervalTerm.Code; } //立账位置 if (customer.CustomerSites != null) { if (customer.CustomerSites.Count > 0) { soLine.BillToSite = customerSite; soLine.BillToSite.Code = customerSite.Code; soLine.BillToSite.CustomerSiteKey = customerSite.CustomerSiteKey; } } //定价方式 soLine.CooperatePriceStyle = -1; //免费品类型 soLine.FreeType = FreeTypeEnum.GetFromValue(-1); //免费品原因 soLine.FreeReason = DonationReasonEnum.GetFromValue(-1); //台阶划分依据 soLine.StepBy = -1; //预收环节 soLine.PreRecObject = -1; //原币-额币 soLine.TCToCCExchRateType = ExchangeRateTypesEnum.GetFromValue(0); //来源单据类别 soLine.SrcDocType = SOSourceTypeEnum.GetFromValue(0); //成套收发货标志 soLine.ShipTogetherFlag = KITShipModeEnum.GetFromValue(-1); //数量类型 soLine.QuantityType = UsageQuantityTypeEnum.GetFromValue(-1); //资源成本计费基础 soLine.ChargeBasis = ChargeBasisEnum.GetFromValue(-1); //价格来源 soLine.PriceSource = PriceSourceEnum.GetFromValue(1); //是否消耗信用额度 soLine.IsEngrossCreditLimit = true; //添加销售订单上的计划行 soLine.SOShiplines = new List <SOShipLineDTO>(); SOShipLineDTO soship = new SOShipLineDTO(); soship.ItemInfo = new UFIDA.U9.CBO.SCM.Item.ItemInfo(); soship.ItemInfo.ItemID = beItemMaster; soship.ItemInfo.ItemCode = beItemMaster.Code; soship.ItemInfo.ItemName = beItemMaster.Name; soship.RequireDate = DateTime.Parse(itemLine.DeliveryDate); soship.DescFlexField = new UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegments(); //区域位置 soship.ShipToSite = new CustomerSiteMISCInfo(); soship.ShipToSite.CustomerSite = customerSite.CustomerSite; soship.ShipToSite.Code = customerSite.Code; soship.ShipToSite.Name = customerSite.Name; //单价 soLine.OrderPriceTC = itemLine.TCPrice; soLine.SOShiplines.Add(soship); dtoSO.SOLines.Add(soLine); } }
private SaleOrderDTO CreateSOHead(Organization org, string soDocTypeCode, Customer itemCust, SOInfo soInfo) { SaleOrderDTO dtoSOHead = new SaleOrderDTO(); //单据类型 long doctypeID = GetProfileValue(soDocTypeCode);//销售订单单据类型 CommonArchiveDataDTO dtoDocType = new CommonArchiveDataDTO(); dtoDocType.ID = doctypeID; dtoSOHead.DocumentType = dtoDocType; //客户 CustomerMISCInfo customer = new CustomerMISCInfo(); customer.Code = itemCust.Code; dtoSOHead.OrderBy = customer; //订单日期 dtoSOHead.BusinessDate = DateTime.Parse(soInfo.BusinessDate); Profile profDept = Base.Profile.Profile.Finder.Find("Application.Code = @appCode and Code = @code ", new OqlParam[2] { new OqlParam("0503"), new OqlParam("SD051") }); //销售管理-参数设置-默认销售部门 Profile profEmployee = Base.Profile.Profile.Finder.Find("Application.Code = @appCode and Code = @code ", new OqlParam[2] { new OqlParam("0503"), new OqlParam("SD052") }); //销售管理-参数设置-默认销售员 //部门 dtoSOHead.SaleDepartment = new CommonArchiveDataDTO(); dtoSOHead.SaleDepartment.ID = Convert.ToInt64(profDept.GetProfileValue().ToString()); //业务员 dtoSOHead.Seller = new CommonArchiveDataDTO(); dtoSOHead.Seller.ID = Convert.ToInt64(profEmployee.GetProfileValue().ToString()); //立账位置 dtoSOHead.IsPriceIncludeTax = true; CustomerSite cs = CustomerSite.Finder.Find("Customer ='" + itemCust.ID + "'"); CustomerSiteMISCInfo cdd = new CustomerSiteMISCInfo(); cdd.CustomerSite = cs; //收货位置 dtoSOHead.ShipToSite = cdd; dtoSOHead.ShipToSite.Code = cdd.Code; dtoSOHead.ShipToSite.Name = cdd.Name; //立账位置 dtoSOHead.BillToSite = cdd; dtoSOHead.BillToSite.Code = cdd.Code; dtoSOHead.BillToSite.Name = cdd.Name; //付款位置 dtoSOHead.PayerSite = cdd; dtoSOHead.PayerSite.Code = cdd.Code; dtoSOHead.PayerSite.Name = cdd.Name; //币种 if (itemCust.TradeCurrency != null) { dtoSOHead.TC = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTO(); dtoSOHead.TC.Code = itemCust.TradeCurrency.Code; } //优先级 dtoSOHead.SOPriority = SOPRIEnum.GetFromValue(99); //核算组织 dtoSOHead.AccountOrg = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTO(); dtoSOHead.AccountOrg.Code = org.Code; //开票组织 dtoSOHead.InvoiceOrg = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTO(); dtoSOHead.InvoiceOrg.Code = org.Code; //出货原则 if (itemCust.ShippmentRule != null) { dtoSOHead.ShipRule = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTO(); dtoSOHead.ShipRule.Code = itemCust.ShippmentRule.Code; } //立账条件 if (itemCust.ARConfirmTerm != null) { dtoSOHead.ConfirmTerm = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTO(); dtoSOHead.ConfirmTerm.Code = itemCust.ARConfirmTerm.Code; } //成交方式 dtoSOHead.BargainMode = BargainEnum.GetFromValue(-1); //运费支付 dtoSOHead.TransPayMode = UFIDA.U9.CBO.SCM.Enums.FreightPaymentEnum.GetFromValue(-1); //扩展段 dtoSOHead.DescFlexField = new UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegments(); return(dtoSOHead); }