Exemplo n.º 1
0
        // Warehouses & Locations
        //
        public void InsertInventoryReceiptSync(ShopifyInventoryLevel level, AcumaticaInventoryReceipt receipt)
        {
            var sync = new InventoryReceiptSync();

            sync.ShopifyInventoryLevel     = level;
            sync.AcumaticaInventoryReceipt = receipt;
            sync.DateCreated = DateTime.Now;
            sync.LastUpdated = DateTime.Now;
            Entities.InventoryReceiptSyncs.Add(sync);
            Entities.SaveChanges();
        }
Exemplo n.º 2
0
        public void RunInventoryReceiptImport(string warehouseId, long shopifyProductId, List <ShopifyVariant> variants)
        {
            var inventoryForSyncing = variants.SelectMany(x => x.ShopifyInventoryLevels).ToList();

            // Push Inventory Receipt to Acumatica API
            //
            var receipt = BuildReceipt(warehouseId, inventoryForSyncing);

            if (receipt.ControlQty.value == 0)
            {
                // Empty Receipt
                return;
            }

            // Execution logging...
            //
            var shopifyProduct = _syncRepository.RetrieveProduct(shopifyProductId);
            var msg            = $"Creating Inventory Receipt for {shopifyProduct.LogDescriptor()} ({variants.Count} variants)";

            _logService.Log(msg);

            // Create Inventory Receipt in Acumatica
            //
            var resultJson   = _distributionClient.AddInventoryReceipt(receipt.SerializeToJson());
            var resultObject = resultJson.DeserializeFromJson <InventoryReceipt>();

            // Create Monster Record
            //
            var monsterReceipt = new AcumaticaInventoryReceipt();

            monsterReceipt.AcumaticaRefNumber = resultObject.ReferenceNbr.value;
            monsterReceipt.IsReleased         = false;
            monsterReceipt.DateCreated        = DateTime.UtcNow;
            monsterReceipt.LastUpdate         = DateTime.UtcNow;

            // No transaction - keep writing until you can't write no mo'!
            //
            _inventoryRepository.InsertInventoryReceipt(monsterReceipt);

            foreach (var level in inventoryForSyncing)
            {
                _syncRepository.InsertInventoryReceiptSync(level, monsterReceipt);
            }
        }
Exemplo n.º 3
0
 public void InsertInventoryReceipt(AcumaticaInventoryReceipt receipt)
 {
     Entities.AcumaticaInventoryReceipts.Add(receipt);
     Entities.SaveChanges();
 }