public virtual OmniumShipment MapShipment( IShipment shipment, IMarket market, Currency currency, IEnumerable <RewardDescription> shippingDiscounts) { var totals = _shippingCalculator.GetShippingTotals(shipment, market, currency); var shipmentId = shipment.ShipmentId.ToString(); var omniumDiscounts = MapDiscounts(shippingDiscounts, currency, market, shipment.ShippingAddress); var shippingMethodName = GetShipmentName(shipment) ?? shipment.ShippingMethodName; var lineItems = shipment.LineItems.Select(x => MapOrderLine(x, market, currency, shipment.ShippingAddress)) .ToList(); var shipmentItemsTotalInclTax = lineItems.Sum(x => x.ExtendedPrice); var shipmentItemsTax = lineItems.Sum(x => x.TaxTotal); var shippingCostsInclTax = market.PricesIncludeTax ? totals.ShippingCost : totals.ShippingCost + totals.ShippingTax; var shippingDiscountPrice = shipment.GetShipmentDiscount(); var result = new OmniumShipment { Status = shipment.OrderShipmentStatus.ToString(), ShipmentId = shipmentId, ShippingMethodId = shipment.ShippingMethodId.ToString(), ShippingMethodName = shippingMethodName, WarehouseCode = shipment.WarehouseCode, ShipmentTrackingNumber = shipment.ShipmentTrackingNumber, Address = MapOrderAddress(shipment.ShippingAddress), LineItems = lineItems, Properties = shipment.ToPropertyList(), Discounts = omniumDiscounts, // Shipping discount ShippingDiscountAmount = shippingDiscountPrice, // shipping tax ShippingTax = totals.ShippingTax, // shipping costs + shipping tax ShippingSubTotal = shippingCostsInclTax, // sum of all line item (extended) prices SubTotal = shipmentItemsTotalInclTax, // sum of shipping price + all line item prices Total = shippingCostsInclTax + shipmentItemsTotalInclTax - shippingDiscountPrice, // sum of shipping tax + all line items tax TaxTotal = totals.ShippingTax + shipmentItemsTax, }; return(result); }