コード例 #1
0
        private void ModifySOPrice(long so, List <ReturnDiscountDTO> dtoList)
        {
            List <UFIDA.U9.ISV.SM.SaleOrderDTOData> soDtoList = QuerySOByDocNo(so);

            foreach (UFIDA.U9.ISV.SM.SaleOrderDTOData soHead in soDtoList)
            {
                UFIDA.U9.SM.SO.SO soDoc = UFIDA.U9.SM.SO.SO.Finder.FindByID(soHead.ID);

                soHead.DescFlexField.PrivateDescSeg1 = "True";

                foreach (ReturnDiscountDTO dto in dtoList)
                {
                    UFIDA.U9.ISV.SM.SOLineDTOData soLineDto = soHead.SOLines.Find(delegate(UFIDA.U9.ISV.SM.SOLineDTOData dtoTemp)
                    {
                        return(dtoTemp.ID == dto.SoLineID);
                    });
                    if (soLineDto == null)
                    {
                        continue;
                    }

                    UFIDA.U9.Cust.GS.FT.DiscountBE.DiscountLine discountLine = UFIDA.U9.Cust.GS.FT.DiscountBE.DiscountLine.Finder.FindByID(dto.DiscountID);

                    decimal price = 0;//外销价

                    if (string.IsNullOrEmpty(soLineDto.DescFlexField.PrivateDescSeg5))
                    {
                        soLineDto.DescFlexField.PrivateDescSeg5 = soLineDto.OrderPriceTC.ToString();
                    }
                    price = decimal.Parse(soLineDto.DescFlexField.PrivateDescSeg5);

                    decimal DiscountRatio = 0;
                    decimal DiscountPrice = 0;
                    AllEnumBE.DiscountTypeEnum DiscountType = AllEnumBE.DiscountTypeEnum.Empty;
                    if (!dto.IsReset)
                    {
                        DiscountRatio = dto.DiscountRatio;
                        DiscountPrice = dto.DiscountPrices;
                        DiscountType  = dto.DiscountType;
                    }
                    else
                    {
                        #region 重新读取折扣信息
                        string     strWhere   = "DiscountHead.Custmor.Code=@Customer  and DiscountHead.Product.Code=@Item and ValidDate<=@Date and UnValidDate>=@Date and DiscountHead.Org=@Org and DiscountHead.States=2";
                        OqlParam[] appOqlparm = new OqlParam[] {
                            new OqlParam("Customer", soHead.OrderBy.Code),
                            new OqlParam("Item", soLineDto.ItemInfo.ItemCode),
                            new OqlParam("Date", soHead.BusinessDate),
                            new OqlParam("Org", Context.LoginOrg.ID)
                        };
                        UFIDA.U9.Cust.GS.FT.DiscountBE.DiscountLine.EntityList DiscountList = UFIDA.U9.Cust.GS.FT.DiscountBE.DiscountLine.Finder.FindAll(strWhere, appOqlparm);
                        foreach (UFIDA.U9.Cust.GS.FT.DiscountBE.DiscountLine Discount in DiscountList)
                        {
                            bool isBreak = false;
                            if (Discount.DiscountType == AllEnumBE.DiscountTypeEnum.PercentValues)//百分比
                            {
                                //如果是百分比,则使用外销价*百分比
                                DiscountRatio = Discount.Discount;
                                isBreak       = true;
                            }
                            if (Discount.DiscountType == AllEnumBE.DiscountTypeEnum.FixedValues && soHead.TC.ID == Discount.CurrencyType.ID)//固定值
                            {
                                //如果是固定值,并且币种相同,则使用外销价-固定值设定的单价
                                DiscountPrice = Discount.Prices;
                                isBreak       = true;
                            }
                            DiscountType = Discount.DiscountType;

                            discountLine = Discount;

                            if (isBreak)
                            {
                                break;
                            }
                        }
                        #endregion
                    }
                    soLineDto.FinallyPriceTC = price;
                    if (DiscountType == AllEnumBE.DiscountTypeEnum.PercentValues)//百分比
                    {
                        //如果是百分比,则使用外销价*百分比
                        soLineDto.FinallyPriceTC = price - price * DiscountRatio;
                    }
                    if (DiscountType == AllEnumBE.DiscountTypeEnum.FixedValues)//固定值
                    {
                        //如果是固定值,并且币种相同,则使用外销价-固定值设定的单价
                        // update Bug:96 Ldward 20150205
                        if (price < DiscountPrice)
                        {
                            throw new Exception("固定折扣小于外销价生成折扣失败,请确认!");
                        }
                        soLineDto.FinallyPriceTC = price - DiscountPrice;
                    }
                    soLineDto.DescFlexField.PrivateDescSeg19 = "True";
                    soLineDto.PriceCalField = "FinallyPrice";//价格来源改为手工
                    soLineDto.DescFlexField.PrivateDescSeg21 = (price * soLineDto.OrderByQtyTU - soLineDto.FinallyPriceTC * soLineDto.OrderByQtyTU).ToString();

                    CreateSODicount(discountLine, DiscountType, DiscountPrice, DiscountRatio, soLineDto.ID, soLineDto.FinallyPriceTC * soLineDto.OrderByQtyTU, price * soLineDto.OrderByQtyTU - soLineDto.FinallyPriceTC * soLineDto.OrderByQtyTU, price, soDoc.Key);
                }
            }
            UFIDA.U9.ISV.SM.Proxy.CommonModifySOSRVProxy sv = new ISV.SM.Proxy.CommonModifySOSRVProxy();
            sv.SOs           = soDtoList;
            sv.TargetOrgCode = Context.LoginOrg.Code;
            sv.Do();
        }
コード例 #2
0
        // 得到销售订单dto
        /// <summary>
        /// 得到销售订单dto
        /// </summary>
        /// <param name="bpObj"></param>
        /// <returns></returns>
        private System.Collections.Generic.List <SaleOrderDTOData> GetSaleOrderDTODataList(CreateApprovedSaleOrderSV bpObj, out List <SO> lstExist)
        {
            lstExist = new List <SO>();

            System.Collections.Generic.List <SaleOrderDTOData> list = new System.Collections.Generic.List <SaleOrderDTOData>();
            System.Collections.Generic.Dictionary <string, System.Collections.Generic.List <SoLineDTO> > dic = new System.Collections.Generic.Dictionary <string, System.Collections.Generic.List <SoLineDTO> >();
            foreach (SoLineDTO solinedto in bpObj.SoLineDto)
            {
                if (!dic.ContainsKey(solinedto.SpitOrderFlag))
                {
                    dic.Add(solinedto.SpitOrderFlag, new System.Collections.Generic.List <SoLineDTO>());
                }
                dic[solinedto.SpitOrderFlag].Add(solinedto);
            }
            foreach (string key in dic.Keys)
            {
                List <SoLineDTO> listLineDTO = dic[key];

                if (listLineDTO != null &&
                    listLineDTO.Count > 0
                    )
                {
                    SoLineDTO firstDTO = listLineDTO.GetFirst <SoLineDTO>();

                    SO so = SO.Finder.Find("DescFlexField.PubDescSeg5=@DmsSaleNum"
                                           , new OqlParam(firstDTO.DmsSaleNo)
                                           );

                    // 订单存在,添加到订单清单里
                    if (so != null)
                    {
                        lstExist.Add(so);
                    }
                    //
                    else
                    {
                        SaleOrderDTOData sodto = new SaleOrderDTOData();
                        sodto.DocumentType      = (new CommonArchiveDataDTOData());
                        sodto.DocumentType.Code = (firstDTO.OrderType);
                        sodto.OrderBy           = (new CustomerMISCInfoData());
                        sodto.OrderBy.Code      = (firstDTO.DealerCode);
                        sodto.SOSrcType         = (SOSourceTypeEnum.Manual.Value);
                        sodto.TC = (new CommonArchiveDataDTOData());
                        //sodto.TC.Code = (string.IsNullOrEmpty(firstDTO.Currency) ? "C001" : firstDTO.Currency);
                        sodto.TC.Code                   = (string.IsNullOrEmpty(firstDTO.Currency) ? HBHCommon.DefaultCurrencyCode : firstDTO.Currency);
                        sodto.DescFlexField             = (new DescFlexSegmentsData());
                        sodto.DescFlexField.PubDescSeg5 = (firstDTO.DmsSaleNo);
                        //string RecTerm = "01";
                        string   RecTerm  = HBHCommon.DefaultRecTermCode;
                        Customer customer = Customer.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID, firstDTO.DealerCode), new OqlParam[0]);

                        sodto.SaleDepartment = new CommonArchiveDataDTOData();
                        sodto.Seller         = new CommonArchiveDataDTOData();
                        if (customer != null)
                        {
                            sodto.ConfirmTerm = (new CommonArchiveDataDTOData());
                            if (customer.ARConfirmTerm != null)
                            {
                                sodto.ConfirmTerm.Code = (customer.ARConfirmTerm.Code);
                            }
                            else
                            {
                                sodto.ConfirmTerm.Code = HBHCommon.DefaultConfirmTermCode;  // ("01");
                            }
                            sodto.BargainMode = (customer.Bargain.Value);
                            sodto.ShipRule    = (new CommonArchiveDataDTOData());
                            if (customer.ShippmentRuleKey != null)
                            {
                                sodto.ShipRule.Code = (customer.ShippmentRule.Code);
                            }
                            else
                            {
                                sodto.ShipRule.Code = HBHCommon.DefaultShipRuleCode;    // ("C001");
                            }
                            if (customer.RecervalTermKey != null)
                            {
                                RecTerm = customer.RecervalTerm.Code;
                            }

                            if (customer.SaleserKey != null)
                            {
                                sodto.Seller.ID = customer.SaleserKey.ID;
                                //Operators opeator = Operators.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID.ToString(), HBHCommon.DefaultShipOperatorCode), new OqlParam[0]);
                                //if (opeator != null)
                                //{
                                //    shipdto.SaleDept.ID = (opeator.DeptKey.ID);
                                //}
                            }
                            if (customer.DepartmentKey != null)
                            {
                                sodto.SaleDepartment.ID = customer.DepartmentKey.ID;
                            }
                        }
                        else
                        {
                            sodto.ShipRule.Code    = HBHCommon.DefaultShipRuleCode;    // ("C001");
                            sodto.BargainMode      = HBHCommon.DefaultBargainMode;     // (0);
                            sodto.ConfirmTerm      = (new CommonArchiveDataDTOData());
                            sodto.ConfirmTerm.Code = HBHCommon.DefaultConfirmTermCode; // ("01");
                        }
                        sodto.SOLines = new List <ISV.SM.SOLineDTOData>();
                        foreach (SoLineDTO srcsolinedto in dic[key])
                        {
                            UFIDA.U9.ISV.SM.SOLineDTOData solinedto2 = new UFIDA.U9.ISV.SM.SOLineDTOData();
                            solinedto2.ItemInfo          = (new ItemInfoData());
                            solinedto2.ItemInfo.ItemCode = (srcsolinedto.ErpMaterialCode);
                            if (!string.IsNullOrEmpty(srcsolinedto.FinalPrice))
                            {
                                solinedto2.FinallyPriceTC = (decimal.Parse(srcsolinedto.FinalPrice));
                            }
                            if (!string.IsNullOrEmpty(srcsolinedto.Number))
                            {
                                solinedto2.OrderByQtyPU = (decimal.Parse(srcsolinedto.Number));
                            }
                            else
                            {
                                solinedto2.OrderByQtyPU = (1m);
                            }
                            if (!string.IsNullOrEmpty(srcsolinedto.Money))
                            {
                                solinedto2.TotalMoneyTC = (decimal.Parse(srcsolinedto.Money));
                            }
                            solinedto2.Project       = (new CommonArchiveDataDTOData());
                            solinedto2.Project.Code  = (srcsolinedto.DmsSaleNo);
                            solinedto2.SrcDocType    = (SOSourceTypeEnum.Manual.Value);
                            solinedto2.RecTerm       = (new CommonArchiveDataDTOData());
                            solinedto2.RecTerm.Code  = (RecTerm);
                            solinedto2.DescFlexField = (new DescFlexSegmentsData());
                            solinedto2.DescFlexField.PrivateDescSeg1 = (srcsolinedto.MaterialCode);
                            solinedto2.SOShiplines = (new System.Collections.Generic.List <SOShipLineDTOData>());
                            SOShipLineDTOData soshipliendto = new SOShipLineDTOData();
                            soshipliendto.Project           = (new CommonArchiveDataDTOData());
                            soshipliendto.Project.Code      = (srcsolinedto.DmsSaleNo);
                            soshipliendto.ItemInfo          = (new ItemInfoData());
                            soshipliendto.ItemInfo.ItemCode = (srcsolinedto.ErpMaterialCode);
                            soshipliendto.IsMRPRequire      = (true);
                            soshipliendto.RequireDate       = (string.IsNullOrEmpty(srcsolinedto.DeliveryDate) ? System.DateTime.Now : System.Convert.ToDateTime(srcsolinedto.DeliveryDate));
                            solinedto2.SOShiplines.Add(soshipliendto);
                            sodto.SOLines.Add(solinedto2);
                        }
                        list.Add(sodto);
                    }
                }
            }
            return(list);
        }
コード例 #3
0
        // 得到销售订单dto
        /// <summary>
        /// 得到销售订单dto
        /// </summary>
        /// <param name="bpObj"></param>
        /// <returns></returns>
        private System.Collections.Generic.List<SaleOrderDTOData> GetSaleOrderDTODataList(CreateApprovedSaleOrderSV bpObj,out List<SO> lstExist)
        {
            lstExist = new List<SO>();

            System.Collections.Generic.List<SaleOrderDTOData> list = new System.Collections.Generic.List<SaleOrderDTOData>();
            System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<SoLineDTO>> dic = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<SoLineDTO>>();
            foreach (SoLineDTO solinedto in bpObj.SoLineDto)
            {
                if (!dic.ContainsKey(solinedto.SpitOrderFlag))
                {
                    dic.Add(solinedto.SpitOrderFlag, new System.Collections.Generic.List<SoLineDTO>());
                }
                dic[solinedto.SpitOrderFlag].Add(solinedto);
            }
            foreach (string key in dic.Keys)
            {
                List<SoLineDTO> listLineDTO = dic[key];

                if (listLineDTO != null
                    && listLineDTO.Count > 0
                    )
                {
                    SoLineDTO firstDTO = listLineDTO.GetFirst<SoLineDTO>();

                    SO so = SO.Finder.Find("DescFlexField.PubDescSeg5=@DmsSaleNum"
                        , new OqlParam(firstDTO.DmsSaleNo)
                        );

                    // 订单存在,添加到订单清单里
                    if (so != null)
                    {
                        lstExist.Add(so);
                    }
                    //
                    else
                    {
                        SaleOrderDTOData sodto = new SaleOrderDTOData();
                        sodto.DocumentType = (new CommonArchiveDataDTOData());
                        sodto.DocumentType.Code = (firstDTO.OrderType);
                        sodto.OrderBy = (new CustomerMISCInfoData());
                        sodto.OrderBy.Code = (firstDTO.DealerCode);
                        sodto.SOSrcType = (SOSourceTypeEnum.Manual.Value);
                        sodto.TC = (new CommonArchiveDataDTOData());
                        //sodto.TC.Code = (string.IsNullOrEmpty(firstDTO.Currency) ? "C001" : firstDTO.Currency);
                        sodto.TC.Code = (string.IsNullOrEmpty(firstDTO.Currency) ? HBHCommon.DefaultCurrencyCode : firstDTO.Currency);
                        sodto.DescFlexField = (new DescFlexSegmentsData());
                        sodto.DescFlexField.PubDescSeg5 = (firstDTO.DmsSaleNo);
                        //string RecTerm = "01";
                        string RecTerm = HBHCommon.DefaultRecTermCode;
                        Customer customer = Customer.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID, firstDTO.DealerCode), new OqlParam[0]);

                        sodto.SaleDepartment = new CommonArchiveDataDTOData();
                        sodto.Seller = new CommonArchiveDataDTOData();
                        if (customer != null)
                        {
                            sodto.ConfirmTerm = (new CommonArchiveDataDTOData());
                            if (customer.ARConfirmTerm != null)
                            {
                                sodto.ConfirmTerm.Code = (customer.ARConfirmTerm.Code);
                            }
                            else
                            {
                                sodto.ConfirmTerm.Code = HBHCommon.DefaultConfirmTermCode;  // ("01");
                            }
                            sodto.BargainMode = (customer.Bargain.Value);
                            sodto.ShipRule = (new CommonArchiveDataDTOData());
                            if (customer.ShippmentRuleKey != null)
                            {
                                sodto.ShipRule.Code = (customer.ShippmentRule.Code);
                            }
                            else
                            {
                                sodto.ShipRule.Code = HBHCommon.DefaultShipRuleCode;    // ("C001");
                            }
                            if (customer.RecervalTermKey != null)
                            {
                                RecTerm = customer.RecervalTerm.Code;
                            }

                            if (customer.SaleserKey != null)
                            {
                                sodto.Seller.ID = customer.SaleserKey.ID;
                                //Operators opeator = Operators.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID.ToString(), HBHCommon.DefaultShipOperatorCode), new OqlParam[0]);
                                //if (opeator != null)
                                //{
                                //    shipdto.SaleDept.ID = (opeator.DeptKey.ID);
                                //}
                            }
                            if (customer.DepartmentKey != null)
                            {
                                sodto.SaleDepartment.ID = customer.DepartmentKey.ID;
                            }
                        }
                        else
                        {
                            sodto.ShipRule.Code = HBHCommon.DefaultShipRuleCode;    // ("C001");
                            sodto.BargainMode = HBHCommon.DefaultBargainMode;    // (0);
                            sodto.ConfirmTerm = (new CommonArchiveDataDTOData());
                            sodto.ConfirmTerm.Code = HBHCommon.DefaultConfirmTermCode;  // ("01");
                        }
                        sodto.SOLines = new List<ISV.SM.SOLineDTOData>();
                        foreach (SoLineDTO srcsolinedto in dic[key])
                        {
                            UFIDA.U9.ISV.SM.SOLineDTOData solinedto2 = new UFIDA.U9.ISV.SM.SOLineDTOData();
                            solinedto2.ItemInfo = (new ItemInfoData());
                            solinedto2.ItemInfo.ItemCode = (srcsolinedto.ErpMaterialCode);
                            if (!string.IsNullOrEmpty(srcsolinedto.FinalPrice))
                            {
                                solinedto2.FinallyPriceTC = (decimal.Parse(srcsolinedto.FinalPrice));
                            }
                            if (!string.IsNullOrEmpty(srcsolinedto.Number))
                            {
                                solinedto2.OrderByQtyPU = (decimal.Parse(srcsolinedto.Number));
                            }
                            else
                            {
                                solinedto2.OrderByQtyPU = (1m);
                            }
                            if (!string.IsNullOrEmpty(srcsolinedto.Money))
                            {
                                solinedto2.TotalMoneyTC = (decimal.Parse(srcsolinedto.Money));
                            }
                            solinedto2.Project = (new CommonArchiveDataDTOData());
                            solinedto2.Project.Code = (srcsolinedto.DmsSaleNo);
                            solinedto2.SrcDocType = (SOSourceTypeEnum.Manual.Value);
                            solinedto2.RecTerm = (new CommonArchiveDataDTOData());
                            solinedto2.RecTerm.Code = (RecTerm);
                            solinedto2.DescFlexField = (new DescFlexSegmentsData());
                            solinedto2.DescFlexField.PrivateDescSeg1 = (srcsolinedto.MaterialCode);
                            solinedto2.SOShiplines = (new System.Collections.Generic.List<SOShipLineDTOData>());
                            SOShipLineDTOData soshipliendto = new SOShipLineDTOData();
                            soshipliendto.Project = (new CommonArchiveDataDTOData());
                            soshipliendto.Project.Code = (srcsolinedto.DmsSaleNo);
                            soshipliendto.ItemInfo = (new ItemInfoData());
                            soshipliendto.ItemInfo.ItemCode = (srcsolinedto.ErpMaterialCode);
                            soshipliendto.IsMRPRequire = (true);
                            soshipliendto.RequireDate = (string.IsNullOrEmpty(srcsolinedto.DeliveryDate) ? System.DateTime.Now : System.Convert.ToDateTime(srcsolinedto.DeliveryDate));
                            solinedto2.SOShiplines.Add(soshipliendto);
                            sodto.SOLines.Add(solinedto2);
                        }
                        list.Add(sodto);
                    }
                }
            }
            return list;
        }