<commit_before># == Schema Information
#
# Table name: accounts
#
#  id              :integer          not null, primary key
#  name            :string(255)      not null
#  initial_balance :decimal(8, 2)    not null
#  created_by      :integer
#  updated_by      :integer
#  created_at      :datetime
#  updated_at      :datetime
#

class Account < ActiveRecord::Base
  has_and_belongs_to_many :users
  has_many                :categories,    dependent: :restrict_with_error
  has_many                :transactions,  dependent: :restrict_with_error
  has_many                :schedules,     dependent: :delete_all

  validates_presence_of     :name, :initial_balance
  validates_numericality_of :initial_balance
  #validates_uniqueness_of   :name, scope: :user_id

  #scope :active,       -> { where(active: true) }
  scope :order_by_name, -> { order(name: :asc) }
end<commit_msg>format initial_balance before type cast<commit_after># == Schema Information
#
# Table name: accounts
#
#  id              :integer          not null, primary key
#  name            :string(255)      not null
#  initial_balance :decimal(8, 2)    not null
#  created_by      :integer
#  updated_by      :integer
#  created_at      :datetime
#  updated_at      :datetime
#

class Account < ActiveRecord::Base
  has_and_belongs_to_many :users, uniq: true
  has_many                :categories,    dependent: :restrict_with_error
  has_many                :transactions,  dependent: :restrict_with_error
  has_many                :schedules,     dependent: :delete_all

  before_validation :format_initial_balance

  validates_presence_of     :name, :initial_balance
  validates_numericality_of :initial_balance
  #validates_uniqueness_of   :name, scope: user_id

  scope :order_by_name, -> { order(name: :asc) }
  #scope :active,       -> { where(active: true) }

  private
    def format_initial_balance
      self.initial_balance = initial_balance_before_type_cast.gsub(',', '.')
    end
end
{'fraction_non_alphanumeric': 0.08422120750887874, 'fraction_numerical': 0.0050735667174023336, 'mean_word_length': 2.8217054263565893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1738472', 'n_tokens_mistral': 625, 'n_tokens_neox': 607, 'n_words': 141}