Sha256: c74a2b6a44e3ee1294db816f4e87e5d25bf32f8f94c4dbbb5ffdf0be31adbf6b

Contents?: true

Size: 922 Bytes

Versions: 5

Compression:

Stored size: 922 Bytes

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 :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

      validates :code, :name, :address, :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
          locale
          parent_id
          subsidiary
        ]
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
comee_core-0.2.75 app/models/comee/core/client.rb
comee_core-0.2.70 app/models/comee/core/client.rb
comee_core-0.2.69 app/models/comee/core/client.rb
comee_core-0.2.68 app/models/comee/core/client.rb
comee_core-0.2.67 app/models/comee/core/client.rb