Beispiel #1
0
        protected void LMECarryPositionDetailVMPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var position1 = new LMEPosition
            {
                QuotaId = SelectedQuotaId,
                InternalBPId = ICId,
                TradeDate = TradeDate,
                ClientId = SelectedBPartnerId,
                CommodityId = SelectedMetal,
                AgentId = BrokerId,
                PromptDate = PromptDate,
                LotAmount = LotAmount,
                TradeDirection = TradeDirection,
                PositionType = PositionType,
                Comment = Comment,
                AgentPrice = AgentPrice,
                ClientPrice = ClientPrice,
                ClientCommission = ClientCommission,
                AgentCommission = AgentCommission,
            };

            var position2 = new LMEPosition
            {
                QuotaId = SelectedQuotaId,
                InternalBPId = ICId,
                TradeDate = TradeDate,
                ClientId = SelectedBPartnerId,
                CommodityId = SelectedMetal,
                AgentId = BrokerId,
                PromptDate = PromptDate2,
                LotAmount = LotAmount,
                TradeDirection = TradeDirection2,
                PositionType = PositionType2,
                Comment = Comment,
                AgentPrice = AgentPrice2,
                ClientPrice = ClientPrice2,
                ClientCommission = ClientCommission2,
                AgentCommission = AgentCommission2,
            };

            if (e.PropertyName == "BPartnerName")
            {
                BPartnerName2 = BPartnerName;
            }
            if (e.PropertyName == "TradeDirection")
            {
                if (TradeDirection != null || TradeDirection > 0)
                {
                    if (TradeDirection == (int) PositionDirection.Long)
                    {
                        TradeDirection2 = (int) PositionDirection.Short;
                    }
                    else if (TradeDirection == (int) PositionDirection.Short)
                    {
                        TradeDirection2 = (int) PositionDirection.Long;
                    }
                }
            }
            if (e.PropertyName == "PositionType")
            {
                if (PositionType != null || PositionType > 0)
                {
                    PositionType2 = PositionType;
                }
            }

            decimal? commissionValue1 = 0;
            decimal? commissionValue2 = 0;
            using (var commissionService = SvcClientManager.GetSvcClient<CommissionServiceClient>(SvcType.CommissionSvc)
                )
            {
                if (e.PropertyName == "TradeDate" || e.PropertyName == "PromptDate" || e.PropertyName == "PromptDate2" || e.PropertyName == "ICId" ||
                    e.PropertyName == "SelectedMetal" || e.PropertyName == "SelectedBPartnerId" ||
                    e.PropertyName == "ClientPrice" || e.PropertyName == "LotAmount" || e.PropertyName == "ClientPrice2")
                {
                    commissionService.GetCarryCommissionValue(position1, position2, SelectedBPartnerId, ClientPrice, ClientPrice2, ref commissionValue1, ref commissionValue2, CurrentUser.Id);
                    ClientCommission = commissionValue1;
                    ClientCommission2 = commissionValue2;
                }
                if (e.PropertyName == "TradeDate" || e.PropertyName == "PromptDate" || e.PropertyName == "PromptDate2" || e.PropertyName == "ICId" ||
                    e.PropertyName == "SelectedMetal" || e.PropertyName == "BrokerId" || e.PropertyName == "AgentPrice" || e.PropertyName == "AgentPrice2" ||
                    e.PropertyName == "LotAmount")
                {
                    commissionService.GetCarryCommissionValue(position1, position2, BrokerId, AgentPrice, AgentPrice2, ref commissionValue1, ref commissionValue2, CurrentUser.Id);
                    AgentCommission = commissionValue1;
                    AgentCommission2 = commissionValue2;
                }
            }
        }
Beispiel #2
0
        protected override void Create()
        {
            using (
                var lmePositionService = SvcClientManager.GetSvcClient<LMEPositionServiceClient>(SvcType.LMEPositionSvc)
                )
            {
                var lmePosition = new LMEPosition
                                      {
                                          QuotaId = SelectedQuotaId,
                                          InternalBPId = ICId,
                                          TradeDate = TradeDate,
                                          ClientId = SelectedBPartnerId,
                                          CommodityId = SelectedMetal,
                                          AgentId = BrokerId,
                                          PromptDate = PromptDate,
                                          LotAmount = LotAmount,
                                          TradeDirection = TradeDirection,
                                          PositionType = PositionType,
                                          Comment = Comment,
                                          AgentPrice = AgentPrice,
                                          ClientPrice = ClientPrice,
                                          ClientCommission = ClientCommission,
                                          AgentCommission = AgentCommission,
                                      };
                var lmePosition2 = new LMEPosition
                                       {
                                           QuotaId = SelectedQuotaId,
                                           InternalBPId = ICId,
                                           TradeDate = TradeDate,
                                           ClientId = SelectedBPartnerId,
                                           CommodityId = SelectedMetal,
                                           AgentId = BrokerId,
                                           PromptDate = PromptDate2,
                                           LotAmount = LotAmount,
                                           TradeDirection = TradeDirection2,
                                           PositionType = PositionType2,
                                           Comment = Comment,
                                           AgentPrice = AgentPrice2,
                                           ClientPrice = ClientPrice2,
                                           ClientCommission = ClientCommission2,
                                           AgentCommission = AgentCommission2,
                                       };


                lmePositionService.CreateNewCarryLMEPosition(lmePosition, lmePosition2, CurrentUser.Id);
            }
        }
Beispiel #3
0
     private void FixupLMEPosition(LMEPosition previousValue)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.HedgeLineLMEPositions.Contains(this))
         {
             previousValue.HedgeLineLMEPositions.Remove(this);
         }
 
         if (LMEPosition != null)
         {
             if (!LMEPosition.HedgeLineLMEPositions.Contains(this))
             {
                 LMEPosition.HedgeLineLMEPositions.Add(this);
             }
 
             LMEPositionId = LMEPosition.Id;
         }
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("LMEPosition")
                 && (ChangeTracker.OriginalValues["LMEPosition"] == LMEPosition))
             {
                 ChangeTracker.OriginalValues.Remove("LMEPosition");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("LMEPosition", previousValue);
             }
             if (LMEPosition != null && !LMEPosition.ChangeTracker.ChangeTrackingEnabled)
             {
                 LMEPosition.StartTracking();
             }
         }
     }