class Company < ApplicationRecord
  include Base::Company

  belongs_to :school, inverse_of: :companies

  has_many :contacts, inverse_of: :company, dependent: :nullify, foreign_key: :CCID
  has_many :additional_values, class_name: '::CompanyAdditionalValue', foreign_key: :CCID,
    dependent: :destroy, inverse_of: :company
  has_many :notes, class_name: '::CompanyNote', inverse_of: :company, dependent: :destroy,
    foreign_key: :CCID

  validates :location_address, :location_address_ext, :location_city, :location_state,
    :location_country, :mailing_address, :mailing_address_ext, :mailing_city, :mailing_state,
    :mailing_country, :billing_address, :billing_address_ext, :billing_city, :billing_state,
    :billing_country, length: { maximum: 32 }
  validates :location_zip, :mailing_zip, :billing_zip, length: { maximum: 10 }
  validates :contact_email, :billing_email, length: { maximum: 128 }
end
