 
     mAccount.findAndModify {_id: account._id}, null, modifier, {new: true}, (err, account) ->
       mBalance.create account, 'billing', modifier.$inc['billing.balance'],
-        plans: _.indexBy result, 'name'
+        plans: _.indexBy billing_reports, 'plan_name'
       , ->
-        if is_force
-          return forceLeaveAllPlans callback
+        if exports.isForceFreeze account
+          exports.forceLeaveAllPlans account, ->
+            callback()
         else
           callback account
 

exports.leavePlan = (account, plan_name, callback) ->
  leaved_services = _.reject account.billing.services, (service_name) ->
    for item in _.without(account.billing.plans, plan_name)
      if service_name in config.plans[plan_name].services
        return true

    return false

      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 =
