   _salesPrice: (prices, customerGroupId) ->
     _.find prices, (p) ->
       _.has(p, 'customerGroup') and p.customerGroup.id is customerGroupId
-      
+
 module.exports = PriceSync

      @getCustomerGroup(@masterClient, CUSTOMER_GROUP_SALE)
      @getCustomerGroup(@retailerClient, CUSTOMER_GROUP_SALE)
    ]).spread (retailerChannelInMaster, masterCustomerGroup, retailerCustomerGroup) =>
      console.error "retailerChannelInMaster %j", retailerChannelInMaster
      console.error "masterCustomerGroup %j", masterCustomerGroup
      console.error "retailerCustomerGroup %j", retailerCustomerGroup

      @getPublishedProducts @retailerClient, ((page, count) -> console.error "Page #{page} processed - #{count} price update(s) done."), (retailerProduct) =>
        current = retailerProduct.masterData.current
        current.variants or= []
        variants = [current.masterVariant].concat(current.variants)
        stagedVariants = [retailerProduct.masterData.staged.masterVariant].concat(retailerProduct.masterData.staged.variants)

        console.error "C %j", _.map(variants, (a) -> a.sku)
        console.error "S %j", _.map(stagedVariants, (a) -> a.sku)

        v = _.map variants, (retailerVariant) =>
          @taskQueue.addTask _.bind(@_processVariant, this, retailerVariant, retailerCustomerGroup, masterCustomerGroup, retailerChannelInMaster)

  syncVariantPrices: (variantDataInMaster, retailerVariant, retailerCustomerGroup, masterCustomerGroup, retailerChannelInMaster) ->
    prices = @_filterPrices(retailerVariant, variantDataInMaster.variant, retailerCustomerGroup, masterCustomerGroup, retailerChannelInMaster)
    actions = @_updatePrices(prices.retailerPrices, prices.masterPrices, retailerChannelInMaster.id, variantDataInMaster.variant, retailerCustomerGroup.id, masterCustomerGroup.id)

    if _.isEmpty(actions)
      Q({ updates: 0 })

