<commit_before>class AdditionalCodeType < Sequel::Model
  set_primary_key :additional_code_type_id

  one_to_many :additional_codes, key: :additional_code_type_id
  one_to_one  :additional_code_type_description, key: :additional_code_type_id
  one_to_many :additional_code_descriptions, key: :additional_code_type_id
  one_to_many :additional_code_type_measure_types
  many_to_many :measure_types, join_table: :additional_code_type_measure_types
  one_to_many :additional_code_description_periods, key: :additional_code_type_id
  one_to_many :footnote_association_additional_codes, key: :additional_code_type_id
  many_to_many :footnotes, join_table: :footnote_association_additional_codes,
                       class_name: 'Footnote'

  many_to_one :meursing_table_plan

  APPLICATION_CODES = {
    0 => "Export refund nomencalture",
    1 => "Additional Codes",
    3 => "Meursing addition codes",
    4 => "Eport refund for processed agricultural goods"
  }
end

<commit_msg>test ct1..4<commit_after>class AdditionalCodeType < Sequel::Model
  set_primary_key :additional_code_type_id

  one_to_many :additional_codes, key: :additional_code_type_id
  one_to_one  :additional_code_type_description, key: :additional_code_type_id
  one_to_many :additional_code_descriptions, key: :additional_code_type_id
  one_to_many :additional_code_type_measure_types
  many_to_many :measure_types, join_table: :additional_code_type_measure_types
  one_to_many :additional_code_description_periods, key: :additional_code_type_id
  one_to_many :footnote_association_additional_codes, key: :additional_code_type_id
  many_to_many :footnotes, join_table: :footnote_association_additional_codes,
                       class_name: 'Footnote'

  many_to_one :meursing_table_plan

  APPLICATION_CODES = {
    0 => "Export refund nomencalture",
    1 => "Additional Codes",
    3 => "Meursing addition codes",
    4 => "Export refund for processed agricultural goods"
  }

  ######### Conformance validations 120
  def validate
    super
    # CT1
    validates_unique :additional_code_type_id
    # CT2
    if application_code != 3 && meursing_table_plan_id.present?
      errors.add(:meursing_table_plan_id,
        "The Meursing table plan can only be entered if the additional code type has as application code 'Meursing table additional code type'.")
    end
    # CT3
    validates_presence :meursing_table_plan_id if application_code == 3
    # CT4
    validates_start_date

    # TODO: CT6
    # TODO: CT7

    # TODO: CT9
    # TODO: CT10
    # TODO: CT11
  end


end


{'fraction_non_alphanumeric': 0.066796875, 'fraction_numerical': 0.01015625, 'mean_word_length': 4.9282407407407405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6065169', 'n_tokens_mistral': 878, 'n_tokens_neox': 828, 'n_words': 176}