 
   {permit} = require '../group/permissionset'
 
-  {groupBy} = require 'underscore'
-
-  {daisy} = require 'bongo'
+  JRecurlyPlan         = require '../recurly'
+  JRecurlySubscription = require '../recurly/subscription'
+  JVM                  = require '../vm'
+  async                = require 'async'
 
   @share()
 

            callback new KodingError "Can't create new VM."

  checkUsage: (account, group, callback)->
    JVM = require '../vm'
    JVM.someData
      planOwner   : "group_#{group._id}"
      expensedUser: "user_#{account._id}"

      planCode    : 1
    , {}, (err, cursor)=>
      cursor.toArray (err, arr)=>
        return callback err  if err

        stack = []
        arr.forEach (vmData)->
          stack.push (cb)->
            JRecurlyPlan.one
              code: vmData.planCode
            , (err, plan)->
              return cb err  if err
              cb null, plan.feeMonthly

        async.parallel stack, (err, result)->
          return callback err  if err
          cost = 0
          result.forEach (fee)->
            cost += fee

          callback null, cost
