Ejemplo n.º 1
0
        public async Task UpdateSkusQuantitiesAsync__NotPushingToBins_MultipleItems()
        {
            var inventory = new Dictionary <string, NetSuiteItemQuantity>();

            var random = new Random();

            for (int i = 1; i <= 18; i++)
            {
                // item with bins
                if (i == 6)
                {
                    continue;
                }

                var binQuantity = new NetSuiteItemQuantity
                {
                    AvailableQuantity = random.Next(1, 100)
                };
                inventory.Add("NS-testsku" + i.ToString(), binQuantity);
            }

            await this._itemsService.UpdateSkusQuantitiesAsync(AccountId, _locationSkuVaultNoBins.name, inventory, NetSuiteInventoryBinsModeEnum.ItemsNotInBins, CancellationToken.None, Mark.Blank());

            foreach (var inventoryItem in inventory)
            {
                try
                {
                    int currentQuantity = await this._itemsService.GetItemQuantityAsync(inventoryItem.Key, _locationSkuVaultNoBins.internalId, CancellationToken.None);

                    currentQuantity.Should().Be(inventoryItem.Value.AvailableQuantity);
                }
                catch (NetSuiteItemNotFoundException)
                { }
            }
        }
Ejemplo n.º 2
0
        // Seems to fail randomly. Try running again a few times if failing.
        public async Task UpdateSkusQuantitiesAsync_PushingToBins_ItemAndLocationUsesBins_BinIsNotAssociatedWithItem()
        {
            int          newQuantity  = new Random().Next(1, 100);
            const string testsku      = "GUARD528-test1";
            const string binNumber    = "1999";
            var          token        = CancellationToken.None;
            var          itemQuantity = new NetSuiteItemQuantity
            {
                AvailableQuantity = 0,
                BinQuantities     = new []
                {
                    new NetSuiteBinQuantity(_locationBostonBins.name, binNumber, newQuantity)
                }
            };
            var skuLocationQuantities = new Dictionary <string, NetSuiteItemQuantity>
            {
                { testsku, itemQuantity }
            };
            var binQuantityBefore = await GetItemBinQuantityAsync(testsku, _locationBostonBins.internalId, binNumber);

            var itemQuantityBefore = await this._itemsService.GetItemQuantityAsync(testsku, _locationBostonBins.internalId, CancellationToken.None);

            await this._itemsService.UpdateSkusQuantitiesAsync(AccountId, _locationBostonBins.name, skuLocationQuantities,
                                                               NetSuiteInventoryBinsModeEnum.ItemsInBins, token, Mark.Blank());

            var updatedBinQuantity = await GetItemBinQuantityAsync(testsku, _locationBostonBins.internalId, binNumber);;

            updatedBinQuantity.Should().Be(binQuantityBefore);
            var itemQuantityAfter = await this._itemsService.GetItemQuantityAsync(testsku, _locationBostonBins.internalId, CancellationToken.None);

            itemQuantityAfter.Should().Be(itemQuantityBefore);
        }
Ejemplo n.º 3
0
        public async Task UpdateSkusQuantitiesAsync_PushingToBins_BinAssociatedWithItemButInAnotherLocation()
        {
            var          newQuantity  = new Random().Next(1, 100);
            const string testSku      = "GUARD528-test1";
            const string locationName = "San Francisco";
            const string locationId   = "1";
            const string binNumber    = "1004";                 //in the Boston location
            var          token        = CancellationToken.None;

            var itemQuantity = new NetSuiteItemQuantity
            {
                BinQuantities = new []
                {
                    new NetSuiteBinQuantity(locationName, binNumber, newQuantity)
                }
            };
            var skuLocationQuantities = new Dictionary <string, NetSuiteItemQuantity>
            {
                { testSku, itemQuantity }
            };
            var binQuantityBefore = await GetItemBinQuantityAsync(testSku, locationId, binNumber);

            var itemQuantityBefore = await this._itemsService.GetItemQuantityAsync(testSku, locationName, CancellationToken.None);

            await this._itemsService.UpdateSkusQuantitiesAsync(AccountId, locationName, skuLocationQuantities,
                                                               NetSuiteInventoryBinsModeEnum.ItemsInBins, token, Mark.Blank());

            var binQuantityAfter = await GetItemBinQuantityAsync(testSku, locationId, binNumber);;

            binQuantityAfter.Should().Be(binQuantityBefore);
            var itemQuantityAfter = await this._itemsService.GetItemQuantityAsync(testSku, locationName, CancellationToken.None);

            itemQuantityAfter.Should().Be(itemQuantityBefore);
        }
Ejemplo n.º 4
0
        public void UpdateParentSkuQuantityAsync()
        {
            const string sku = "TestParent3";

            var locationQuantity = new NetSuiteItemQuantity
            {
                AvailableQuantity = 10
            };
            var inventory = new Dictionary <string, NetSuiteItemQuantity>
            {
                { sku, locationQuantity }
            };

            Assert.DoesNotThrowAsync(async() =>
            {
                await this._itemsService.UpdateSkusQuantitiesAsync(AccountId, _locationSkuVaultNoBins.name, inventory, NetSuiteInventoryBinsModeEnum.Both, CancellationToken.None, Mark.Blank());
            });
        }
Ejemplo n.º 5
0
        public async Task UpdateSkusQuantitiesAsync_PushItemsThatUsesBinsAndItemThatDoesnt()
        {
            int          newQuantity = new Random().Next(1, 100);
            const string testSkuBin  = "GUARD528-test1";
            const string binNumber   = "1004";

            int          newQuantityNoBin = new Random().Next(1, 100);
            const string testSkuNoBin     = "NS-testsku99";

            var token         = CancellationToken.None;
            var binQuantities = new NetSuiteItemQuantity
            {
                BinQuantities = new []
                {
                    new NetSuiteBinQuantity(_locationBostonBins.name, binNumber, newQuantity)
                }
            };
            var unBinnedQuantities = new NetSuiteItemQuantity
            {
                AvailableQuantity = newQuantityNoBin
            };
            var skuBinQuantities = new Dictionary <string, NetSuiteItemQuantity>
            {
                { testSkuBin, binQuantities },
                { testSkuNoBin, unBinnedQuantities }
            };

            await this._itemsService.UpdateSkusQuantitiesAsync(AccountId, _locationBostonBins.name, skuBinQuantities,
                                                               NetSuiteInventoryBinsModeEnum.Both, token, Mark.Blank());

            var updatedBinQuantity = await GetItemBinQuantityAsync(testSkuBin, _locationBostonBins.internalId, binNumber);

            updatedBinQuantity.Should().Be(newQuantity);
            var updatedNoBinQuantity = await this._itemsService.GetItemQuantityAsync(testSkuNoBin, _locationBostonBins.internalId, CancellationToken.None);

            updatedNoBinQuantity.Should().Be(newQuantityNoBin);
        }
Ejemplo n.º 6
0
        public async Task UpdateSkusQuantitiesAsync_PushingToBins_ZerosOutBinsNotPushed()
        {
            var          nonZeroQuantity    = new Random().Next(1, 100);
            const string testsku            = "GUARD528-test1";
            const string binNumberToZeroOut = "1004";
            const string anotherBinNumber   = "1001";
            var          token = CancellationToken.None;

            var itemQuantity = new NetSuiteItemQuantity
            {
                BinQuantities = new []
                {
                    new NetSuiteBinQuantity(_locationBostonBins.name, binNumberToZeroOut, nonZeroQuantity)
                }
            };
            var skuLocationQuantities = new Dictionary <string, NetSuiteItemQuantity>
            {
                { testsku, itemQuantity }
            };

            //Push non-zero to binNumberToZeroOut
            await this._itemsService.UpdateSkusQuantitiesAsync(AccountId, _locationBostonBins.name, skuLocationQuantities,
                                                               NetSuiteInventoryBinsModeEnum.ItemsInBins, token, Mark.Blank());

            //Push to anotherBinNumber
            itemQuantity.BinQuantities.First().BinNumber = anotherBinNumber;
            await this._itemsService.UpdateSkusQuantitiesAsync(AccountId, _locationBostonBins.name, skuLocationQuantities,
                                                               NetSuiteInventoryBinsModeEnum.ItemsInBins, token, Mark.Blank());

            var binQuantityAfter = await GetItemBinQuantityAsync(testsku, _locationBostonBins.internalId, binNumberToZeroOut);

            binQuantityAfter.Should().Be(0);
            //Restore binNumberToZeroOut for other tests
            itemQuantity.BinQuantities.First().BinNumber = binNumberToZeroOut;
            await this._itemsService.UpdateSkusQuantitiesAsync(AccountId, _locationBostonBins.name, skuLocationQuantities,
                                                               NetSuiteInventoryBinsModeEnum.ItemsInBins, token, Mark.Blank());
        }