/// <summary> /// Visits a line items. /// </summary> /// <param name="item"> /// The item. /// </param> public void Visit(ILineItem item) { // We only need product line items if (item.LineItemType != LineItemType.Product && item.LineItemType != LineItemType.Tax) { return; } // Just add Tax items are list for return if (item.LineItemType == LineItemType.Tax) { _taxLineItems.Add(item.AsLineItemWithKeyOf <InvoiceLineItem>()); return; } // Ensure this item has taxes included in product pricing. var taxesIncludedInPrice = bool.Parse(item.ExtendedData.GetValue(Constants.ExtendedDataKeys.TaxIncludedInProductPrice)); if (!taxesIncludedInPrice) { _productLineItems.Add(item.AsLineItemWithKeyOf <InvoiceLineItem>()); return; } // TODO merchCouponAdjustedProductPreTaxTotal // Determine whether or not this item was purchased was onsale var onsale = item.ExtendedData.GetOnSaleValue(); var priceKey = onsale ? Constants.ExtendedDataKeys.ProductSalePriceNoTax : Constants.ExtendedDataKeys.ProductPriceNoTax; var taxKey = onsale ? Constants.ExtendedDataKeys.ProductSalePriceTaxAmount : Constants.ExtendedDataKeys.ProductPriceTaxAmount; if (item.ExtendedData.ContainsKey(priceKey) && item.ExtendedData.ContainsKey(taxKey)) { var clone = item.AsLineItemWithKeyOf <InvoiceLineItem>(); clone.Price = ConvertToDecimal(item.ExtendedData.GetValue(priceKey)); _productLineItems.Add(clone); var taxItem = new InvoiceLineItem(LineItemType.Tax, string.Format("{0} Tax", item.Name), string.Format("{0}-Tax", item.Sku), item.Quantity, ConvertToDecimal(item.ExtendedData.GetValue(taxKey))); _taxLineItems.Add(taxItem); } }