   amount = billing_unit_count * plan_info.billing_by_time.price
 
   callback
-    name: plan_name
+    plan_name: plan_name
     billing_unit_count: billing_unit_count
     last_billing_at: new_last_billing_at
     amount_inc: -amount

      $inc:
        'billing.balance': 0

    for item in result
      modifier.$set["billing.last_billing_at.#{item.name}"] = item.last_billing_at
      modifier.$inc['billing.balance'] += item.amount_inc

    if account.billing.balance > 0
      if account.billing.arrears_at

      exports.cyclicalBilling ->
    , config.billing.billing_cycle

exports.forceLeaveAllPlans = (account, callback) ->
  async.eachSeries account.billing.plans, (plan_name, callback) ->
    exports.leavePlan account, plan_name, callback
  , ->
    mAccount.findOne {_id: account._id}, (err, account) ->
      callback account

exports.isForceFreeze = (account) ->
  if account.billing.balance < config.billing.force_freeze.when_balance_below
    return true

  force_freeze_when = account.billing.arrears_at.getTime() + config.billing.force_freeze.when_arrears_above

  if account.billing.arrears_at and Date.now() > force_freeze_when
    return true

  return false

# @param callback(account)
exports.triggerBilling = (account, callback) ->
  async.each account.billing.plans, (plan_name, callback) ->
    exports.generateBilling account, plan_name, (result) ->
      callback null, result

  , (err, result) ->
    billing_reports = _.compact result

    if _.isEmpty billing_reports
      return callback account

    modifier =
