Ejemplo n.º 1
0
        private void InjectTotalsFromAcumatica(ShopifyOrder shopifyOrderRecord, OrderAnalysisTotals output)
        {
            SalesOrder acumaticaOrder    = null;
            var        acumaticaOrderNbr = shopifyOrderRecord.AcumaticaSalesOrder.AcumaticaOrderNbr;

            _acumaticaHttpContext.SessionRun(() =>
            {
                var json = _salesOrderClient
                           .RetrieveSalesOrder(acumaticaOrderNbr, SalesOrderType.SO, Expand.Totals);
                acumaticaOrder = json.ToSalesOrderObj();
            });

            output.AcumaticaOrderLineTotal = (decimal)acumaticaOrder.Totals.LineTotalAmount.value;
            output.AcumaticaOrderFreight   = (decimal)acumaticaOrder.Totals.Freight.value;
            output.AcumaticaTaxTotal       = (decimal)acumaticaOrder.Totals.TaxTotal.value;
            output.AcumaticaOrderTotal     = (decimal)acumaticaOrder.OrderTotal.value;
        }
Ejemplo n.º 2
0
        // Update existing Sales Order
        //
        public SalesOrderUpdate BuildSalesOrderUpdate(ShopifyOrder shopifyOrderRecord)
        {
            var shopifyOrder     = _shopifyJsonService.RetrieveOrder(shopifyOrderRecord.ShopifyOrderId);
            var salesOrderRecord = shopifyOrderRecord.SyncedSalesOrder();

            var existingSalesOrder
                = _salesOrderClient
                  .RetrieveSalesOrder(
                      salesOrderRecord.AcumaticaOrderNbr, SalesOrderType.SO, SalesOrderExpand.Details)
                  .ToSalesOrderObj();

            var salesOrderUpdate = new SalesOrderUpdate();

            salesOrderUpdate.OrderType = existingSalesOrder.OrderType.Copy();
            salesOrderUpdate.OrderNbr  = existingSalesOrder.OrderNbr.Copy();
            salesOrderUpdate.Hold      = false.ToValue();

            // Update the Shipping Cost
            //
            salesOrderUpdate.FreightPrice         = ((double)shopifyOrder.NetShippingPrice).ToValue();
            salesOrderUpdate.OverrideFreightPrice = true.ToValue();

            foreach (var line_item in shopifyOrder.line_items)
            {
                var variant =
                    _syncInventoryRepository.RetrieveVariant(line_item.variant_id.Value, line_item.sku);

                var stockItemId      = variant.MatchedStockItem().ItemId;
                var salesOrderDetail = existingSalesOrder.DetailByInventoryId(stockItemId);

                var detail = new SalesOrderUpdateDetail();
                detail.id          = salesOrderDetail.id;
                detail.OrderQty    = ((double)line_item.NetOrderedQuantity).ToValue();
                detail.InventoryID = variant.MatchedStockItem().ItemId.ToValue();

                salesOrderUpdate.Details.Add(detail);
            }

            var taxTransfer = shopifyOrder.ToSerializedAndZippedTaxTransfer();

            salesOrderUpdate.custom = new SalesOrderUsrTaxSnapshot(taxTransfer);
            return(salesOrderUpdate);
        }
Ejemplo n.º 3
0
        private string RetrieveExternalJson(int acumaticaJsonType, string acumaticaNbr, string acumaticaType)
        {
            if (acumaticaJsonType == AcumaticaJsonType.Warehouse)
            {
                return(_distributionClient.RetrieveWarehouse(acumaticaNbr));
            }
            if (acumaticaJsonType == AcumaticaJsonType.Customer)
            {
                return(_customerClient.RetrieveCustomer(acumaticaNbr));
            }
            if (acumaticaJsonType == AcumaticaJsonType.StockItem)
            {
                return(_distributionClient.RetrieveStockItem(acumaticaNbr));
            }
            if (acumaticaJsonType == AcumaticaJsonType.SalesOrderShipments)
            {
                return(_salesOrderClient.RetrieveSalesOrder(acumaticaType, acumaticaNbr));
            }

            throw new NotImplementedException();
        }