Sha256: 871c247ca46b9ec38475b7fb6f8ac337fe58f41713cbdcc25b2fcc7b6dca32f6

Contents?: true

Size: 1.07 KB

Versions: 57

Compression:

Stored size: 1.07 KB

Contents

module Comee
  module Core
    class Client < ApplicationRecord
      belongs_to :user, optional: true
      belongs_to :parent, class_name: "Comee::Core::Client", optional: true
      belongs_to :country, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup", optional: true
      belongs_to :currency, optional: true
      has_and_belongs_to_many :contacts, join_table: :comee_core_clients_contacts
      has_and_belongs_to_many :agents, join_table: :comee_core_clients_agents
      has_many :client_warehouses
      has_many :client_addresses

      validates :code, :name, :match_code, :locale, presence: true
      validates :code, uniqueness: true

      delegate(:name, to: :user, prefix: true, allow_nil: true)

      def self.ransackable_attributes(_auth_object = nil)
        %w[
          id
          user_id
          address
          code
          name
          match_code
          locale
          parent_id
          subsidiary
        ]
      end

      def self.ransackable_associations(_auth_object = nil)
        ["parent"]
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
comee_core-0.3.62 app/models/comee/core/client.rb
comee_core-0.3.61 app/models/comee/core/client.rb
comee_core-0.3.60 app/models/comee/core/client.rb
comee_core-0.3.59 app/models/comee/core/client.rb
comee_core-0.3.58 app/models/comee/core/client.rb
comee_core-0.3.57 app/models/comee/core/client.rb
comee_core-0.3.56 app/models/comee/core/client.rb
comee_core-0.3.55 app/models/comee/core/client.rb
comee_core-0.3.54 app/models/comee/core/client.rb
comee_core-0.3.53 app/models/comee/core/client.rb
comee_core-0.3.51 app/models/comee/core/client.rb
comee_core-0.3.50 app/models/comee/core/client.rb
comee_core-0.3.49 app/models/comee/core/client.rb
comee_core-0.3.48 app/models/comee/core/client.rb
comee_core-0.3.47 app/models/comee/core/client.rb
comee_core-0.3.46 app/models/comee/core/client.rb
comee_core-0.3.45 app/models/comee/core/client.rb
comee_core-0.3.44 app/models/comee/core/client.rb
comee_core-0.3.43 app/models/comee/core/client.rb
comee_core-0.3.42 app/models/comee/core/client.rb