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
Constants included
from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
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
config
#after_commit
#publish_event
Instance Attribute Details
#aisle ⇒ Object
44
|
# File 'app/models/storage_location.rb', line 44
validates :aisle, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
#bin ⇒ Object
47
|
# File 'app/models/storage_location.rb', line 47
validates :bin, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
#level ⇒ Object
46
|
# File 'app/models/storage_location.rb', line 46
validates :level, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
#reference_number ⇒ Object
42
|
# File 'app/models/storage_location.rb', line 42
validates :reference_number, uniqueness: { scope: :store_id }
|
#section ⇒ Object
45
|
# File 'app/models/storage_location.rb', line 45
validates :section, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
#zone ⇒ Object
43
|
# File 'app/models/storage_location.rb', line 43
validates :zone, presence: true, inclusion: { in: ZONES }
|
Class Method Details
.select_options(store) ⇒ Object
53
54
55
|
# File 'app/models/storage_location.rb', line 53
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>
36
|
# File 'app/models/storage_location.rb', line 36
has_and_belongs_to_many :cycle_count_items
|
81
82
83
|
# File 'app/models/storage_location.rb', line 81
def format_reference_number
index_fields.map { |f| send(:"formatted_#{f}") }.join('.')
end
|
61
62
63
|
# File 'app/models/storage_location.rb', line 61
def formatted_aisle
'A%02i' % aisle
end
|
73
74
75
|
# File 'app/models/storage_location.rb', line 73
def formatted_bin
'B%02i' % bin
end
|
69
70
71
|
# File 'app/models/storage_location.rb', line 69
def formatted_level
'L%02i' % level
end
|
65
66
67
|
# File 'app/models/storage_location.rb', line 65
def formatted_section
'S%02i' % section
end
|
57
58
59
|
# File 'app/models/storage_location.rb', line 57
def formatted_zone
zone
end
|
#index_fields ⇒ Object
77
78
79
|
# File 'app/models/storage_location.rb', line 77
def index_fields
%i[zone aisle section level bin]
end
|
34
|
# File 'app/models/storage_location.rb', line 34
belongs_to :store
|
#store_items ⇒ ActiveRecord::Relation<StoreItem>
35
|
# File 'app/models/storage_location.rb', line 35
has_and_belongs_to_many :store_items
|
#to_s ⇒ Object
49
50
51
|
# File 'app/models/storage_location.rb', line 49
def to_s
reference_number
end
|