app/models/jobshop/organization.rb in jobshop-0.0.163 vs app/models/jobshop/organization.rb in jobshop-0.0.167

- old
+ new

@@ -5,30 +5,37 @@ self.primary_key = :organization_id has_many :collections, inverse_of: :organization, dependent: :restrict_with_exception - has_many :companies, inverse_of: :organization, + has_many :customers, inverse_of: :organization, dependent: :restrict_with_exception - has_many :company_types, inverse_of: :organization, + has_many :customer_categories, inverse_of: :organization, dependent: :restrict_with_exception, - class_name: "Jobshop::Company::Type" + class_name: "Jobshop::Customer::Category" + has_many :customer_contacts, inverse_of: :organization, + dependent: :restrict_with_exception, + class_name: "Jobshop::Customer::Contact" + + has_many :employees, -> { merge(Jobshop::Employee.active) }, + inverse_of: :organization, dependent: :restrict_with_exception + + has_many :employments, inverse_of: :organization, + dependent: :restrict_with_exception + has_many :inspection_reports, inverse_of: :organization, dependent: :restrict_with_exception, class_name: "Jobshop::Inspection::Report" has_many :mailmen, inverse_of: :organization, dependent: :restrict_with_exception has_many :orders, inverse_of: :organization, dependent: :restrict_with_exception - has_many :people, inverse_of: :organization, - dependent: :restrict_with_exception - has_many :places, inverse_of: :organization, dependent: :restrict_with_exception has_many :products, inverse_of: :organization, dependent: :restrict_with_exception @@ -46,16 +53,18 @@ dependent: :restrict_with_exception has_many :users, inverse_of: :organization, dependent: :restrict_with_exception +=begin scope :grouped_by_email, ->(email_addresses) { Jobshop::User .where(email: email_addresses) .joins(:organization) .includes(:organization) .each_with_object({}) { |user, organizations| (organizations[user.email] ||= []) << user.organization } } +=end end end