Class: AssortmentInstruction
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AssortmentInstruction
- Includes:
- Models::Auditable
- Defined in:
- app/models/assortment_instruction.rb
Overview
== Schema Information
Table name: assortment_instructions
Database name: primary
id :integer not null, primary key
active :boolean default(TRUE)
final_rule :boolean default(TRUE)
instruction_type :string not null
position :integer
title :string
created_at :datetime not null
updated_at :datetime not null
creator_id :integer
customer_filter_id :integer
email_template_id :integer
updater_id :integer
Indexes
index_assortment_instructions_on_customer_filter_id (customer_filter_id)
index_assortment_instructions_on_instruction_type (instruction_type)
Foreign Keys
fk_rails_... (customer_filter_id => customer_filters.id)
fk_rails_... (email_template_id => email_templates.id)
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Belongs to collapse
Methods included from Models::Auditable
Has many collapse
Has and belongs to many collapse
-
#items ⇒ ActiveRecord::Relation<Item>
for publications.
Class Method Summary collapse
-
.active ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are active.
-
.for_customer ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are for customer.
- .instruction_types_for_select ⇒ Object
-
.sorted ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are sorted.
Instance Method Summary collapse
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Class Method Details
.active ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are active. Active Record Scope
48 |
# File 'app/models/assortment_instruction.rb', line 48 scope :active, -> { where(active: true) } |
.for_customer ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are for customer. Active Record Scope
49 |
# File 'app/models/assortment_instruction.rb', line 49 scope :for_customer, ->(customer) { where(customer_filter_id: CustomerFilter::QueryBuilder.filter_ids_for_customer(customer)).order(:position) } |
.instruction_types_for_select ⇒ Object
54 55 56 |
# File 'app/models/assortment_instruction.rb', line 54 def self.instruction_types_for_select instruction_types.invert.keys.map{|k| [k.to_s.humanize.titleize, k] } end |
.sorted ⇒ ActiveRecord::Relation<AssortmentInstruction>
A relation of AssortmentInstructions that are sorted. Active Record Scope
50 |
# File 'app/models/assortment_instruction.rb', line 50 scope :sorted, -> { order(:position)} |
Instance Method Details
#customer_filter ⇒ CustomerFilter
32 |
# File 'app/models/assortment_instruction.rb', line 32 belongs_to :customer_filter, optional: true |
#email_template ⇒ EmailTemplate
33 |
# File 'app/models/assortment_instruction.rb', line 33 belongs_to :email_template, optional: true |
#items ⇒ ActiveRecord::Relation<Item>
for publications
35 |
# File 'app/models/assortment_instruction.rb', line 35 has_and_belongs_to_many :items, inverse_of: :assortment_instructions |
#line_items_qualify?(line_items) ⇒ Boolean
58 59 60 |
# File 'app/models/assortment_instruction.rb', line 58 def line_items_qualify?(line_items) ProductFilter::LineQualifier.new(line_items, product_filters). end |
#product_filters ⇒ ActiveRecord::Relation<ProductFilter>
34 |
# File 'app/models/assortment_instruction.rb', line 34 has_many :product_filters, dependent: :destroy, inverse_of: :assortment_instruction |