 
   _toTax: (rate) ->
     rate = _s.numberFormat(_s.toNumber(rate * 100), 2)
+
+  _toProductPriceFromTotal: (centAmount, quantity) ->
+    amount = _s.numberFormat(_s.toNumber(centAmount / quantity / 100), 2)
 
   _addressToXML: (address, xml, name) ->
     el = xml.ele(name)

    @logger.debug "[OrderExport] Processing order with id: '#{order.id}'"
    orderXML.e('OrderId').t(order.id)
    orderXML.e('OrderDate').t(order.createdAt)
    orderXML.e('TotalAmountProductsNetto').t(@_toAmount(order.taxedPrice.totalNet.centAmount))
    orderXML.e('TotalAmountVat').t(@_toAmount(order.taxedPrice.taxPortions[0].amount.centAmount))
    orderXML.e('TotalAmount').t(@_toAmount(order.taxedPrice.totalGross.centAmount))

    shippingInfo = order.shippingInfo
    if shippingInfo
      shippingCost = @_toAmount(shippingInfo.price.centAmount)
      orderXML.e('ShippingCost').t(shippingCost)
      orderXML.e('ShippingMethod').t(shippingInfo.shippingMethodName)

    @_addressToXML(order.shippingAddress, orderXML, 'DeliveryParty')
    @_addressToXML(order.billingAddress, orderXML, 'BillingParty') if order.billingAddress

    lineItemsXML = orderXML.ele("OrderLines", {'count': order.lineItems.length})
    _.each order.lineItems, (lineItem, index, list) =>

class OrderExport

  constructor: (@_options = {}) ->
    @rest = new Rest @_options
    @logger = @_options.appLogger

