Class: SupplierItemPrice

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/supplier_item_price.rb

Overview

== Schema Information

Table name: supplier_item_prices
Database name: primary

id :integer not null, primary key
currency :string(255)
effective_from :date
purchasing_cost :decimal(11, 5)
unit_cost :decimal(11, 5)
created_at :datetime
updated_at :datetime
creator_id :integer
supplier_item_id :integer
updater_id :integer

Indexes

by_ef_siid (effective_from,supplier_item_id)
idx_si_id_updated_at (supplier_item_id,updated_at)
idx_sup_item_id_effective_from (supplier_item_id,effective_from)

Foreign Keys

supplier_item_prices_supplier_item_id_fk (supplier_item_id => supplier_items.id) ON DELETE => cascade

Constant Summary

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Class Method Summary collapse

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

#publish_event

Class Method Details

.currentActiveRecord::Relation<SupplierItemPrice>

A relation of SupplierItemPrices that are current. Active Record Scope

Returns:

See Also:



33
# File 'app/models/supplier_item_price.rb', line 33

scope :current, -> { where(SupplierItemPrice[:effective_from].lteq(Date.current)).order(:effective_from, :created_at) }

Instance Method Details

#currency_symbolObject



42
43
44
# File 'app/models/supplier_item_price.rb', line 42

def currency_symbol
  Money::Currency.new(currency).symbol
end

#supplier_itemSupplierItem



31
# File 'app/models/supplier_item_price.rb', line 31

belongs_to :supplier_item, :inverse_of => :supplier_item_prices, optional: true