private PriceInformation CompletePricesWithExtraCharges(DateTimeOffset startAt, DateTimeOffset endAt, CompetenceLevel competenceLevel, List <PriceRowBase> priceListRowsPerPriceType, int rankingId, decimal?travelCost, DateTimeOffset orderCreatedDate, decimal?outlay = null, PriceRowBase requestBrokerFeeForRequisition = null)
        {
            List <PriceRowBase> allPriceRows = new List <PriceRowBase>
            {
                GetPriceRowSocialInsuranceCharge(startAt, endAt, priceListRowsPerPriceType),
                GetPriceRowAdministrativeCharge(startAt, endAt, priceListRowsPerPriceType),
                GetPriceRowBrokerFee(startAt, endAt, competenceLevel, rankingId, requestBrokerFeeForRequisition, orderCreatedDate)
            };

            allPriceRows.AddRange(priceListRowsPerPriceType);
            if (travelCost != null && travelCost > 0)
            {
                allPriceRows.Add(GetTravelCostRow(startAt.Date, startAt.Date.AddDays(1).ToDateTimeOffsetSweden(), travelCost, PriceRowType.TravelCost));
            }
            if (outlay != null && outlay > 0)
            {
                allPriceRows.Add(GetTravelCostRow(startAt.Date, startAt.Date.AddDays(1).ToDateTimeOffsetSweden(), outlay, PriceRowType.Outlay));
            }

            allPriceRows.Add(GetRoundedPriceRow(startAt, endAt, allPriceRows));

            var priceInformation = new PriceInformation
            {
                PriceRows = allPriceRows
            };

            return(priceInformation);
        }
Exemple #2
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.Reset();
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 > 1)
            {
                this.TextEncoding = (EncodingType)Utils.ReadByte(stream, ref num1);
                string text1 = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                if (!string.IsNullOrEmpty(text1))
                {
                    foreach (string text2 in text1.Split(new char[] { '/' }))
                    {
                        if (text2.Length > 3)
                        {
                            double num2;
                            string text3 = text2.Substring(3, text2.Length - 3);
                            if (double.TryParse(text3, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out num2))
                            {
                                IPriceInformation information1 = new PriceInformation();
                                information1.CurrencyCode = text2.Substring(0, 3);
                                information1.Price        = num2;
                                this.m_PriceList.Add(information1);
                            }
                        }
                    }
                }
                if (num1 > 0)
                {
                    string text4 = Utils.ReadString(EncodingType.ISO88591, stream, 8);
                    num1 -= 8;
                    if (text4.Length == 8)
                    {
                        text4 = string.Format("{0}-{1}-{2}", text4.Substring(0, 4), text4.Substring(4, 2), text4.Substring(6, 2));
                        DateTime.TryParse(text4, out this.m_ValidUntil);
                    }
                    if (num1 > 0)
                    {
                        this.ContactUrl = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                        if (num1 > 0)
                        {
                            this.ReceivedAs         = (IdSharp.Tagging.ID3v2.ReceivedAs)Utils.ReadByte(stream, ref num1);
                            this.NameOfSeller       = Utils.ReadString(this.TextEncoding, stream, ref num1);
                            this.Description        = Utils.ReadString(this.TextEncoding, stream, ref num1);
                            this.SellerLogoMimeType = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                            if (num1 > 0)
                            {
                                this.SellerLogo = Utils.Read(stream, num1);
                                num1            = 0;
                            }
                        }
                    }
                }
            }
            if (num1 != 0)
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
        }
Exemple #3
0
        protected override object AddNewCore()
        {
            IPriceInformation information1 = new PriceInformation();

            base.Add(information1);
            return(information1);
        }
Exemple #4
0
 public TrailingStopLossDetails(Instrument.Instrument instrument)
 {
    priceInformation = new PriceInformation()
    {
       instrument = instrument,
       priceProperties = new List<string>() { "distance" }
    };
 }
Exemple #5
0
 public TakeProfitDetails(Instrument.Instrument instrument)
 {
    priceInformation = new PriceInformation()
    {
       instrument = instrument,
       priceProperties = new List<string>() { "price" }
    };
 }
 public ExitOrderRequest(Instrument.Instrument oandaInstrument)
 {
    priceInformation = new PriceInformation()
    {
       instrument = oandaInstrument,
       priceProperties = new List<string>() { "price" }
    };
 }
Exemple #7
0
        protected override object AddNewCore()
        {
            IPriceInformation priceInformation = new PriceInformation();

            Add(priceInformation);

            // Not necessary to hook up event handlers, base class calls InsertItem

            return(priceInformation);
        }
 public ExitOrderRequest(Instrument.Instrument oandaInstrument)
 {
     priceInformation = new PriceInformation()
     {
         instrument      = oandaInstrument,
         priceProperties = new List <string>()
         {
             nameof(price)
         },
         unitsProperties = new List <string>()
     };
 }
 public EntryOrderRequest(Instrument.Instrument oandaInstrument)
 {
     instrument       = oandaInstrument.name;
     timeInForce      = TimeInForce.FillOrKill;
     positionFill     = OrderPositionFill.Default;
     priceInformation = new PriceInformation()
     {
         instrument      = oandaInstrument,
         priceProperties = new List <string>()
         {
             "price", "priceBound"
         }
     };
 }
Exemple #10
0
        /// <summary>
        /// Adds price information to the article.
        /// </summary>
        /// <param name="category">The category of the price (e.g. "RRP" or "Offer").</param>
        /// <param name="price">The actual price of the article specified in the smalles unit of the currency (e.g. Cent).</param>
        /// <param name="quantity">The quantity from which the price is valid.</param>
        /// <param name="basePrice">The base price of the article.</param>
        /// <param name="basePriceUnit">The base price is specified in (e.g. "100ml).</param>
        /// <param name="vat">The VAT of the article.</param>
        /// <param name="description">The description of the price information (e.g. name of a special offer).</param>
        void IDigitalShelfArticle.AddPriceInformation(PriceCategory category, decimal price, uint quantity, decimal basePrice, string basePriceUnit, string vat, string description)
        {
            if (this.PriceInformation == null)
            {
                this.PriceInformation = new List <PriceInformation>();
            }

            var priceInformation = new PriceInformation()
            {
                Category      = TextConverter.EscapeInvalidXmlChars(category.ToString()),
                Price         = price.ToString(CultureInfo.InvariantCulture),
                Quantity      = quantity.ToString(),
                BasePrice     = basePrice.ToString(CultureInfo.InvariantCulture),
                BasePriceUnit = TextConverter.EscapeInvalidXmlChars(basePriceUnit),
                VAT           = TextConverter.EscapeInvalidXmlChars(vat),
                Description   = TextConverter.EscapeInvalidXmlChars(description)
            };

            this.PriceInformation.Add(priceInformation);
        }
        public async Task ModifyMarketOrder(string accountId, OAOrder order)
        {
            SetCredentials(accountId);

            PriceInformation priceInformation = new PriceInformation();

            priceInformation.instrument = await GetInstrument(accountId, order.Instrument);

            priceInformation.priceProperties = new List <string>();

            PatchExitOrdersRequest request = new PatchExitOrdersRequest();

            request.stopLoss             = new StopLossDetails(instruments[0]);
            request.stopLoss.price       = Math.Round(order.SL, priceInformation.instrument.displayPrecision);
            request.stopLoss.timeInForce = TimeInForce.GoodUntilCancelled;

            if (order.PT > 1) // != 0, kvuli zaokrouhlovani
            {
                request.takeProfit             = new TakeProfitDetails(instruments[0]);
                request.takeProfit.price       = Math.Round(order.PT, priceInformation.instrument.displayPrecision);
                request.takeProfit.timeInForce = TimeInForce.GoodUntilCancelled;
            }
            else
            {
                request.takeProfit = null;
            }

            try
            {
                TradePatchExitOrdersResponse tradePatchExitOrdersResponse = await Rest20.PatchTradeExitOrders(accountId, order.Id, request);
            }
            catch (Exception e)
            {
                if (e.Message.IndexOf("NO_SUCH_TRADE") > 0)
                {
                    return;
                }
                throw e;
            }
        }
            public void Update(CsvRow row)
            {
                if (row != null)
                {
                    String sku = row.GetColumn(Sku).Value;

                    if (MatchingRowIds.ContainsKey(sku))
                    {
                        PriceInformation pi = MatchingRowIds[sku];
                        if (pi != null)
                        {
                            row.SetColumn(VariantCompareToPrice, pi.Msrp);
                            row.SetColumn(Option1Value, "Default Title");
                            row.SetColumn(CostPerItem, pi.CostPerItem);
                            row.SetColumn(VariantPrice, pi.Price);
                            row.SetColumn(Price, pi.Price);
                            row.SetColumn(Msrp, pi.Msrp);
                            row.SetColumn(Option1Name, "Title");
                        }
                    }
                }
            }
            public bool ApplyFilter(IFilterRow row)
            {
                bool result = false;


                if (row != null)
                {
                    String volumeAsString = row.GetColumn("cubic_volume (in.)").Value;

                    String weightAsString           = row.GetColumn(Weight).Value;
                    String priceAsString            = row.GetColumn(Price).Value;
                    String msrpAsString             = row.GetColumn(Msrp).Value;
                    String mapAsString              = row.GetColumn(Map).Value;
                    String sku                      = row.GetColumn(Sku).Value;
                    WeightCubicVolumeInformation wi = null;

                    decimal.TryParse(msrpAsString, out decimal msrp);
                    decimal.TryParse(weightAsString, out decimal weight);
                    decimal.TryParse(volumeAsString, out decimal volume);
                    decimal.TryParse(mapAsString, out decimal map);

                    if (String.IsNullOrWhiteSpace(weightAsString) == false &&
                        String.IsNullOrWhiteSpace(volumeAsString) == false)
                    {
                        if (decimal.TryParse(weightAsString, out decimal weightAsLBS) &&
                            decimal.TryParse(volumeAsString, out decimal volumeAsCubicFeet))
                        {
                            decimal gramConversionFactor = (decimal)453.59237;

                            weight = gramConversionFactor * weightAsLBS;

                            wi = new WeightCubicVolumeInformation(weight, weightAsLBS, volumeAsCubicFeet);
                        }
                    }

                    decimal.TryParse(priceAsString, out decimal price);

                    decimal costPerItem = price;

                    price = (price * (decimal)ProfitMargin);
                    if (price > (decimal)3.0)
                    {
                        price = (Math.Floor(price) + (decimal)0.47);
                    }

                    if (price < costPerItem)
                    {
                        price = (costPerItem * (decimal)ProfitMargin);
                    }

                    if (String.IsNullOrWhiteSpace(mapAsString) == false)
                    {
                        if (price < map)
                        {
                            price = Math.Floor(map) + (decimal)0.49;
                        }
                    }

                    if (msrp > 0)
                    {
                        if (price > msrp)
                        {
                            price = msrp;
                        }
                    }
                    else
                    {
                        msrp = price + (price * (decimal)0.20);
                    }

                    IFilterValue storage = row.GetColumn("storage");
                    if (storage != null && string.IsNullOrWhiteSpace(storage.Value) == false &&
                        (storage.Value == Refrigerated || storage.Value == Frozen))
                    {
                        price += (decimal)ShippingSurcharge;
                    }

                    decimal volumeShippingCost = 0;
                    decimal weightShippingCost = 0;
                    if (wi != null && ShouldAddShipping)
                    {
                        (volumeShippingCost, weightShippingCost) = ShippingCost.Get(wi);

                        if (volumeShippingCost < weightShippingCost)
                        {
                            price += weightShippingCost;
                        }
                        else
                        {
                            price += volumeShippingCost;
                        }
                    }

                    PriceInformation pi = new PriceInformation(msrp.ToString("C2"), msrp.ToString("C2"), costPerItem.ToString("C2"), price.ToString("C2"));

                    MatchingRowIds.Add(row.GetColumn(Sku).Value, pi);

                    result = true;
                }
                return(result);
            }
Exemple #14
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            Reset();

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 1)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                string priceString = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);

                if (!string.IsNullOrEmpty(priceString))
                {
                    foreach (string priceItem in priceString.Split('/'))
                    {
                        if (priceItem.Length > 3)
                        {
                            decimal price;
                            string  pricePart = priceItem.Substring(3, priceItem.Length - 3);
                            if (decimal.TryParse(pricePart, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out price))
                            {
                                IPriceInformation priceInfo = new PriceInformation();
                                priceInfo.CurrencyCode = priceItem.Substring(0, 3);
                                priceInfo.Price        = price;
                                _priceList.Add(priceInfo);
                            }
                        }
                    }
                }

                if (bytesLeft > 0)
                {
                    string validUntil = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 8);
                    bytesLeft -= 8;

                    if (validUntil.Length == 8)
                    {
                        validUntil = string.Format("{0}-{1}-{2}", validUntil.Substring(0, 4),
                                                   validUntil.Substring(4, 2), validUntil.Substring(6, 2));
                        DateTime.TryParse(validUntil, out _validUntil);
                    }

                    if (bytesLeft > 0)
                    {
                        ContactUrl = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);

                        if (bytesLeft > 0)
                        {
                            ReceivedAs         = (ReceivedAs)stream.Read1(ref bytesLeft);
                            NameOfSeller       = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                            Description        = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                            SellerLogoMimeType = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                            if (bytesLeft > 0)
                            {
                                SellerLogo = stream.Read(bytesLeft);
                                bytesLeft  = 0;
                            }
                        }
                    }
                }
            }

            if (bytesLeft != 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }