Beispiel #1
0
        public void Discount_Rule_On_Color_Level_With_End_Date_Should_Not_Return_The_Discount()
        {
            var    priceMockRepo = new Mock <IPriceRepository>();
            string productNumber = "2EB6771029";
            string currencyCode  = "EURN";
            string colorCode     = "10";
            string sizeCode      = "s";
            string discountCode  = "afp";

            priceMockRepo.Setup(c => c.GetProductPriceRules(productNumber, currencyCode)).Returns(new List <PriceResult>()
            {
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2011, 7, 7),
                    end_date      = new DateTime(2011, 7, 8),
                    price         = 5,
                    discount_code = discountCode,
                    color_code    = colorCode
                }
            });

            AssortmentHelper help = new AssortmentHelper();

            Assert.AreEqual(help.GetDiscount(productNumber, colorCode, sizeCode, priceMockRepo.Object.GetProductPriceRules(productNumber, currencyCode)), null, "Discount from PFA on color level is not as it is expected");
        }
Beispiel #2
0
        public void Older_Discounts_On_Product_Level_Should_Not_Override_Newer_Color_Levels()
        {
            var    priceMockRepo = new Mock <IPriceRepository>();
            string productNumber = "2EB6771029";
            string currencyCode  = "EURN";
            string colorCode     = "10";
            string sizeCode      = "s";
            string discountCode  = "afp";

            priceMockRepo.Setup(c => c.GetProductPriceRules(productNumber, currencyCode)).Returns(new List <PriceResult>()
            {
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2011, 7, 7),
                    price         = 7,
                    discount_code = discountCode,
                    color_code    = "5"
                },
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2011, 7, 9),
                    price         = 5,
                    discount_code = discountCode,
                    color_code    = colorCode
                },
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2011, 7, 6),
                    price         = 3,
                    discount_code = discountCode,
                },
            });

            AssortmentHelper help = new AssortmentHelper();

            var prices = priceMockRepo.Object.GetProductPriceRules(productNumber, currencyCode);

            Assert.AreEqual(help.GetDiscount(productNumber, colorCode, sizeCode, prices), 5, "Discount from PFA on color level is not as it is expected");
            Assert.AreEqual(help.GetDiscount(productNumber, "5", sizeCode, prices), 7, "Discount from PFA on color level is not as it is expected");
            Assert.AreEqual(help.GetDiscount(productNumber, "12", sizeCode, prices), 3, "Discount from PFA on color level is not as it is expected");
        }
Beispiel #3
0
        public void Discount_on_Product_Level_Later_Than_On_Color_Level()
        {
            var    priceMockRepo = new Mock <IPriceRepository>();
            string productNumber = "1512509031";
            string currencyCode  = "EURN";
            string colorCode     = "800";
            string sizeCode      = "s";

            priceMockRepo.Setup(c => c.GetProductPriceRules(productNumber, currencyCode)).Returns(new List <PriceResult>()
            {
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2012, 7, 2),
                    price         = 49.95m,
                    discount_code = "spec"
                },
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2007, 11, 15),
                    end_date      = new DateTime(2013, 12, 31),
                    price         = 59.95m,
                    color_code    = colorCode,
                    discount_code = "tijd"
                }, new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2012, 3, 7),
                    price         = 64.95m
                },
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2012, 3, 7),
                    end_date      = new DateTime(2013, 12, 31),
                    price         = 64.95m,
                    color_code    = colorCode
                }
            });

            DateTime currentTime = new DateTime(2012, 7, 30);


            AssortmentHelper help = new AssortmentHelper();

            var prices = priceMockRepo.Object.GetProductPriceRules(productNumber, currencyCode);

            Assert.AreEqual(49.95m, help.GetDiscount(productNumber, colorCode, sizeCode, prices, currentTime), "Discount from PFA on color level is not as it is expected");
            Assert.AreEqual(64.95m, help.GetPrice(productNumber, colorCode, sizeCode, prices, currentTime), "Price from PFA on color level is not as it is expected");
        }
Beispiel #4
0
        public void Discounts_With_Date_Later_Than_Today_Should_Be_Discarded()
        {
            var    priceMockRepo = new Mock <IPriceRepository>();
            string productNumber = "2EB6771029";
            string currencyCode  = "EURN";
            string colorCode     = "10";
            string sizeCode      = "s";
            string discountCode  = "afp";

            DateTime currentTime = new DateTime(2012, 7, 20);

            priceMockRepo.Setup(c => c.GetProductPriceRules(productNumber, currencyCode)).Returns(new List <PriceResult>()
            {
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2012, 7, 20),
                    end_date      = new DateTime(2012, 7, 23),
                    price         = 15,
                    discount_code = discountCode,
                    color_code    = colorCode
                },
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2012, 7, 24),
                    end_date      = new DateTime(2012, 7, 23),
                    price         = 19.95m,
                    discount_code = discountCode,
                    color_code    = colorCode
                },
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2012, 7, 21),
                    price         = 10,
                    discount_code = discountCode,
                    color_code    = "20"
                },
            });

            AssortmentHelper help = new AssortmentHelper();

            var prices = priceMockRepo.Object.GetProductPriceRules(productNumber, currencyCode);

            Assert.AreEqual(help.GetDiscount(productNumber, colorCode, sizeCode, prices, currentTime), 15, "Discount from PFA on color level is not as it is expected");
        }
Beispiel #5
0
        public void Price_With_A_Start_Date_Later_Than_Discount_With_Start_Date_And_Earlier_End_Date_Should_Override_The_Discount()
        {
            var    priceMockRepo = new Mock <IPriceRepository>();
            string productNumber = "1512510009";
            string currencyCode  = "EURN";
            string colorCode     = "100";
            string sizeCode      = "s";
            string discountCode  = "tijd";

            DateTime currentTime = new DateTime(2012, 7, 30);

            priceMockRepo.Setup(c => c.GetProductPriceRules(productNumber, currencyCode)).Returns(new List <PriceResult>()
            {
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2012, 7, 24),
                    end_date      = new DateTime(2012, 7, 29),
                    price         = 15,
                    discount_code = discountCode,
                    color_code    = colorCode
                },
                new PriceResult()
                {
                    art_code      = productNumber,
                    currency_code = currencyCode,
                    start_date    = new DateTime(2012, 7, 30),
                    price         = 21.50m,
                    color_code    = colorCode
                }
            });

            AssortmentHelper help = new AssortmentHelper();

            var prices = priceMockRepo.Object.GetProductPriceRules(productNumber, currencyCode);

            Assert.AreEqual(null, help.GetDiscount(productNumber, colorCode, sizeCode, prices, currentTime), "Discount from PFA on color level is not as it is expected");
        }
Beispiel #6
0
        protected override void Process()
        {
            _monitoring.Notify(Name, 0);

            var vendorOverridesSetting = GetConfiguration().AppSettings.Settings["VendorIDOverrides"].Try(c => c.Value, string.Empty);

            if (!string.IsNullOrEmpty(vendorOverridesSetting))
            {
                _vendorIDs = (from p in vendorOverridesSetting.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                              select Convert.ToInt32(p)).ToList();
            }

            var cultureInfoAmerican = CultureInfo.InvariantCulture;
            List <ProductAttributeMetaData> attributes = new List <ProductAttributeMetaData>();

            string connectionString      = string.Empty;
            string stockConnectionString = string.Empty;
            var    pluginConfig          = GetConfiguration();
            var    currentYear           = DateTime.Now.Year;

            using (var unit = GetUnitOfWork())
            {
                connectionString = VendorHelper.GetConnectionStringForPFA(1); //todo: fix vendorid

                CoolcatPFARepository repository = new CoolcatPFARepository(connectionString, stockConnectionString, log);
                AssortmentHelper     helper     = new AssortmentHelper();

                try
                {
                    SetupAttributes(unit, CCAttributeHelper.Attributes, out attributes);
                }
                catch (Exception e)
                {
                    log.Debug(e.InnerException);
                }

                var shopWeekLookup  = repository.GetShopWeekLookup();
                var sizeCodeLookup  = repository.GetSizeCodeLookup();
                var validArtCodes   = repository.GetValidItemNumbers();
                var colorNameLookup = repository.GetColorLookup();
                Dictionary <string, string> colorCodesDict = new Dictionary <string, string>();

                foreach (var vendorID in _vendorIDs)
                {
                    try
                    {
                        _monitoring.Notify(Name, vendorID);
#if DEBUG
                        if (vendorID != 15)
                        {
                            continue;
                        }
#endif

                        Dictionary <string, int> justArrivedCounters = new Dictionary <string, int>();
                        var vendor = unit.Scope.Repository <Vendor>().GetSingle(c => c.VendorID == vendorID);
                        var shouldNotCheckForSolden        = vendor.VendorSettings.GetValueByKey <bool>("NonSoldenVendor", false);
                        var vendorDoesNotImportDescription = vendor.VendorSettings.GetValueByKey <bool>("VendorDoesNotImportDescriptions", false);
                        var countryCode = VendorHelper.GetCountryCode(vendorID);
                        log.Info("Starting import for vendor " + vendor.Name);

                        var connectorID = vendor.ContentProducts.Select(x => x.ConnectorID).FirstOrDefault();

                        bool isSolden;

                        if (shouldNotCheckForSolden)
                        {
                            isSolden = true;
                        }
                        else if (connectorID == null || !GetSoldenPeriod(connectorID, out isSolden))
                        {
                            throw new Exception("Solden period values are corrupt.");
                        }

                        var parentVendorID = vendor.ParentVendorID.HasValue ? vendor.ParentVendorID.Value : vendor.VendorID;

                        var currencyCode = vendor.VendorSettings.FirstOrDefault(c => c.SettingKey == "PFACurrencyCode").Try(c => c.Value, string.Empty);
                        currencyCode.ThrowIfNullOrEmpty(new InvalidOperationException("Missing PFA currency code"));


                        List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorAssortmentItem> items          = new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorAssortmentItem>();
                        List <Concentrator.Objects.Vendors.Bulk.VendorBarcodeBulk.VendorImportBarcode>     vendorBarcodes = new List <VendorBarcodeBulk.VendorImportBarcode>();

                        log.Info("Found products in total: " + validArtCodes.Count());

                        int counter = 0;

                        foreach (var itemNumber in validArtCodes)
                        {
                            var productInfo = repository.GetGeneralProductInformation(itemNumber, countryCode);
                            //productInfo.TaxRate = productInfo.TaxRate.Replace("%", string.Empty);
                            var rate = helper.GetCurrentBTWRate(productInfo.TaxRatePercentage, productInfo.TaxRateDates, 21, productInfo.TaxCode);

                            counter++;
                            if (counter % 100 == 0)
                            {
                                log.Info("Found " + counter);
                            }

                            if (!justArrivedCounters.ContainsKey(productInfo.GroupName1))
                            {
                                justArrivedCounters.Add(productInfo.GroupName1, 0);
                            }

                            var priceRules = repository.GetProductPriceRules(itemNumber, currencyCode);

                            if (!string.IsNullOrEmpty(productInfo.override_tax_code))
                            {
                                rate = helper.GetCurrentBTWRate(productInfo.override_tax_rates, productInfo.override_tax_dates, 21, productInfo.override_tax_code);
                            }


                            DateTime?weekShop = null;

                            shopWeekLookup.TryGetValue(itemNumber, out weekShop);

                            Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorAssortmentItem itemToAdd = null;
                            if (itemNumber != PfaCoolcatConfiguration.Current.ShipmentCostsProduct && itemNumber != PfaCoolcatConfiguration.Current.ReturnCostsProduct &&
                                itemNumber != PfaCoolcatConfiguration.Current.KialaShipmentCostsProduct && itemNumber != PfaCoolcatConfiguration.Current.KialaReturnCostsProduct)
                            {
                                itemToAdd = new Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorAssortmentItem
                                {
                                    BrandVendors = new List <VendorAssortmentBulk.VendorImportBrand>()
                                    {
                                        GetVendorBrand(vendorID)
                                    },
                                    VendorProduct               = GetVendorProduct(itemNumber, productInfo.ShortDescription, productInfo.Material, vendorID, parentVendorID, true, productInfo.GroupCode1, productInfo.GroupName1, productInfo.GroupCode2, productInfo.GroupName2, productInfo.GroupCode3, productInfo.GroupName3),
                                    VendorProductDescriptions   = vendorDoesNotImportDescription ? new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorProductDescription>() : GetProductDescriptions(itemNumber, vendorID, parentVendorID, productInfo, _languageIDs),
                                    VendorImportAttributeValues = GetAttributesOnConfigurableLevel(productInfo, itemNumber, attributes, CONCENTRATOR_VENDOR_ID, vendorID),
                                    RelatedProducts             = new List <VendorAssortmentBulk.VendorImportRelatedProduct>(),
                                    VendorImportPrices          = new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportPrice>()
                                    {
                                        GetVendorPrice(vendorID, parentVendorID, itemNumber, "0", rate.ToString(cultureInfoAmerican), "0", LEVEL_NOT_EXPORTABLE_STATUS)
                                    },
                                    VendorImportStocks = new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportStock>()
                                };
                                items.Add(itemToAdd);
                            }
                            int?shopWeekNumber = null;
                            if (weekShop.HasValue)
                            {
                                Calendar cal = new CultureInfo("nl-NL").Calendar;
                                shopWeekNumber = cal.GetWeekOfYear(weekShop.Value, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);
                            }

                            if (itemToAdd != null && shopWeekNumber.HasValue)
                            {
                                itemToAdd.VendorImportAttributeValues.Add(new Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportAttributeValue()
                                {
                                    AttributeCode    = SHOP_WEEK_ATTRIBUTE_CODE,
                                    Value            = weekShop.Value.Year.ToString() + shopWeekNumber.ToString().PadLeft(2, '0'),
                                    AttributeID      = attributes.FirstOrDefault(c => c.AttributeCode == SHOP_WEEK_ATTRIBUTE_CODE).AttributeID,
                                    CustomItemNumber = itemNumber,
                                    DefaultVendorID  = vendorID,
                                    LanguageID       = null,
                                    VendorID         = CONCENTRATOR_VENDOR_ID
                                });
                            }

                            var skus     = repository.GetValidSkus(itemNumber);
                            var skuSpecs = repository.GetSkuSpecifications(itemNumber);

                            //process color level
                            foreach (var colorLevel in skus.GroupBy(c => c.ColorCode))
                            {
                                var colorItemNumber = string.Format("{0} {1}", itemNumber, colorLevel.Key).Trim();

                                Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorAssortmentItem colorLevelProduct = null;

                                if (itemNumber != PfaCoolcatConfiguration.Current.ShipmentCostsProduct && itemNumber != PfaCoolcatConfiguration.Current.ReturnCostsProduct &&
                                    itemNumber != PfaCoolcatConfiguration.Current.KialaShipmentCostsProduct && itemNumber != PfaCoolcatConfiguration.Current.KialaReturnCostsProduct)
                                {
                                    colorLevelProduct = new Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorAssortmentItem()
                                    {
                                        BrandVendors = new List <VendorAssortmentBulk.VendorImportBrand>()
                                        {
                                            GetVendorBrand(vendorID)
                                        },
                                        VendorProduct               = GetVendorProduct(colorItemNumber, productInfo.ShortDescription, productInfo.Material, vendorID, parentVendorID, true, productInfo.GroupCode1, productInfo.GroupName1, productInfo.GroupCode2, productInfo.GroupName2, productInfo.GroupCode3, productInfo.GroupName3, parentCustomItemNumber: itemNumber),
                                        VendorProductDescriptions   = vendorDoesNotImportDescription ? new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorProductDescription>() : GetProductDescriptions(colorItemNumber, vendorID, parentVendorID, productInfo, _languageIDs),
                                        VendorImportAttributeValues = GetAttributesOnConfigurableLevel(productInfo, colorItemNumber, attributes, CONCENTRATOR_VENDOR_ID, vendorID),
                                        RelatedProducts             = new List <VendorAssortmentBulk.VendorImportRelatedProduct>(
                                            (from rp in skus.GroupBy(c => c.ColorCode)
                                             where rp.Key != colorLevel.Key
                                             select new Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportRelatedProduct()
                                        {
                                            CustomItemNumber = colorItemNumber,
                                            DefaultVendorID = vendorID,
                                            VendorID = vendorID,
                                            IsConfigured = 0,
                                            RelatedCustomItemNumber = string.Format("{0} {1}", itemNumber, rp.Key).Trim(),
                                            RelatedProductType = "Related Color Level"
                                        }).ToList()
                                            ),
                                        VendorImportPrices = new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportPrice>()
                                        {
                                            GetVendorPrice(vendorID, parentVendorID, colorItemNumber, "0", rate.ToString(cultureInfoAmerican), "0")
                                        },
                                        VendorImportStocks = new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportStock>()
                                    };

                                    if (colorLevelProduct != null && shopWeekNumber.HasValue)
                                    {
                                        colorLevelProduct.VendorImportAttributeValues.Add(new Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportAttributeValue()
                                        {
                                            AttributeCode    = SHOP_WEEK_ATTRIBUTE_CODE,
                                            Value            = weekShop.Value.Year.ToString() + shopWeekNumber.ToString().PadLeft(2, '0'),
                                            AttributeID      = attributes.FirstOrDefault(c => c.AttributeCode == SHOP_WEEK_ATTRIBUTE_CODE).AttributeID,
                                            CustomItemNumber = colorItemNumber,
                                            DefaultVendorID  = vendorID,
                                            LanguageID       = null,
                                            VendorID         = CONCENTRATOR_VENDOR_ID
                                        });
                                    }

                                    items.Add(colorLevelProduct);

                                    if (itemToAdd != null)
                                    {
                                        itemToAdd.RelatedProducts.Add(new VendorAssortmentBulk.VendorImportRelatedProduct()
                                        {
                                            CustomItemNumber        = itemNumber,
                                            RelatedCustomItemNumber = colorItemNumber,
                                            IsConfigured            = 0,
                                            DefaultVendorID         = parentVendorID,
                                            VendorID           = vendorID,
                                            RelatedProductType = "Style"
                                        });
                                    }
                                }

                                if (justArrivedCounters[productInfo.GroupName1] < 60)
                                {
                                    if (weekShop.HasValue)
                                    {
                                        var daysInRange = (DateTime.Now - weekShop.Value).Days;
                                        if (daysInRange >= 0 && daysInRange <= 14)
                                        {
                                            if (colorLevelProduct != null)
                                            {
                                                colorLevelProduct.VendorProduct.VendorProductGroupCode4 = "Just arrived";

                                                colorLevelProduct.VendorProduct.VendorProductGroupCodeName4 = "Just arrived";
                                                justArrivedCounters[productInfo.GroupName1]++;
                                            }
                                        }
                                    }
                                }

                                foreach (var sku in colorLevel)
                                {
                                    var skuBarcode = CompleteBarcode(sku.Barcode);

                                    int webshopStock  = 0;
                                    int ceyenneStock  = 0;
                                    int transferStock = 0;
                                    int wmsStock      = 0;

                                    string sizeCodePfa = sku.SizeCode;

                                    foreach (var lookupT in new List <string>()
                                    {
                                        productInfo.MtbCode1, productInfo.MtbCode2, productInfo.MtbCode3, productInfo.MtbCode4
                                    })
                                    {
                                        var lookup = sizeCodeLookup.FirstOrDefault(c => c.SizeCode.ToLower() == sku.SizeCode.ToLower() && c.MtbCode.ToLower() == lookupT.ToLower());
                                        if (lookup != null)
                                        {
                                            sizeCodePfa = lookup.PfaCode;
                                            break;
                                        }
                                    }

                                    var product = new Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorAssortmentItem();

                                    string skuNew = string.Empty;
                                    if (itemNumber == PfaCoolcatConfiguration.Current.ShipmentCostsProduct || itemNumber == PfaCoolcatConfiguration.Current.ReturnCostsProduct ||
                                        itemNumber == PfaCoolcatConfiguration.Current.KialaShipmentCostsProduct || itemNumber == PfaCoolcatConfiguration.Current.KialaReturnCostsProduct)
                                    {
                                        skuNew = itemNumber;
                                    }
                                    else
                                    {
                                        skuNew = string.Format("{0} {1} {2}", itemNumber, sku.ColorCode, sku.SizeCode);
                                    }

                                    Concentrator.Objects.Vendors.Bulk.VendorBarcodeBulk.VendorImportBarcode bc = new VendorBarcodeBulk.VendorImportBarcode()
                                    {
                                        CustomItemNumber = skuNew,
                                        Barcode          = sizeCodePfa,
                                        Type             = 4,
                                        VendorID         = 1
                                    };

                                    vendorBarcodes.Add(bc);

                                    var price    = helper.GetPrice(itemNumber, sku.ColorCode, sku.SizeCode, priceRules);
                                    var discount = helper.GetDiscount(itemNumber, sku.ColorCode, sku.SizeCode, priceRules);

                                    if (!isSolden)
                                    {
                                        if (discount.HasValue)
                                        {
                                            price    = discount.Value;
                                            discount = null;
                                        }
                                    }

                                    var item = items.Where(c => c.VendorProduct.CustomItemNumber == itemNumber);
                                    if (item == null)
                                    {
                                        continue;
                                    }


                                    product = new Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorAssortmentItem()
                                    {
                                        VendorProduct             = GetVendorProduct(skuNew, productInfo.ShortDescription, productInfo.LongDescription, vendorID, parentVendorID, false, productInfo.GroupCode1, productInfo.GroupName1, productInfo.GroupCode2, productInfo.GroupName2, productInfo.GroupCode3, productInfo.GroupName3, parentCustomItemNumber: colorItemNumber, barcode: skuBarcode),
                                        VendorProductDescriptions = vendorDoesNotImportDescription ? new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorProductDescription>() : GetProductDescriptions(skuNew, vendorID, parentVendorID, productInfo, _languageIDs),
                                        BrandVendors = new List <VendorAssortmentBulk.VendorImportBrand>()
                                        {
                                            GetVendorBrand(vendorID)
                                        },
                                        VendorImportAttributeValues = (from m in CCAttributeHelper.Attributes
                                                                       where m.Configurable
                                                                       let aM = attributes.FirstOrDefault(c => c.AttributeCode.ToLower() == m.Code.ToLower())
                                                                                select new Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportAttributeValue
                                        {
                                            AttributeCode = aM.AttributeCode,
                                            AttributeID = aM.AttributeID,
                                            CustomItemNumber = skuNew,
                                            DefaultVendorID = vendorID,
                                            LanguageID = null,
                                            VendorID = CONCENTRATOR_VENDOR_ID,
                                            Value = (m.Code.ToLower() == "color" ? sku.ColorCode : sku.SizeCode)
                                        }).ToList(),

                                        RelatedProducts    = new List <VendorAssortmentBulk.VendorImportRelatedProduct>(),
                                        VendorImportPrices = new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportPrice>()
                                        {
                                            GetVendorPrice(vendorID, parentVendorID, skuNew, price.ToString(cultureInfoAmerican), rate.ToString(cultureInfoAmerican), (discount.HasValue && discount.Value < price)? discount.Value.ToString(cultureInfoAmerican) :null)
                                        },

                                        VendorImportStocks = new List <Concentrator.Objects.Vendors.Bulk.VendorAssortmentBulk.VendorImportStock>()
                                    };


                                    if ((discount.HasValue && discount.Value > 0) && (price != discount))
                                    {
                                        if (itemToAdd != null)
                                        {
                                            //That is because code4 might be filled with just arrived
                                            if (string.IsNullOrEmpty(colorLevelProduct.VendorProduct.VendorProductGroupCode4))
                                            {
                                                colorLevelProduct.VendorProduct.VendorProductGroupCode4     = "SALE";
                                                colorLevelProduct.VendorProduct.VendorProductGroupCodeName4 = "SALE";
                                            }
                                            else
                                            {
                                                colorLevelProduct.VendorProduct.VendorProductGroupCode5     = "SALE";
                                                colorLevelProduct.VendorProduct.VendorProductGroupCodeName5 = "SALE";
                                            }

                                            if (string.IsNullOrEmpty(itemToAdd.VendorProduct.VendorProductGroupCode4))
                                            {
                                                itemToAdd.VendorProduct.VendorProductGroupCode4     = "SALE";
                                                itemToAdd.VendorProduct.VendorProductGroupCodeName4 = "SALE";
                                            }
                                            else
                                            {
                                                itemToAdd.VendorProduct.VendorProductGroupCode5     = "SALE";
                                                itemToAdd.VendorProduct.VendorProductGroupCodeName5 = "SALE";
                                            }

                                            if (string.IsNullOrEmpty(product.VendorProduct.VendorProductGroupCode4))
                                            {
                                                product.VendorProduct.VendorProductGroupCode4     = "SALE";
                                                product.VendorProduct.VendorProductGroupCodeName4 = "SALE";
                                            }
                                            else
                                            {
                                                product.VendorProduct.VendorProductGroupCode5     = "SALE";
                                                product.VendorProduct.VendorProductGroupCodeName5 = "SALE";
                                            }
                                        }
                                    }

                                    var attributeColorRows = skuSpecs.Where(c => c.ColorCode == sku.ColorCode).ToList();

                                    var mentality  = GetAttributeValue(attributeColorRows, "Mentality");
                                    var input      = GetAttributeValue(attributeColorRows, "Input");
                                    var Style      = GetAttributeValue(attributeColorRows, "Style");
                                    var Usermoment = GetAttributeValue(attributeColorRows, "Usermoment");
                                    var Module     = GetAttributeValue(attributeColorRows, "Module");

                                    AddAttributeValue(itemToAdd, "Mentality", mentality, attributes, itemNumber, CONCENTRATOR_VENDOR_ID, vendorID);
                                    AddAttributeValue(itemToAdd, "Style", Style, attributes, itemNumber, CONCENTRATOR_VENDOR_ID, vendorID);
                                    AddAttributeValue(itemToAdd, "Usermoment", Usermoment, attributes, itemNumber, CONCENTRATOR_VENDOR_ID, vendorID);
                                    AddAttributeValue(product, "Module", Module, attributes, skuNew, CONCENTRATOR_VENDOR_ID, vendorID);
                                    AddAttributeValue(itemToAdd, "InputCode", input, attributes, itemNumber, CONCENTRATOR_VENDOR_ID, vendorID);
                                    AddAttributeValue(itemToAdd, "Gender", DetermineGenderByVendorItemNumber(itemNumber), attributes, itemNumber, CONCENTRATOR_VENDOR_ID, vendorID);

                                    items.Add(product);
                                    if (colorLevelProduct != null)
                                    {
                                        //relate to main product
                                        if (colorLevelProduct.RelatedProducts.Where(c => c.CustomItemNumber == colorItemNumber && c.RelatedCustomItemNumber == skuNew).FirstOrDefault() == null)
                                        {
                                            colorLevelProduct.RelatedProducts.Add(new VendorAssortmentBulk.VendorImportRelatedProduct()
                                            {
                                                CustomItemNumber        = colorItemNumber,
                                                DefaultVendorID         = parentVendorID,
                                                IsConfigured            = 1,
                                                RelatedCustomItemNumber = skuNew,
                                                RelatedProductType      = "Configured product",
                                                VendorID = vendorID
                                            });
                                        }
                                    }
                                }
                            }
                        }

                        var bulkConfig = new VendorAssortmentBulkConfiguration();
                        using (var vendorAssortmentBulk = new VendorAssortmentBulk(items, vendorID, parentVendorID, bulkConfig))
                        {
                            vendorAssortmentBulk.Init(unit.Context);
                            vendorAssortmentBulk.Sync(unit.Context);
                        }

                        using (var barcodeBulk = new VendorBarcodeBulk(vendorBarcodes, vendorID, 4))
                        {
                            barcodeBulk.Init(unit.Context);
                            barcodeBulk.Sync(unit.Context);
                        }
                    }
                    catch (Exception e)
                    {
                        log.AuditCritical("Import failed for vendor " + vendorID, e);
                        _monitoring.Notify(Name, -vendorID);
                    }
                }
                AddValueLabels(unit, colorCodesDict);
                ConfigureProductAttributes(_vendorIDs, unit);
            }
            _monitoring.Notify(Name, 1);
        }