private IList <SalesOrderDetail> BuildSalesOrderDetail(Order shopifyOrder) { var output = new List <SalesOrderDetail>(); var settings = _settingsRepository.RetrieveSettings(); // Build Line Items foreach (var lineItem in shopifyOrder.line_items) { var standardizedSku = Canonizers.StandardizedSku(lineItem.sku); var stockItemRecord = _syncInventoryRepository.RetrieveStockItem(standardizedSku); var detail = new SalesOrderDetail(); detail.InventoryID = stockItemRecord.ItemId.ToValue(); detail.OrderQty = ((double)lineItem.NetOrderedQuantity).ToValue(); detail.UnitPrice = ((double)lineItem.price).ToValue(); detail.DiscountAmount = ((double)lineItem.Discount).ToValue(); // detail.ExtendedPrice = ((double)lineItem.NetLineAmount).ToValue(); detail.TaxCategory = lineItem.taxable ? settings.AcumaticaTaxableCategory.ToValue() : settings.AcumaticaTaxExemptCategory.ToValue(); output.Add(detail); } return(output); }
private StockItem BuildNewStockItem(string warehouseId, ShopifyVariant variant) { var settings = _settingsRepository.RetrieveSettings(); var defaultItemClass = settings.AcumaticaDefaultItemClass; var defaultPostingClass = settings.AcumaticaDefaultPostingClass; var defaultTaxCategory = variant.ShopifyIsTaxable.TaxCategory(settings); var shopifyVariant = _shopifyJsonService.RetrieveVariant(variant.ShopifyVariantId); var shopifyProduct = _shopifyJsonService.RetrieveProduct(variant.ShopifyProduct.ShopifyProductId); var newStockItem = new StockItem(); newStockItem.InventoryID = variant.StandardizedSku().ToValue(); newStockItem.Description = Canonizers.StandardizedStockItemTitle(shopifyProduct, shopifyVariant).ToValue(); newStockItem.DefaultPrice = ((double)shopifyVariant.price).ToValue(); newStockItem.DefaultWarehouseID = warehouseId.ToValue(); var dimensionWeight = (double)shopifyVariant.grams.ToAcumaticaOunces(); // newStockItem.WeightUOM = WeightCalc.AcumaticaUnitsOfMeasure.ToValue(); newStockItem.DimensionWeight = dimensionWeight.ToValue(); newStockItem.ItemClass = defaultItemClass.ToValue(); newStockItem.PostingClass = defaultPostingClass.ToValue(); newStockItem.TaxCategory = defaultTaxCategory.ToValue(); return(newStockItem); }