Class: StorageLocation
Overview
== Schema Information
Table name: storage_locations
Database name: primary
id :bigint not null, primary key
aisle :integer not null
bin :integer not null
level :integer not null
notes :text
reference_number :string not null
section :integer not null
zone :string not null
store_id :integer not null
Indexes
idx_sl_aisle (aisle)
idx_sl_bin (bin)
idx_sl_level (level)
idx_sl_section (section)
idx_sl_zone (zone)
index_storage_locations_on_reference_number (store_id,reference_number) UNIQUE
Foreign Keys
fk_rails_... (store_id => stores.id)
Constant Summary
collapse
- ZONES =
('A'..'Z').to_a.freeze
Instance Attribute Summary collapse
Has and belongs to many
collapse
Class Method Summary
collapse
Instance Method Summary
collapse
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
#publish_event
Instance Attribute Details
#aisle ⇒ Object
43
|
# File 'app/models/storage_location.rb', line 43
validates :aisle, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
#bin ⇒ Object
46
|
# File 'app/models/storage_location.rb', line 46
validates :bin, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
#level ⇒ Object
45
|
# File 'app/models/storage_location.rb', line 45
validates :level, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
#reference_number ⇒ Object
41
|
# File 'app/models/storage_location.rb', line 41
validates :reference_number, uniqueness: { scope: :store_id }
|
#section ⇒ Object
44
|
# File 'app/models/storage_location.rb', line 44
validates :section, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
#zone ⇒ Object
42
|
# File 'app/models/storage_location.rb', line 42
validates :zone, presence: true, inclusion: { in: ZONES }
|
Class Method Details
.select_options(store) ⇒ Object
52
53
54
|
# File 'app/models/storage_location.rb', line 52
def self.select_options(store)
store.storage_locations.order(:reference_number).pluck(:reference_number, :id)
end
|
Instance Method Details
#cycle_count_items ⇒ ActiveRecord::Relation<CycleCountItem>
35
|
# File 'app/models/storage_location.rb', line 35
has_and_belongs_to_many :cycle_count_items
|
80
81
82
|
# File 'app/models/storage_location.rb', line 80
def format_reference_number
index_fields.map{|f| send("formatted_#{f}".to_sym)}.join('.')
end
|
60
61
62
|
# File 'app/models/storage_location.rb', line 60
def formatted_aisle
'A%02i' % aisle
end
|
72
73
74
|
# File 'app/models/storage_location.rb', line 72
def formatted_bin
'B%02i' % bin
end
|
68
69
70
|
# File 'app/models/storage_location.rb', line 68
def formatted_level
'L%02i' % level
end
|
64
65
66
|
# File 'app/models/storage_location.rb', line 64
def formatted_section
'S%02i' % section
end
|
56
57
58
|
# File 'app/models/storage_location.rb', line 56
def formatted_zone
zone
end
|
#index_fields ⇒ Object
76
77
78
|
# File 'app/models/storage_location.rb', line 76
def index_fields
%i[zone aisle section level bin]
end
|
33
|
# File 'app/models/storage_location.rb', line 33
belongs_to :store
|
#store_items ⇒ ActiveRecord::Relation<StoreItem>
34
|
# File 'app/models/storage_location.rb', line 34
has_and_belongs_to_many :store_items
|
#to_s ⇒ Object
48
49
50
|
# File 'app/models/storage_location.rb', line 48
def to_s
reference_number
end
|