Exemplo n.º 1
0
        private FulfillmentParent ShopifyOrderRecord(AcumaticaSoShipment salesOrderShipment)
        {
            var salesOrderRecord   = salesOrderShipment.AcumaticaSalesOrder;
            var orderRecord        = _syncOrderRepository.RetrieveSalesOrder(salesOrderRecord.AcumaticaOrderNbr);
            var shopifyOrderRecord = orderRecord.OriginalShopifyOrder();

            var shopifyOrder = _shopifyJsonService.RetrieveOrder(shopifyOrderRecord.ShopifyOrderId);
            var shipment     = salesOrderShipment.AcumaticaShipmentJson.DeserializeFromJson <Shipment>();

            var location = RetrieveMatchingLocation(shipment);

            // Line Items
            //
            var details     = shipment.DetailByOrder(orderRecord.AcumaticaOrderNbr);
            var fulfillment = new Fulfillment();

            fulfillment.line_items      = new List <LineItem>();
            fulfillment.location_id     = location.id;
            fulfillment.tracking_number = salesOrderShipment.AcumaticaTrackingNbr;

            // Build the Detail
            //
            foreach (var detail in details)
            {
                var stockItem = _syncInventoryRepository.RetrieveStockItem(detail.InventoryID.value);
                var variant   = stockItem.MatchedVariant();

                var shopifyLineItem = shopifyOrder.LineItem(variant.ShopifySku);
                var quantity        = detail.ShippedQty.value;

                var fulfillmentDetail = new LineItem()
                {
                    id       = shopifyLineItem.id,
                    quantity = (int)quantity,
                };

                fulfillment.line_items.Add(fulfillmentDetail);
            }

            var parent = new FulfillmentParent()
            {
                fulfillment = fulfillment
            };

            return(parent);
        }