private int RunStockItemImport(AcumaticaStockItemImportContext context, ShopifyVariant variant) { var matchingShopifySkus = _syncRepository.RetrieveNonMissingVariants(variant.StandardizedSku()); if (matchingShopifySkus.Count > 1) { _logService.Log($"Stock Item Import: {variant.LogDescriptor()} has duplicates in Shopify - aborting"); return(StockItemPutResult.NoAction); } // Attempt to Auto-match // if (variant.IsMatched()) { _logService.Log($"Stock Item Import: {variant.LogDescriptor()} already matched - aborting"); return(StockItemPutResult.NoAction); } var stockItem = _syncRepository.RetrieveStockItem(variant.StandardizedSku()); if (stockItem != null) { if (stockItem.IsMatched()) { var msg = $"Stock Item Import: {variant.LogDescriptor()} SKU already synchronized"; _logService.Log(msg); return(StockItemPutResult.NoAction); } else { var msg = $"Stock Item Import: auto-matched {stockItem.LogDescriptor()} to {variant.LogDescriptor()}"; _logService.Log(msg); _syncRepository.InsertItemSync(variant, stockItem, context.IsSyncEnabled); return(StockItemPutResult.Synchronized); } } // Abort any further processing if (context.SynchronizeOnly == true) { return(StockItemPutResult.NoAction); } // With neither duplicates or Auto-matching having succeeded, // ... we'll create a new Stock Item in Acumatica // StockItemPush(context, variant); context.VariantsForNextInventoryReceipt.Add(variant); return(StockItemPutResult.CreatedStockItem); }
public static string CreateStockItem(ShopifyVariant variant) { return($"Creating Acumatica Stock Item from {variant.LogDescriptor()}"); }