コード例 #1
0
 /// <summary>
 /// 创建出运明细行佣金
 /// </summary>
 /// <param name="DtoList"></param>
 public void CreateShipBrokerage(List <ReturnBrokerageDto> DtoList)
 {
     //删除出运明细行对应的佣金
     using (ISession removeSession = Session.Open())
     {
         for (int i = 0; i < DtoList.Count; i++)
         {
             OrderLineBrokerage.EntityList BrokerageList = OrderLineBrokerage.Finder.FindAll("ShipPlanLine=@OrderLineID", new OqlParam(DtoList[i].ShipPlanLineID));
             if (BrokerageList != null && BrokerageList.Count > 0)
             {
                 //删除出运明细行佣金
                 for (int j = 0; j < BrokerageList.Count; j++)
                 {
                     BrokerageList[j].Remove();
                 }
             }
         }
         removeSession.Commit();
     }
     using (ISession session = Session.Open())
     {
         for (int i = 0; i < DtoList.Count; i++)
         {
             ShipPlanDetailLine shipLine = ShipPlanDetailLine.Finder.FindByID(DtoList[i].ShipPlanLineID.ID);
             if (shipLine == null)
             {
                 continue;
             }
             SOLine soLine = SOLine.Finder.FindByID(shipLine.SrcLineID);
             OrderLineBrokerage.EntityList brokerage = OrderLineBrokerage.Finder.FindAll("OrderLineID='" + shipLine.SrcLineID + "'");
             if (brokerage != null && brokerage.Count > 0)
             {
                 OrderLineBrokerage shipLineBroke = null;
                 foreach (OrderLineBrokerage orderBrokerage in brokerage)
                 {
                     shipLineBroke                = OrderLineBrokerage.Create();
                     shipLineBroke.SourceType     = AllEnumBE.SourceTypeEnum.ShipPlanDoc;
                     shipLineBroke.ShipPlanLine   = shipLine;
                     shipLineBroke.ShipPlanRowNo  = shipLine.RowNo;
                     shipLineBroke.Client         = orderBrokerage.Client;
                     shipLineBroke.Product        = orderBrokerage.Product;
                     shipLineBroke.BrokerageRatio = orderBrokerage.BrokerageRatio;
                     shipLineBroke.Payee          = orderBrokerage.Payee;
                     //shipLineBroke.PayAmount = orderBrokerage.PayAmount;
                     shipLineBroke.BrokerageType = orderBrokerage.BrokerageType;
                     shipLineBroke.Prices        = orderBrokerage.Prices;
                     shipLineBroke.PayAmount     = orderBrokerage.PayAmount / soLine.OrderByQtyTU * shipLine.Qty;
                     shipLineBroke.PayCurrency   = orderBrokerage.PayCurrency;
                     //shipLineBroke.OutPayment = orderBrokerage.OutPayment;
                     shipLineBroke.OrderCurrency    = orderBrokerage.OrderCurrency;
                     shipLineBroke.Rate             = orderBrokerage.Rate;
                     shipLineBroke.SrcBrokerageLine = orderBrokerage.SrcBrokerageLine;
                 }
             }
         }
         session.Commit();
     }
 }
コード例 #2
0
        /// <summary>
        /// after Insert
        /// </summary>
        protected override void OnInserted()
        {
            SM.SO.SOLine soLine = null;
            using (ISession session = Session.Open())
            {
                decimal shippedQty = 0;
                soLine = SM.SO.SOLine.Finder.FindByID(this.SrcLineID);
                if (soLine != null)
                {
                    //校验修改的数量是否等于或者小于来源销售订单行.数量-来源销售订单行.已出运数量,
                    // 如果大于,则修改无效,不提示,将数量还原至修改前,
                    if (soLine.DescFlexField.PrivateDescSeg8 != "")
                    {
                        shippedQty = Convert.ToDecimal(soLine.DescFlexField.PrivateDescSeg8);
                    }
                    soLine.DescFlexField.PrivateDescSeg8 = (shippedQty + this.Qty).ToString();
                    #region 生成订单佣金
                    if (soLine.DescFlexField.PrivateDescSeg6.ToLower() == "true")
                    {
                        OrderLineBrokerage.EntityList brokerage = OrderLineBrokerage.Finder.FindAll("OrderLineID='" + soLine.ID + "'");
                        if (brokerage != null && brokerage.Count > 0)
                        {
                            OrderLineBrokerage shipLineBroke = null;
                            foreach (OrderLineBrokerage orderBrokerage in brokerage)
                            {
                                shipLineBroke                = OrderLineBrokerage.Create();
                                shipLineBroke.SourceType     = AllEnumBE.SourceTypeEnum.ShipPlanDoc;
                                shipLineBroke.ShipPlanLine   = this;
                                shipLineBroke.ShipPlanRowNo  = this.RowNo;
                                shipLineBroke.Client         = orderBrokerage.Client;
                                shipLineBroke.Product        = orderBrokerage.Product;
                                shipLineBroke.BrokerageRatio = orderBrokerage.BrokerageRatio;
                                shipLineBroke.Payee          = orderBrokerage.Payee;
                                shipLineBroke.Prices         = orderBrokerage.Prices;
                                //支付金额根据明细单数量计算
                                shipLineBroke.PayAmount   = orderBrokerage.PayAmount / soLine.OrderByQtyTU * this.Qty;
                                shipLineBroke.PayCurrency = orderBrokerage.PayCurrency;
                                //shipLineBroke.OutPayment = orderBrokerage.OutPayment;
                                shipLineBroke.OrderCurrency    = orderBrokerage.OrderCurrency;
                                shipLineBroke.Rate             = orderBrokerage.Rate;
                                shipLineBroke.SrcBrokerageLine = orderBrokerage.SrcBrokerageLine;
                            }
                        }
                    }
                    #endregion
                }

                session.Commit();
            }
            base.OnInserted();
            // TO DO: write your business code here...
        }
コード例 #3
0
 private void DeleteSoLineBrokerage(List <long> ids)
 {
     foreach (long id in ids)
     {
         OrderLineBrokerage doc = OrderLineBrokerage.Finder.FindByID(id);
         if (doc != null)
         {
             if (doc.OutPayment > 0)
             {
                 continue;
             }
             doc.Remove();
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// 创建销售行佣金
        /// </summary>
        /// <param name="DtoList"></param>
        public void CreateBrokerage(List <ReturnBrokerageDto> DtoList)
        {
            //佣金方式,单价,支付金额,支付币种,计算原则,佣金比例,销售订单行ID,佣金表ID
            for (int i = 0; i < DtoList.Count; i++)
            {
                SOLine             line      = SOLine.Finder.FindByID(DtoList[i].SoLineID.ID);
                OrderLineBrokerage Brokerage = OrderLineBrokerage.Create();
                Brokerage.OrderLineRowNo = line.DocLineNo;                                                                           //行号
                Brokerage.OrderLineIDKey = line.Key;                                                                                 //销售订单行ID
                Brokerage.ClientKey      = DtoList[i].Customer;                                                                      // line.customerItem.Customer.Key;//客户
                Brokerage.ProductKey     = line.ItemInfo.ItemIDKey;                                                                  //料品
                Brokerage.BrokerageType  = DtoList[i].BrokerageType;                                                                 //佣金方式
                Brokerage.Prices         = DtoList[i].Prices;                                                                        //单价
                Brokerage.BrokerageRatio = DtoList[i].Rato;                                                                          //佣金比例
                if (DtoList[i].BrokerageType == AllEnumBE.DiscountTypeEnum.FixedValues && DtoList[i].Currenty == line.OriginalTCKey) //固定值
                {
                    Brokerage.PayAmount      = DtoList[i].Prices * line.OrderByQtyPU;                                                //支付金额=佣金.单价*销售行.数量
                    Brokerage.PayCurrencyKey = DtoList[i].Currenty;                                                                  //支付币种=佣金.支付币种
                }
                else
                {                                                            //百分比
                    if (DtoList[i].Computes == AllEnumBE.ComputeEnum.IsPlan) //折扣金额前计划
                    {
                        if (!string.IsNullOrEmpty(line.DescFlexField.PrivateDescSeg5 + ""))
                        {
                            Brokerage.PayAmount = DtoList[i].Rato * line.OrderByQtyPU * Convert.ToDecimal(line.DescFlexField.PrivateDescSeg5); //支付金额=佣金.比例*销售行.数量*销售行.外销价
                        }
                        Brokerage.PayCurrencyKey = line.OriginalTCKey;                                                                         //支付币种=销售单.支付币种
                    }
                    else //折扣后金额计算
                    {
                        Brokerage.PayAmount      = DtoList[i].Prices * line.OrderByQtyPU * line.FinallyPriceTC; //支付金额=佣金.单价*销售行.数量*销售行.最终价
                        Brokerage.PayCurrencyKey = line.OriginalTCKey;                                          //支付币种=销售单.支付币种
                    }
                }

                Brokerage.SourceType = AllEnumBE.SourceTypeEnum.SelfMotion;//来源类型 ="自动产生"
                //  Brokerage.Memo;//备注
                // Brokerage.OutPayment;//已付款金额
                Brokerage.OrderCurrencyKey = line.OriginalTCKey;  //订单币种
                Brokerage.PayeeKey         = DtoList[i].PayMan;   //收款人
                Brokerage.Rate             = line.TCToCCExchRate; //汇率
            }
        }
コード例 #5
0
 /// <summary>
 /// 清空订单行佣金
 /// </summary>
 /// <param name="SolineEntity"></param>
 public void DeleteSoLineBrokerage(List <SOLine.EntityKey> SolineEntity)
 {
     for (int i = 0; i < SolineEntity.Count; i++)
     {
         OrderLineBrokerage.EntityList LineBrokerageList = OrderLineBrokerage.Finder.FindAll("OrderLineID=@OrderLineID", new OqlParam(SolineEntity[i].ID));
         if (LineBrokerageList != null)
         {
             foreach (OrderLineBrokerage doc in LineBrokerageList)
             {
                 //校验是否已生成出运明细单佣金,如果生成则需要手动清除出运明细单佣金
                 OrderLineBrokerage shipBrokerage = OrderLineBrokerage.Finder.Find("ShipPlanLine.SrcLineID=" + SolineEntity[i].ID + "");
                 if (shipBrokerage != null)
                 {
                     throw new Exception("请手动清除此销售订单对应的出运明细单佣金再重新生成");
                 }
                 if (doc.OutPayment > 0)
                 {
                     continue;
                 }
                 doc.Remove();
             }
         }
     }
 }