unidom-inventory 1.0.3 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +37 -5
  3. data/app/controllers/unidom/inventory/application_controller.rb +8 -2
  4. data/app/helpers/unidom/inventory/application_helper.rb +7 -1
  5. data/app/jobs/unidom/inventory/application_job.rb +7 -1
  6. data/app/mailers/unidom/inventory/application_mailer.rb +9 -3
  7. data/app/models/unidom/inventory/application_record.rb +8 -2
  8. data/app/models/unidom/inventory/concerns/as_inventory_item.rb +31 -23
  9. data/app/models/unidom/inventory/concerns/as_store.rb +16 -8
  10. data/app/models/unidom/inventory/concerns/as_stored.rb +16 -8
  11. data/app/models/unidom/inventory/grouped_inventory_item.rb +12 -6
  12. data/app/models/unidom/inventory/inventory_item_variance.rb +38 -32
  13. data/app/models/unidom/inventory/item_issuing.rb +14 -8
  14. data/app/models/unidom/inventory/lot.rb +14 -8
  15. data/app/models/unidom/inventory/pick_item.rb +13 -7
  16. data/app/models/unidom/inventory/pick_list.rb +11 -5
  17. data/app/models/unidom/inventory/serialized_inventory_item.rb +12 -6
  18. data/db/migrate/20020901000000_create_unidom_serialized_inventory_items.rb +5 -5
  19. data/db/migrate/20020902000000_create_unidom_grouped_inventory_items.rb +5 -5
  20. data/db/migrate/20020903000000_create_unidom_inventory_item_variances.rb +4 -4
  21. data/db/migrate/20020911000000_create_unidom_lots.rb +4 -4
  22. data/db/migrate/20020921000000_create_unidom_pick_lists.rb +4 -4
  23. data/db/migrate/20020922000000_create_unidom_pick_items.rb +5 -5
  24. data/db/migrate/20020923000000_create_unidom_item_issuings.rb +5 -5
  25. data/lib/rspec/models/unidom/inventory/concerns/as_store_shared_examples.rb +45 -0
  26. data/lib/rspec/models/unidom/inventory/concerns/as_stored_shared_examples.rb +45 -0
  27. data/lib/unidom/inventory/rspec_shared_examples.rb +2 -0
  28. data/lib/unidom/inventory/version.rb +1 -1
  29. metadata +11 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 32158525d1a8bf6042b9caacadf539ea2ecfd57a
4
- data.tar.gz: 964134d12be7d9afb13dcb1746627f6858116025
2
+ SHA256:
3
+ metadata.gz: c3ad528a0044425394ae08209db37dc08a765126c7cd5cde6542324cc71505ac
4
+ data.tar.gz: 8e33f180fbf7408839e65863e728a5413a70080e0f56b86435ea27712976fd4a
5
5
  SHA512:
6
- metadata.gz: fa620ba7184e6ebfa452ef1efd8f8e64eef79b3deb1243a0973f919fb33148971ef939274e8643aee1b6dcc40138025f6cdc4a9d9f97148557133b0c7ab3edb8
7
- data.tar.gz: 44e20bcb02363abc43691a79321b014d245d6d8c279f36de3dbd6e6be4f07a8aa726be350fc5138a36d6c05444799daaf9ee954539af622a4d61d174c251ed85
6
+ metadata.gz: 74ac13809d430a0dac0eb72347eab053cf8cf7d4308092e9a50bfcf02f041495473c00813395d93d80db22e52de30f9d2f9576069f86ec1632b4d5cb242650c9
7
+ data.tar.gz: 25d8a0491784b082cec356d239029e6ab5bbaddcd503b8fbb1b3af93f7ba293eb9e11237bc3ee509a44269d3481eaab4d7831abe11ec3579ee19ad09ee0ddf92
data/README.md CHANGED
@@ -135,6 +135,20 @@ require 'unidom/inventory/validators_rspec'
135
135
  ### RSpec shared examples (to be integrated)
136
136
 
137
137
  ```ruby
138
+ # lib/unidom.rb
139
+ Unidom::Party::Shop.class_eval do
140
+
141
+ include Unidom::Inventory::Concerns::AsStore
142
+
143
+ end
144
+
145
+ Unidom::Product::Product.class_eval do
146
+
147
+ include Unidom::Inventory::Concerns::AsStored
148
+
149
+ end
150
+
151
+
138
152
  # The Unidom::Inventory::GroupedInventoryItem model & the Unidom::Inventory::SerializedInventoryItem model already include the Unidom::Inventory::Concerns::AsInventoryItem concern
139
153
  # app/models/your_inventory_item.rb
140
154
  class YourInventoryItem < ApplicationRecord
@@ -147,14 +161,32 @@ end
147
161
  # spec/support/unidom_rspec_shared_examples.rb
148
162
  require 'unidom/inventory/rspec_shared_examples'
149
163
 
150
- # spec/models/unidom/party/person_spec.rb
164
+ # spec/models/unidom/party/shop_spec.rb
165
+ describe Unidom::Party::Shop, type: :model do
166
+
167
+ it_behaves_like 'Unidom::Inventory::Concerns::AsStore', model_attributes
168
+
169
+ end
170
+
171
+ # spec/models/unidom/product/product_spec.rb
172
+ describe Unidom::Product::Product, type: :model do
173
+
174
+ it_behaves_like 'Unidom::Inventory::Concerns::AsStored', model_attributes
175
+
176
+ end
177
+
178
+ # spec/models/your_inventory_item_spec.rb
151
179
  describe YourInventoryItem, type: :model do
152
180
 
153
- model_attribtues = {
154
- your_attribute: 'your value'
155
- }
181
+ context do
182
+
183
+ model_attribtues = {
184
+ your_attribute: 'your value'
185
+ }
186
+
187
+ it_behaves_like 'Unidom::Inventory::Concerns::AsInventoryItem', model_attribtues
156
188
 
157
- it_behaves_like 'Unidom::Inventory::Concerns::AsInventoryItem', model_attribtues
189
+ end
158
190
 
159
191
  end
160
192
  ```
@@ -1,6 +1,12 @@
1
1
  ##
2
2
  # Application controller 是模块内所有控制器的基类。
3
3
 
4
- class Unidom::Inventory::ApplicationController < ActionController::Base
5
- protect_from_forgery with: :exception
4
+ module Unidom
5
+ module Inventory
6
+
7
+ class ApplicationController < ActionController::Base
8
+ protect_from_forgery with: :exception
9
+ end
10
+
11
+ end
6
12
  end
@@ -1,2 +1,8 @@
1
- module Unidom::Inventory::ApplicationHelper
1
+ module Unidom
2
+ module Inventory
3
+
4
+ module ApplicationHelper
5
+ end
6
+
7
+ end
2
8
  end
@@ -1,5 +1,11 @@
1
1
  ##
2
2
  # Application job 是模块内所有异步任务的基类。
3
3
 
4
- class Unidom::Inventory::ApplicationJob < ActiveJob::Base
4
+ module Unidom
5
+ module Inventory
6
+
7
+ class ApplicationJob < ActiveJob::Base
8
+ end
9
+
10
+ end
5
11
  end
@@ -1,7 +1,13 @@
1
1
  ##
2
2
  # Application mailer 是模块内所有电子邮件发送类的基类。
3
3
 
4
- class Unidom::Inventory::ApplicationMailer < ActionMailer::Base
5
- default from: 'from@example.com'
6
- layout 'mailer'
4
+ module Unidom
5
+ module Inventory
6
+
7
+ class ApplicationMailer < ActionMailer::Base
8
+ default from: 'from@example.com'
9
+ layout 'mailer'
10
+ end
11
+
12
+ end
7
13
  end
@@ -1,6 +1,12 @@
1
1
  ##
2
2
  # Application record 是模块内所有模型的抽象基类。
3
3
 
4
- class Unidom::Inventory::ApplicationRecord < ActiveRecord::Base
5
- self.abstract_class = true
4
+ module Unidom
5
+ module Inventory
6
+
7
+ class ApplicationRecord < ActiveRecord::Base
8
+ self.abstract_class = true
9
+ end
10
+
11
+ end
6
12
  end
@@ -1,33 +1,41 @@
1
- module Unidom::Inventory::Concerns::AsInventoryItem
1
+ module Unidom
2
+ module Inventory
3
+ module Concerns
2
4
 
3
- extend ActiveSupport::Concern
5
+ module AsInventoryItem
4
6
 
5
- included do |includer|
7
+ extend ActiveSupport::Concern
6
8
 
7
- belongs_to :stored, polymorphic: true
8
- belongs_to :store, polymorphic: true
9
- belongs_to :lot, class_name: 'Unidom::Inventory::Lot'
9
+ included do |includer|
10
10
 
11
- has_many :pick_items, class_name: 'Unidom::Inventory::PickItem', as: :inventory_item
12
- has_many :variances, class_name: 'Unidom::Inventory::InventoryItemVariance', as: :inventory_item
11
+ belongs_to :stored, polymorphic: true
12
+ belongs_to :store, polymorphic: true
13
+ belongs_to :lot, class_name: 'Unidom::Inventory::Lot'
14
+
15
+ has_many :pick_items, class_name: 'Unidom::Inventory::PickItem', as: :inventory_item
16
+ has_many :variances, class_name: 'Unidom::Inventory::InventoryItemVariance', as: :inventory_item
17
+
18
+ def is_adjusted!(quantity: nil, due_to: nil, at: Time.now, description: nil, instruction: nil)
19
+ if respond_to? :quantity
20
+ increment! :quantity, quantity
21
+ else
22
+ if quantity.nil?
23
+ quantity = -1
24
+ soft_destroy
25
+ else
26
+ raise ArgumentError.new('The quantity should be nil when Inventory Item Variance is adjusted.')
27
+ end
28
+ end
29
+ variances.create! inventory_item: self, reason: due_to, quantity: quantity, description: description, instruction: instruction, opened_at: at
30
+ end
13
31
 
14
- def is_adjusted!(quantity: nil, due_to: nil, at: Time.now, description: nil, instruction: nil)
15
- if respond_to? :quantity
16
- increment! :quantity, quantity
17
- else
18
- if quantity.nil?
19
- quantity = -1
20
- soft_destroy
21
- else
22
- raise ArgumentError.new('The quantity should be nil when Inventory Item Variance is adjusted.')
23
32
  end
24
- end
25
- variances.create! inventory_item: self, reason: due_to, quantity: quantity, description: description, instruction: instruction, opened_at: at
26
- end
27
33
 
28
- end
34
+ module ClassMethods
35
+ end
29
36
 
30
- module ClassMethods
31
- end
37
+ end
32
38
 
39
+ end
40
+ end
33
41
  end
@@ -1,15 +1,23 @@
1
- module Unidom::Inventory::Concerns::AsStore
1
+ module Unidom
2
+ module Inventory
3
+ module Concerns
2
4
 
3
- extend ActiveSupport::Concern
5
+ module AsStore
4
6
 
5
- included do |includer|
7
+ extend ActiveSupport::Concern
6
8
 
7
- has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :store_id
8
- has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem', foreign_key: :store_id
9
+ included do |includer|
9
10
 
10
- end
11
+ has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :store_id
12
+ has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem', foreign_key: :store_id
11
13
 
12
- module ClassMethods
13
- end
14
+ end
15
+
16
+ module ClassMethods
17
+ end
14
18
 
19
+ end
20
+
21
+ end
22
+ end
15
23
  end
@@ -1,15 +1,23 @@
1
- module Unidom::Inventory::Concerns::AsStored
1
+ module Unidom
2
+ module Inventory
3
+ module Concerns
2
4
 
3
- extend ActiveSupport::Concern
5
+ module AsStored
4
6
 
5
- included do |includer|
7
+ extend ActiveSupport::Concern
6
8
 
7
- has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :stored_id
8
- has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem', foreign_key: :stored_id
9
+ included do |includer|
9
10
 
10
- end
11
+ has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :stored_id
12
+ has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem', foreign_key: :stored_id
11
13
 
12
- module ClassMethods
13
- end
14
+ end
15
+
16
+ module ClassMethods
17
+ end
14
18
 
19
+ end
20
+
21
+ end
22
+ end
15
23
  end
@@ -1,13 +1,19 @@
1
1
  ##
2
2
  # Grouped Inventory Item 是分组库存项。
3
3
 
4
- class Unidom::Inventory::GroupedInventoryItem < Unidom::Inventory::ApplicationRecord
4
+ module Unidom
5
+ module Inventory
5
6
 
6
- self.table_name = 'unidom_grouped_inventory_items'
7
+ class GroupedInventoryItem < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
- include Unidom::Inventory::Concerns::AsInventoryItem
9
+ self.table_name = 'unidom_grouped_inventory_items'
10
10
 
11
- validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0.0, less_than_or_equal_to: 1_000_000_000.00 }
11
+ include Unidom::Common::Concerns::ModelExtension
12
+ include Unidom::Inventory::Concerns::AsInventoryItem
12
13
 
13
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::GroupedInventoryItem'
14
+ validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0.0, less_than_or_equal_to: 1_000_000_000.00 }
15
+
16
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::GroupedInventoryItem'
17
+
18
+ end
19
+ end
@@ -4,37 +4,43 @@
4
4
  # #reason 是调整的原因。
5
5
  # #quantity 是调整数量,正数表示库存增加,负数表示库存减少。
6
6
 
7
- class Unidom::Inventory::InventoryItemVariance < Unidom::Inventory::ApplicationRecord
8
-
9
- self.table_name = 'unidom_inventory_item_variances'
10
-
11
- include Unidom::Common::Concerns::ModelExtension
12
-
13
- #validates :quantity, presence: true, numericality: true
14
- validates :quantity, presence: true, numericality: { greater_than: -1_000_000_000.00, less_than: 1_000_000_000.00 }
15
-
16
- belongs_to :inventory_item, polymorphic: true
17
- belongs_to :reason, polymorphic: true
18
-
19
- scope :inventory_item_is, ->(inventory_item) { where inventory_item: inventory_item }
20
- scope :caused_by, ->(reason) { where reason: reason }
21
-
22
- ##
23
- # 对库存项 inventory_item 进行调整。调整数量为 quantity ,缺省为 nil 。调整原因为 due_to 。调整时间为 at ,缺省为当前时间。
24
- # 另有适用于己方的备注信息 description 和适用于对方的备注信息 instruction 。
25
- # Unidom::Inventory::InventoryItemVariance.adjust! inventory_item, quantity: 3
26
- def self.adjust!(inventory_item, quantity: nil, due_to: nil, at: Time.now, description: nil, instruction: nil)
27
- if inventory_item.respond_to? :quantity
28
- inventory_item.increment! :quantity, quantity
29
- else
30
- if quantity.nil?
31
- quantity = -1
32
- inventory_item.soft_destroy
33
- else
34
- raise ArgumentError.new('The quantity should be -1 when Inventory Item Variance adjusts a Serialized Inventory Item.')
7
+ module Unidom
8
+ module Inventory
9
+
10
+ class InventoryItemVariance < ApplicationRecord
11
+
12
+ self.table_name = 'unidom_inventory_item_variances'
13
+
14
+ include Unidom::Common::Concerns::ModelExtension
15
+
16
+ #validates :quantity, presence: true, numericality: true
17
+ validates :quantity, presence: true, numericality: { greater_than: -1_000_000_000.00, less_than: 1_000_000_000.00 }
18
+
19
+ belongs_to :inventory_item, polymorphic: true
20
+ belongs_to :reason, polymorphic: true
21
+
22
+ scope :inventory_item_is, ->(inventory_item) { where inventory_item: inventory_item }
23
+ scope :caused_by, ->(reason) { where reason: reason }
24
+
25
+ ##
26
+ # 对库存项 inventory_item 进行调整。调整数量为 quantity ,缺省为 nil 。调整原因为 due_to 。调整时间为 at ,缺省为当前时间。
27
+ # 另有适用于己方的备注信息 description 和适用于对方的备注信息 instruction 。
28
+ # Unidom::Inventory::InventoryItemVariance.adjust! inventory_item, quantity: 3
29
+ def self.adjust!(inventory_item, quantity: nil, due_to: nil, at: Time.now, description: nil, instruction: nil)
30
+ if inventory_item.respond_to? :quantity
31
+ inventory_item.increment! :quantity, quantity
32
+ else
33
+ if quantity.nil?
34
+ quantity = -1
35
+ inventory_item.soft_destroy
36
+ else
37
+ raise ArgumentError.new('The quantity should be -1 when Inventory Item Variance adjusts a Serialized Inventory Item.')
38
+ end
39
+ end
40
+ create! inventory_item: inventory_item, reason: due_to, quantity: quantity, description: description, instruction: instruction, opened_at: at
35
41
  end
36
- end
37
- create! inventory_item: inventory_item, reason: due_to, quantity: quantity, description: description, instruction: instruction, opened_at: at
38
- end
39
42
 
40
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::InventoryItemVariance'
43
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::InventoryItemVariance'
44
+
45
+ end
46
+ end
@@ -4,16 +4,22 @@
4
4
  # #inventory_item 是库存项,可以由 #pick_item 导出。
5
5
  # #target_item 是目标项,比如: ShipmentItem 、 OrderItem 等。
6
6
 
7
- class Unidom::Inventory::ItemIssuing < Unidom::Inventory::ApplicationRecord
7
+ module Unidom
8
+ module Inventory
8
9
 
9
- self.table_name = 'unidom_item_issuings'
10
+ class ItemIssuing < ApplicationRecord
10
11
 
11
- include Unidom::Common::Concerns::ModelExtension
12
+ self.table_name = 'unidom_item_issuings'
12
13
 
13
- validates :quantity, presence: true, numericality: true
14
+ include Unidom::Common::Concerns::ModelExtension
14
15
 
15
- belongs_to :pick_item, class_name: 'Unidom::Inventory::PickItem'
16
- belongs_to :inventory_item, polymorphic: true
17
- belongs_to :target_item, polymorphic: true
16
+ validates :quantity, presence: true, numericality: true
18
17
 
19
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::ItemIssuing'
18
+ belongs_to :pick_item, class_name: 'Unidom::Inventory::PickItem'
19
+ belongs_to :inventory_item, polymorphic: true
20
+ belongs_to :target_item, polymorphic: true
21
+
22
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::ItemIssuing'
23
+
24
+ end
25
+ end
@@ -1,16 +1,22 @@
1
1
  ##
2
2
  # Lot 是批量。
3
3
 
4
- class Unidom::Inventory::Lot < Unidom::Inventory::ApplicationRecord
4
+ module Unidom
5
+ module Inventory
5
6
 
6
- self.table_name = 'unidom_lots'
7
+ class Lot < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
+ self.table_name = 'unidom_lots'
9
10
 
10
- validates :quantity, presence: true, numericality: true
11
- validates :identification_number, presence: true, length: { in: 2..columns_hash['identification_number'].limit }
11
+ include Unidom::Common::Concerns::ModelExtension
12
12
 
13
- has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem'
14
- has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem'
13
+ validates :quantity, presence: true, numericality: true
14
+ validates :identification_number, presence: true, length: { in: 2..columns_hash['identification_number'].limit }
15
15
 
16
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::Lot'
16
+ has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem'
17
+ has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem'
18
+
19
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::Lot'
20
+
21
+ end
22
+ end
@@ -1,15 +1,21 @@
1
1
  ##
2
2
  # Pick Item 是出库单项。
3
3
 
4
- class Unidom::Inventory::PickItem < Unidom::Inventory::ApplicationRecord
4
+ module Unidom
5
+ module Inventory
5
6
 
6
- self.table_name = 'unidom_pick_items'
7
+ class PickItem < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
+ self.table_name = 'unidom_pick_items'
9
10
 
10
- validates :quantity, presence: true, numericality: true
11
+ include Unidom::Common::Concerns::ModelExtension
11
12
 
12
- belongs_to :pick_list, class_name: 'Unidom::Inventory::PickList'
13
- belongs_to :inventory_item, polymorphic: true
13
+ validates :quantity, presence: true, numericality: true
14
14
 
15
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::PickItem'
15
+ belongs_to :pick_list, class_name: 'Unidom::Inventory::PickList'
16
+ belongs_to :inventory_item, polymorphic: true
17
+
18
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::PickItem'
19
+
20
+ end
21
+ end
@@ -1,12 +1,18 @@
1
1
  ##
2
2
  # Pick List 是出库单。
3
3
 
4
- class Unidom::Inventory::PickList < Unidom::Inventory::ApplicationRecord
4
+ module Unidom
5
+ module Inventory
5
6
 
6
- self.table_name = 'unidom_pick_lists'
7
+ class PickList < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
+ self.table_name = 'unidom_pick_lists'
9
10
 
10
- has_many :items, class_name: 'Unidom::Inventory::PickItem' #, foreign_key: :pick_list_id
11
+ include Unidom::Common::Concerns::ModelExtension
11
12
 
12
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::PickList'
13
+ has_many :items, class_name: 'Unidom::Inventory::PickItem' #, foreign_key: :pick_list_id
14
+
15
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::PickList'
16
+
17
+ end
18
+ end
@@ -1,13 +1,19 @@
1
1
  ##
2
2
  # Serialized Inventory Item 是序列化库存项。
3
3
 
4
- class Unidom::Inventory::SerializedInventoryItem < Unidom::Inventory::ApplicationRecord
4
+ module Unidom
5
+ module Inventory
5
6
 
6
- self.table_name = 'unidom_serialized_inventory_items'
7
+ class SerializedInventoryItem < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
- include Unidom::Inventory::Concerns::AsInventoryItem
9
+ self.table_name = 'unidom_serialized_inventory_items'
10
10
 
11
- validates :serial_number, presence: true, length: { in: 2..columns_hash['serial_number'].limit }
11
+ include Unidom::Common::Concerns::ModelExtension
12
+ include Unidom::Inventory::Concerns::AsInventoryItem
12
13
 
13
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::SerializedInventoryItem'
14
+ validates :serial_number, presence: true, length: { in: 2..columns_hash['serial_number'].limit }
15
+
16
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::SerializedInventoryItem'
17
+
18
+ end
19
+ end
@@ -1,4 +1,4 @@
1
- class CreateUnidomSerializedInventoryItems < ActiveRecord::Migration
1
+ class CreateUnidomSerializedInventoryItems < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -12,9 +12,9 @@ class CreateUnidomSerializedInventoryItems < ActiveRecord::Migration
12
12
 
13
13
  t.string :serial_number, null: false, default: nil, limit: 200
14
14
 
15
- t.column :state, 'char(1)', null: false, default: 'C'
16
- t.datetime :opened_at, null: false, default: Time.utc(1970)
17
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
15
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
16
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
17
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
18
18
  t.boolean :defunct, null: false, default: false
19
19
  t.jsonb :notation, null: false, default: {}
20
20
 
@@ -24,7 +24,7 @@ class CreateUnidomSerializedInventoryItems < ActiveRecord::Migration
24
24
 
25
25
  add_index :unidom_serialized_inventory_items, :stored_id
26
26
  add_index :unidom_serialized_inventory_items, :store_id
27
- add_index :unidom_serialized_inventory_items, :lot_id
27
+ #add_index :unidom_serialized_inventory_items, :lot_id
28
28
  add_index :unidom_serialized_inventory_items, :serial_number
29
29
 
30
30
  end
@@ -1,4 +1,4 @@
1
- class CreateUnidomGroupedInventoryItems < ActiveRecord::Migration
1
+ class CreateUnidomGroupedInventoryItems < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -12,9 +12,9 @@ class CreateUnidomGroupedInventoryItems < ActiveRecord::Migration
12
12
 
13
13
  t.decimal :quantity, null: false, default: 0.0, precision: 12, scale: 2
14
14
 
15
- t.column :state, 'char(1)', null: false, default: 'C'
16
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
17
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
15
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
16
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
17
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
18
18
  t.boolean :defunct, null: false, default: false
19
19
  t.jsonb :notation, null: false, default: {}
20
20
 
@@ -24,7 +24,7 @@ class CreateUnidomGroupedInventoryItems < ActiveRecord::Migration
24
24
 
25
25
  add_index :unidom_grouped_inventory_items, :stored_id
26
26
  add_index :unidom_grouped_inventory_items, :store_id
27
- add_index :unidom_grouped_inventory_items, :lot_id
27
+ #add_index :unidom_grouped_inventory_items, :lot_id
28
28
 
29
29
  end
30
30
 
@@ -1,4 +1,4 @@
1
- class CreateUnidomInventoryItemVariances < ActiveRecord::Migration
1
+ class CreateUnidomInventoryItemVariances < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -14,9 +14,9 @@ class CreateUnidomInventoryItemVariances < ActiveRecord::Migration
14
14
  t.text :description
15
15
  t.text :instruction
16
16
 
17
- t.column :state, 'char(1)', null: false, default: 'C'
18
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
19
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
17
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
18
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
19
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
20
20
  t.boolean :defunct, null: false, default: false
21
21
  t.jsonb :notation, null: false, default: {}
22
22
 
@@ -1,4 +1,4 @@
1
- class CreateUnidomLots < ActiveRecord::Migration
1
+ class CreateUnidomLots < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -10,9 +10,9 @@ class CreateUnidomLots < ActiveRecord::Migration
10
10
  t.text :description
11
11
  t.text :instruction
12
12
 
13
- t.column :state, 'char(1)', null: false, default: 'C'
14
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
15
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
13
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
14
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
15
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
16
16
  t.boolean :defunct, null: false, default: false
17
17
  t.jsonb :notation, null: false, default: {}
18
18
 
@@ -1,4 +1,4 @@
1
- class CreateUnidomPickLists < ActiveRecord::Migration
1
+ class CreateUnidomPickLists < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -7,9 +7,9 @@ class CreateUnidomPickLists < ActiveRecord::Migration
7
7
  t.text :description
8
8
  t.text :instruction
9
9
 
10
- t.column :state, 'char(1)', null: false, default: 'C'
11
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
12
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
10
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
11
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
12
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
13
13
  t.boolean :defunct, null: false, default: false
14
14
  t.jsonb :notation, null: false, default: {}
15
15
 
@@ -1,4 +1,4 @@
1
- class CreateUnidomPickItems < ActiveRecord::Migration
1
+ class CreateUnidomPickItems < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -13,9 +13,9 @@ class CreateUnidomPickItems < ActiveRecord::Migration
13
13
  t.text :description
14
14
  t.text :instruction
15
15
 
16
- t.column :state, 'char(1)', null: false, default: 'C'
17
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
18
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
16
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
17
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
18
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
19
19
  t.boolean :defunct, null: false, default: false
20
20
  t.jsonb :notation, null: false, default: {}
21
21
 
@@ -23,7 +23,7 @@ class CreateUnidomPickItems < ActiveRecord::Migration
23
23
 
24
24
  end
25
25
 
26
- add_index :unidom_pick_items, :pick_list_id
26
+ #add_index :unidom_pick_items, :pick_list_id
27
27
  add_index :unidom_pick_items, :inventory_item_id
28
28
 
29
29
  end
@@ -1,4 +1,4 @@
1
- class CreateUnidomItemIssuings < ActiveRecord::Migration
1
+ class CreateUnidomItemIssuings < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -15,9 +15,9 @@ class CreateUnidomItemIssuings < ActiveRecord::Migration
15
15
  t.text :description
16
16
  t.text :instruction
17
17
 
18
- t.column :state, 'char(1)', null: false, default: 'C'
19
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
20
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
18
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
19
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
20
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
21
21
  t.boolean :defunct, null: false, default: false
22
22
  t.jsonb :notation, null: false, default: {}
23
23
 
@@ -25,7 +25,7 @@ class CreateUnidomItemIssuings < ActiveRecord::Migration
25
25
 
26
26
  end
27
27
 
28
- add_index :unidom_item_issuings, :pick_item_id
28
+ #add_index :unidom_item_issuings, :pick_item_id
29
29
  add_index :unidom_item_issuings, :inventory_item_id
30
30
  add_index :unidom_item_issuings, :target_item_id
31
31
 
@@ -0,0 +1,45 @@
1
+ shared_examples 'Unidom::Inventory::Concerns::AsStore' do |model_attributes|
2
+
3
+ before :each do
4
+ end
5
+
6
+ after :each do
7
+ end
8
+
9
+ context do
10
+
11
+ grouped_inventory_item_1_attributes = {
12
+ stored_id: SecureRandom.uuid,
13
+ stored_type: 'Unidom::Inventory::Stored::Mock',
14
+ lot_id: SecureRandom.uuid,
15
+ quantity: 10.00
16
+ }
17
+
18
+ grouped_inventory_item_2_attributes = {
19
+ stored_id: SecureRandom.uuid,
20
+ stored_type: 'Unidom::Inventory::Stored::Mock',
21
+ lot_id: SecureRandom.uuid,
22
+ quantity: 20.00
23
+ }
24
+
25
+ it_behaves_like 'has_many', model_attributes, :grouped_inventory_items, Unidom::Inventory::GroupedInventoryItem, [ grouped_inventory_item_1_attributes, grouped_inventory_item_2_attributes ]
26
+
27
+ serialized_inventory_item_1_attributes = {
28
+ stored_id: SecureRandom.uuid,
29
+ stored_type: 'Unidom::Inventory::Stored::Mock',
30
+ lot_id: SecureRandom.uuid,
31
+ serial_number: SecureRandom.hex(16)
32
+ }
33
+
34
+ serialized_inventory_item_2_attributes = {
35
+ stored_id: SecureRandom.uuid,
36
+ stored_type: 'Unidom::Inventory::Stored::Mock',
37
+ lot_id: SecureRandom.uuid,
38
+ serial_number: SecureRandom.hex(16)
39
+ }
40
+
41
+ it_behaves_like 'has_many', model_attributes, :serialized_inventory_items, Unidom::Inventory::SerializedInventoryItem, [ serialized_inventory_item_1_attributes, serialized_inventory_item_2_attributes ]
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,45 @@
1
+ shared_examples 'Unidom::Inventory::Concerns::AsStored' do |model_attributes|
2
+
3
+ before :each do
4
+ end
5
+
6
+ after :each do
7
+ end
8
+
9
+ context do
10
+
11
+ grouped_inventory_item_1_attributes = {
12
+ store_id: SecureRandom.uuid,
13
+ store_type: 'Unidom::Inventory::Stored::Mock',
14
+ lot_id: SecureRandom.uuid,
15
+ quantity: 10.00
16
+ }
17
+
18
+ grouped_inventory_item_2_attributes = {
19
+ store_id: SecureRandom.uuid,
20
+ store_type: 'Unidom::Inventory::Stored::Mock',
21
+ lot_id: SecureRandom.uuid,
22
+ quantity: 20.00
23
+ }
24
+
25
+ it_behaves_like 'has_many', model_attributes, :grouped_inventory_items, Unidom::Inventory::GroupedInventoryItem, [ grouped_inventory_item_1_attributes, grouped_inventory_item_2_attributes ]
26
+
27
+ serialized_inventory_item_1_attributes = {
28
+ store_id: SecureRandom.uuid,
29
+ store_type: 'Unidom::Inventory::Stored::Mock',
30
+ lot_id: SecureRandom.uuid,
31
+ serial_number: SecureRandom.hex(16)
32
+ }
33
+
34
+ serialized_inventory_item_2_attributes = {
35
+ store_id: SecureRandom.uuid,
36
+ store_type: 'Unidom::Inventory::Stored::Mock',
37
+ lot_id: SecureRandom.uuid,
38
+ serial_number: SecureRandom.hex(16)
39
+ }
40
+
41
+ it_behaves_like 'has_many', model_attributes, :serialized_inventory_items, Unidom::Inventory::SerializedInventoryItem, [ serialized_inventory_item_1_attributes, serialized_inventory_item_2_attributes ]
42
+
43
+ end
44
+
45
+ end
@@ -1 +1,3 @@
1
1
  require 'rspec/models/unidom/inventory/concerns/as_inventory_item_shared_examples'
2
+ require 'rspec/models/unidom/inventory/concerns/as_store_shared_examples'
3
+ require 'rspec/models/unidom/inventory/concerns/as_stored_shared_examples'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Inventory
3
- VERSION = '1.0.3'.freeze
3
+ VERSION = '2.0.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-01 00:00:00.000000000 Z
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.9'
26
+ version: '2.0'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Inventory domain model engine includes the Serialized Inventory Item, the Grouped
29
29
  Inventory Item, the Lot, and the Inventory Item Variance models. Unidom (统一领域对象模型)是一系列的领域模型引擎。库存领域模型引擎包括序列化库存项、分组库存项、批量和库存项变化的模型。
@@ -64,6 +64,8 @@ files:
64
64
  - db/migrate/20020922000000_create_unidom_pick_items.rb
65
65
  - db/migrate/20020923000000_create_unidom_item_issuings.rb
66
66
  - lib/rspec/models/unidom/inventory/concerns/as_inventory_item_shared_examples.rb
67
+ - lib/rspec/models/unidom/inventory/concerns/as_store_shared_examples.rb
68
+ - lib/rspec/models/unidom/inventory/concerns/as_stored_shared_examples.rb
67
69
  - lib/rspec/models/unidom/inventory/grouped_inventory_item_spec.rb
68
70
  - lib/rspec/models/unidom/inventory/inventory_item_variance_spec.rb
69
71
  - lib/rspec/models/unidom/inventory/item_issuing_spec.rb
@@ -79,11 +81,11 @@ files:
79
81
  - lib/unidom/inventory/types_rspec.rb
80
82
  - lib/unidom/inventory/validators_rspec.rb
81
83
  - lib/unidom/inventory/version.rb
82
- homepage: https://github.com/topbitdu/unidom-inventory
84
+ homepage: https://gitee.com/Unidom/unidom-inventory
83
85
  licenses:
84
86
  - MIT
85
87
  metadata: {}
86
- post_install_message:
88
+ post_install_message:
87
89
  rdoc_options: []
88
90
  require_paths:
89
91
  - lib
@@ -98,9 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
100
  - !ruby/object:Gem::Version
99
101
  version: '0'
100
102
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.6.4
103
- signing_key:
103
+ rubygems_version: 3.2.3
104
+ signing_key:
104
105
  specification_version: 4
105
106
  summary: Unidom Inventory Domain Model Engine 库存领域模型引擎
106
107
  test_files: []