Class: CommissionRate
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- CommissionRate
- Includes:
- Models::Auditable
- Defined in:
- app/models/commission_rate.rb
Overview
== Schema Information
Table name: commission_rates
Database name: primary
id :integer not null, primary key
commission_rate :float not null
commission_tier_description :string
end_date :date
is_active :boolean not null
items_apply_commission :integer is an Array
max_profit :float
min_order_amount :integer default(0), not null
min_profit :float
start_date :date
created_at :datetime not null
updated_at :datetime not null
commission_tier_id :integer not null
creator_id :integer
employee_id :integer not null
updater_id :integer
Indexes
index_commission_rates_on_commission_tier_id (commission_tier_id)
index_commission_rates_on_employee_id (employee_id)
index_commission_rates_on_end_date (end_date)
index_commission_rates_on_is_active (is_active)
index_commission_rates_on_items_apply_commission (items_apply_commission)
index_commission_rates_on_min_order_amount (min_order_amount)
index_commission_rates_on_start_date (start_date)
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Belongs to collapse
Methods included from Models::Auditable
Class Method Summary collapse
-
.active ⇒ ActiveRecord::Relation<CommissionRate>
A relation of CommissionRates that are active.
-
.sorted ⇒ ActiveRecord::Relation<CommissionRate>
A relation of CommissionRates that are sorted.
-
.with_description_tier_employee_sku_name ⇒ ActiveRecord::Relation<CommissionRate>
A relation of CommissionRates that are with description tier employee sku name.
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<CommissionRate>
A relation of CommissionRates that are active. Active Record Scope
37 |
# File 'app/models/commission_rate.rb', line 37 scope :active, -> { where(is_active: true) } |
.sorted ⇒ ActiveRecord::Relation<CommissionRate>
A relation of CommissionRates that are sorted. Active Record Scope
36 |
# File 'app/models/commission_rate.rb', line 36 scope :sorted, -> { order(is_active: :desc, employee_id: :asc, commission_tier_id: :asc) } |
.with_description_tier_employee_sku_name ⇒ ActiveRecord::Relation<CommissionRate>
A relation of CommissionRates that are with description tier employee sku name. Active Record Scope
38 39 40 |
# File 'app/models/commission_rate.rb', line 38 scope :with_description_tier_employee_sku_name, -> { select("commission_rates.*, (select full_name from parties where id = employee_id) as employee_name, (select array_agg(sku) as skus from items where id = any(items_apply_commission))") } |
Instance Method Details
#commission_tier ⇒ CommissionTier
45 |
# File 'app/models/commission_rate.rb', line 45 belongs_to :commission_tier |