       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) ->
-  forceLeaveAllPlans = (callback) ->
-    async.eachSeries account.billing.plans, (plan_name, callback) ->
-      exports.leavePlan account, plan_name, callback
-    , ->
-      mAccount.findOne {_id: account._id}, (err, account) ->
-        callback account
-
-  is_force = do ->
-    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
-
   async.each account.billing.plans, (plan_name, callback) ->
     exports.generateBilling account, plan_name, (result) ->
       callback null, result
 
   , (err, result) ->
-    result = _.compact result
+    billing_reports = _.compact result
 
-    if _.isEmpty result
+    if _.isEmpty billing_reports
       return callback account
 
     modifier =

  amount = billing_unit_count * plan_info.billing_by_time.price

  callback
    name: plan_name
    billing_unit_count: billing_unit_count
    last_billing_at: new_last_billing_at
    amount_inc: -amount

      $inc:
        'billing.balance': 0

    for report in billing_reports
      modifier.$set["billing.last_billing_at.#{report.plan_name}"] = report.last_billing_at
      modifier.$inc['billing.balance'] += report.amount_inc

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