Class: ViewAmazonCatalogItem
- Inherits:
-
ApplicationViewRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApplicationViewRecord
- ViewAmazonCatalogItem
- Defined in:
- app/models/view_amazon_catalog_item.rb
Overview
== Schema Information
Table name: view_amazon_catalog_items
Database name: primary
id :integer primary key
amazon_asin :string(10)
amazon_info_datetime :datetime
amazon_min_price_with_tax :decimal(, )
amazon_price_with_tax :decimal(, )
amazon_product_url :text
amount :decimal(8, 2)
amz_last_buy_box_winner_change :datetime
amz_min_seller_price_override :decimal(8, 2)
catalog_name :string(255)
currency :string(255)
currency_symbol :string(255)
disable_amz_repricing :boolean
effective_price :decimal(8, 2)
effective_price_with_vat :decimal(, )
goods_vat_rate :decimal(6, 4)
is_amz_buy_box_winner :boolean
is_amz_featured_merchant :boolean
item_name :text
item_suppressed_status :string
item_suppressed_status_message :string
marketplace_identifier :string(20)
old_amount :decimal(10, 2)
price_updated_at :datetime
price_with_vat :decimal(, )
retail_price :decimal(8, 2)
retailer_information :jsonb
sale_price :decimal(8, 2)
sku :string
state :string(30)
url :string
catalog_id :integer
catalog_item_id :integer
item_id :integer
store_item_id :integer
Belongs to collapse
- #catalog ⇒ Catalog
-
#catalog_item ⇒ CatalogItem
Associations for preloading additional data not in the view.
Has many collapse
Class Method Summary collapse
-
.active ⇒ ActiveRecord::Relation<ViewAmazonCatalogItem>
A relation of ViewAmazonCatalogItems that are active.
-
.for_catalog ⇒ ActiveRecord::Relation<ViewAmazonCatalogItem>
A relation of ViewAmazonCatalogItems that are for catalog.
- .ransackable_associations(_auth_object = nil) ⇒ Object
-
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration - allow searching on flattened columns.
-
.with_state ⇒ ActiveRecord::Relation<ViewAmazonCatalogItem>
A relation of ViewAmazonCatalogItems that are with state.
Instance Method Summary collapse
-
#amazon_minimum_seller_allowed_price_with_tax ⇒ Object
Alias for helpers expecting this method.
-
#item ⇒ Object
Compatibility aliases for helpers that expect nested structure These delegate to flattened columns from the view.
- #store_item ⇒ Object
-
#tax_rate ⇒ Object
Tax rate from view (already computed in SQL).
Methods inherited from ApplicationViewRecord
Methods inherited from ApplicationRecord
ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Class Method Details
.active ⇒ ActiveRecord::Relation<ViewAmazonCatalogItem>
A relation of ViewAmazonCatalogItems that are active. Active Record Scope
54 |
# File 'app/models/view_amazon_catalog_item.rb', line 54 scope :active, -> { where(state: 'active') } |
.for_catalog ⇒ ActiveRecord::Relation<ViewAmazonCatalogItem>
A relation of ViewAmazonCatalogItems that are for catalog. Active Record Scope
53 |
# File 'app/models/view_amazon_catalog_item.rb', line 53 scope :for_catalog, ->(catalog_id) { where(catalog_id: catalog_id) } |
.ransackable_associations(_auth_object = nil) ⇒ Object
68 69 70 |
# File 'app/models/view_amazon_catalog_item.rb', line 68 def self.ransackable_associations(_auth_object = nil) %w[amazon_catalog_item_flags] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration - allow searching on flattened columns
58 59 60 61 62 63 64 65 66 |
# File 'app/models/view_amazon_catalog_item.rb', line 58 def self.ransackable_attributes(_auth_object = nil) %w[ id catalog_id store_item_id item_id amount sale_price state sku item_name amazon_asin catalog_name is_amz_buy_box_winner is_amz_featured_merchant disable_amz_repricing price_updated_at amazon_info_datetime ] end |
.with_state ⇒ ActiveRecord::Relation<ViewAmazonCatalogItem>
A relation of ViewAmazonCatalogItems that are with state. Active Record Scope
55 |
# File 'app/models/view_amazon_catalog_item.rb', line 55 scope :with_state, ->(states) { where(state: states) } |
Instance Method Details
#amazon_catalog_item_flags ⇒ ActiveRecord::Relation<AmazonCatalogItemFlag>
50 |
# File 'app/models/view_amazon_catalog_item.rb', line 50 has_many :amazon_catalog_item_flags, foreign_key: :catalog_item_id, primary_key: :catalog_item_id |
#amazon_minimum_seller_allowed_price_with_tax ⇒ Object
Alias for helpers expecting this method
93 94 95 |
# File 'app/models/view_amazon_catalog_item.rb', line 93 def amazon_minimum_seller_allowed_price_with_tax amazon_min_price_with_tax end |
#catalog ⇒ Catalog
49 |
# File 'app/models/view_amazon_catalog_item.rb', line 49 belongs_to :catalog, optional: true |
#catalog_item ⇒ CatalogItem
Associations for preloading additional data not in the view
48 |
# File 'app/models/view_amazon_catalog_item.rb', line 48 belongs_to :catalog_item, optional: true |
#item ⇒ Object
Compatibility aliases for helpers that expect nested structure
These delegate to flattened columns from the view
75 76 77 78 79 80 |
# File 'app/models/view_amazon_catalog_item.rb', line 75 def item # Simple struct for helpers expecting catalog_item.item.sku @_item ||= Struct.new(:id, :sku, :name, :amazon_asin).new( item_id, sku, item_name, amazon_asin ) end |
#store_item ⇒ Object
82 83 84 85 |
# File 'app/models/view_amazon_catalog_item.rb', line 82 def store_item # Simple struct for helpers expecting catalog_item.store_item.item_id @_store_item ||= Struct.new(:id, :item_id).new(store_item_id, item_id) end |
#tax_rate ⇒ Object
Tax rate from view (already computed in SQL)
88 89 90 |
# File 'app/models/view_amazon_catalog_item.rb', line 88 def tax_rate goods_vat_rate end |