app/controllers/util_controller.rb
# recalculate user balance
# use after login, at new day, after new deal, after deleted deal etc
# todo: delete. should be client only information
recalculate user balance
use after login, at new day, after new deal, after deleted deal etc
todo: delete. should be client only information
recalculate user balance use after login at new day after new deal after deleted deal etc todo : delete . should be client only information
def recalculate_user_balance (id)
    begin
      user = User.find_by_id(id)
      return ['.recal_user_bal_unknown_id',{}] unless user
      return ['.recal_user_bal_invalid_id',{}] unless login_user_ids.index(user.user_id)
      today = Date.parse(Sequence.get_last_exchange_rate_date)
      res = user.recalculate_balance if !user.balance_at or user.balance_at != today
      ['.recal_user_cal_pending',{}] unless res
      nil
    rescue => e
      logger.debug2  "Exception: #{e.message.to_s} (#{e.class})"
      logger.debug2  "Backtrace: " + e.backtrace.join("\n")
      raise
    end
  end
def recalculate_user_balance ( id ) begin user = User . find_by_id ( id ) return [ '.recal_user_bal_unknown_id' , { } ] unless user return [ '.recal_user_bal_invalid_id' , { } ] unless login_user_ids . index ( user . user_id ) today = Date . parse ( Sequence . get_last_exchange_rate_date ) res = user . recalculate_balance if ! user . balance_at or user . balance_at != today [ '.recal_user_cal_pending' , { } ] unless res nil rescue => e logger . debug2 "Exception: #{e.message.to_s} (#{e.class})" logger . debug2 "Backtrace: " + e . backtrace . join ( "\n" ) raise end end
recalculate user balance
use after login, at new day, after new deal, after deleted deal etc
todo: delete.
recalculate user balance use after login at new day after new deal after deleted deal etc todo : delete .
# check id # recalculate balance for user or for user combination
id
<not_specific>