Ejemplo n.º 1
0
        private void UpdateShopifyVariant(AcumaticaStockItem stockItemRecord, bool setTracking)
        {
            var settings      = _settingsRepository.RetrieveSettings();
            var variantRecord = stockItemRecord.MatchedVariant();
            var stockItemObj  = _acumaticaJsonService.RetrieveStockItem(stockItemRecord.ItemId);

            // Build the Shopify DTO
            //
            var variantShopifyId = variantRecord.ShopifyVariantId;
            var variantSku       = variantRecord.ShopifySku;

            // Push the update via Variant API
            //
            var id      = variantShopifyId;
            var taxable = stockItemRecord.IsTaxable(settings).Value;

            var price =
                settings.InventorySyncPrice
                    ? (decimal)stockItemObj.DefaultPrice.value
                    : (decimal?)null;

            var grams =
                settings.InventorySyncWeight
                    ? stockItemObj.DimensionWeight.value.ToShopifyGrams()
                    : (int?)null;

            string json = VariantUpdate.Make(id, taxable, price, grams);

            _productApi.UpdateVariantPrice(variantShopifyId, json);


            using (var transaction = _syncInventoryRepository.BeginTransaction())
            {
                var log = LogBuilder.UpdateShopifyVariantPrice(variantSku, taxable, price, grams);
                _executionLogService.Log(log);

                // Update Stock Item record
                //
                stockItemRecord.IsVariantSynced = true;
                stockItemRecord.LastUpdated     = DateTime.UtcNow;

                // Update Variant record
                //
                variantRecord.ShopifyIsTaxable = taxable;
                if (price.HasValue)
                {
                    variantRecord.ShopifyPrice = price.Value;
                }
                if (setTracking)
                {
                    variantRecord.ShopifyIsTracked = true;
                }

                _syncInventoryRepository.SaveChanges();
                transaction.Commit();
            }
        }
Ejemplo n.º 2
0
 public static bool IsValidTaxCategory(this AcumaticaStockItem input, MonsterSetting settings)
 {
     return(input.IsTaxable(settings).HasValue);
 }