<commit_before># == Schema Information
#
# Table name: expense_groups
#
#  id                     :integer          not null, primary key
#  visible                :boolean          default(TRUE), not null
#  position               :integer
#  created_at             :datetime
#  updated_at             :datetime
#  info_url               :string(255)
#  competitor_required    :boolean          default(FALSE), not null
#  noncompetitor_required :boolean          default(FALSE), not null
#  registration_items     :boolean          default(FALSE), not null
#  info_page_id           :integer
#  system_managed         :boolean          default(FALSE), not null
#

class ExpenseGroup < ApplicationRecord
  include PageOrUrlLink

  validates :group_name, presence: true
  validates :visible, :competitor_required, :noncompetitor_required, inclusion: { in: [true, false] } # because it's a boolean

  has_many :expense_items, -> { order "expense_items.position" }, inverse_of: :expense_group
  has_many :expense_group_options, inverse_of: :expense_group

  translates :group_name, fallbacks_for_empty_translations: true
  accepts_nested_attributes_for :translations
  accepts_nested_attributes_for :expense_group_options, allow_destroy: true

  default_scope { order(:position) }
  scope :visible, -> { where(visible: true).not_a_required_item_group }<commit_msg>Expense Group deletion should not orphan records<commit_after># == Schema Information
#
# Table name: expense_groups
#
#  id                     :integer          not null, primary key
#  visible                :boolean          default(TRUE), not null
#  position               :integer
#  created_at             :datetime
#  updated_at             :datetime
#  info_url               :string(255)
#  competitor_required    :boolean          default(FALSE), not null
#  noncompetitor_required :boolean          default(FALSE), not null
#  registration_items     :boolean          default(FALSE), not null
#  info_page_id           :integer
#  system_managed         :boolean          default(FALSE), not null
#

class ExpenseGroup < ApplicationRecord
  include PageOrUrlLink

  validates :group_name, presence: true
  validates :visible, :competitor_required, :noncompetitor_required, inclusion: { in: [true, false] } # because it's a boolean

  has_many :expense_items, -> { order "expense_items.position" }, inverse_of: :expense_group, dependent: :destroy
  has_many :expense_group_options, inverse_of: :expense_group, dependent: :destroy

  translates :group_name, fallbacks_for_empty_translations: true
  accepts_nested_attributes_for :translations
  accepts_nested_attributes_for :expense_group_options, allow_destroy: true

  default_scope { order(:position) }
  scope :visible, -> { where(visible: true).not_a_required_item_group }
{'fraction_non_alphanumeric': 0.07925740806854695, 'fraction_numerical': 0.0021420921099607284, 'mean_word_length': 3.213533834586466, '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': '2458843', 'n_tokens_mistral': 788, 'n_tokens_neox': 779, 'n_words': 198}