unidom-inventory 0.5 → 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -5
- data/app/models/unidom/inventory/concerns/as_inventory_item.rb +2 -1
- data/app/models/unidom/inventory/inventory_item_variance.rb +20 -0
- data/db/migrate/20020903000000_create_unidom_inventory_item_variances.rb +31 -0
- data/lib/unidom/inventory/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59116b8cfb8504d2ff15c7ff9afa640d77542afc
|
4
|
+
data.tar.gz: 9df508c0df726dfb5b350d36dadea5a21bbae35a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f24af042b909c72252e548c4958894850108f9cc8097db04d2e33ea81650e00b0a14ab64351174f11ab5e2fdfb65f3e93e5faa4d98a14b831070dc36faacd821
|
7
|
+
data.tar.gz: 49e7eca834921f0c1e8663c58301256ae87e6be4936f67f0b7200900e7fe648b323812c1d2a8102f70c64fbe1f9945ca4ea300076894447541e757709928e061
|
data/README.md
CHANGED
@@ -34,6 +34,7 @@ The migration versions start with 200209.
|
|
34
34
|
|
35
35
|
|
36
36
|
## Call the Model
|
37
|
+
|
37
38
|
```ruby
|
38
39
|
lot = Unidom::Inventory::Lot.create! identification_number: '20040312', description: '1 more thing', instruction: 'Please note...'
|
39
40
|
|
@@ -48,6 +49,10 @@ pick_list = Unidom::Inventory::PickList.create!
|
|
48
49
|
pick_item = pick_list.items.create! inventory_item: grouped_inventory_item, quantity: 100
|
49
50
|
item_issuing = Unidom::Inventory::ItemIssuing.create! pick_item: pick_item, inventory_item: grouped_inventory_item, target_item: nil
|
50
51
|
# target_item could be nil or any model like: shipment item or order item
|
52
|
+
|
53
|
+
variance = Unidom::Inventory::InventoryItemVariance.create! inventory_item: grouped_inventory_item, reason: nil, opened_at: Time.now
|
54
|
+
# or the following source code do the exact same thing.
|
55
|
+
grouped_inventory_item.variances.create! quantity: 10, reason: nil, opened_at: Time.now
|
51
56
|
```
|
52
57
|
|
53
58
|
|
@@ -61,19 +66,20 @@ include Unidom::Inventory::AsInventoryItem
|
|
61
66
|
### As Inventory Item concern
|
62
67
|
|
63
68
|
The As Inventory Item concern do the following tasks for the includer automatically:
|
64
|
-
1. Define the belongs_to :stored macro as: ``belongs_to :stored, polymorphic: true``
|
65
|
-
2. Define the belongs_to :store macro as: ``belongs_to :store, polymorphic: true``
|
66
|
-
3. Define the belongs_to :lot macro as: ``belongs_to :lot, class_name: 'Unidom::Inventory::Lot'``
|
69
|
+
1. Define the belongs_to :stored macro as: ``belongs_to :stored, polymorphic: true``
|
70
|
+
2. Define the belongs_to :store macro as: ``belongs_to :store, polymorphic: true``
|
71
|
+
3. Define the belongs_to :lot macro as: ``belongs_to :lot, class_name: 'Unidom::Inventory::Lot'``
|
67
72
|
4. Define the has_many :pick_items macro as: ``has_many :pick_items, class_name: 'Unidom::Inventory::PickItem', as: :inventory_item``
|
73
|
+
5. Define the has_many :variances macro as: ``has_many :variances, class_name: 'Unidom::Inventory::InventoryItemVariance', as: :inventory_item``
|
68
74
|
|
69
75
|
### As Store concern
|
70
76
|
|
71
77
|
The As Store concern do the following tasks for the includer automatically:
|
72
|
-
1. Define the has_many :grouped_inventory_items macro as: ``has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :store_id``
|
78
|
+
1. Define the has_many :grouped_inventory_items macro as: ``has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :store_id``
|
73
79
|
2. Define the has_many :serialized_inventory_items macro as: ``has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem', foreign_key: :store_id``
|
74
80
|
|
75
81
|
### As Stored concern
|
76
82
|
|
77
83
|
The As Stored concern do the following tasks for the includer automatically:
|
78
|
-
1. Define the has_many :grouped_inventory_items macro as: ``has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :stored_id``
|
84
|
+
1. Define the has_many :grouped_inventory_items macro as: ``has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :stored_id``
|
79
85
|
2. Define the has_many :serialized_inventory_items macro as: ``has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem', foreign_key: :stored_id``
|
@@ -8,7 +8,8 @@ module Unidom::Inventory::Concerns::AsInventoryItem
|
|
8
8
|
belongs_to :store, polymorphic: true
|
9
9
|
belongs_to :lot, class_name: 'Unidom::Inventory::Lot'
|
10
10
|
|
11
|
-
has_many :pick_items, class_name: 'Unidom::Inventory::PickItem',
|
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
|
12
13
|
|
13
14
|
end
|
14
15
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Inventory Item Variance 是库存项变化。
|
2
|
+
# #inventory_item 是被调整的库存项。
|
3
|
+
# #reason 是调整的原因。
|
4
|
+
# #quantity 是调整数量,正数表示库存增加,负数表示库存减少。
|
5
|
+
|
6
|
+
class Unidom::Inventory::InventoryItemVariance < ActiveRecord::Base
|
7
|
+
|
8
|
+
self.table_name = 'unidom_inventory_item_variances'
|
9
|
+
|
10
|
+
include Unidom::Common::Concerns::ModelExtension
|
11
|
+
|
12
|
+
validates :quantity, presence: true, numericality: true
|
13
|
+
|
14
|
+
belongs_to :inventory_item, polymorphic: true
|
15
|
+
belongs_to :reason, polymorphic: true
|
16
|
+
|
17
|
+
scope :inventory_item_is, ->(inventory_item) { where inventory_item: inventory_item }
|
18
|
+
scope :caused_by, ->(reason) { where reason: reason }
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class CreateUnidomInventoryItemVariances < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :unidom_inventory_item_variances, id: :uuid do |t|
|
6
|
+
|
7
|
+
t.references :inventory_item, type: :uuid, null: false,
|
8
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
9
|
+
t.references :reason, type: :uuid, null: true,
|
10
|
+
polymorphic: { null: true, default: nil, limit: 200 }
|
11
|
+
|
12
|
+
t.decimal :quantity, null: false, default: 0.0, precision: 10, scale: 6
|
13
|
+
|
14
|
+
t.text :description
|
15
|
+
t.text :instruction
|
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)
|
20
|
+
t.boolean :defunct, null: false, default: false
|
21
|
+
t.jsonb :notation, null: false, default: {}
|
22
|
+
|
23
|
+
t.timestamps null: false
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
add_index :unidom_inventory_item_variances, :inventory_item_id
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
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: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- app/models/unidom/inventory/concerns/as_store.rb
|
45
45
|
- app/models/unidom/inventory/concerns/as_stored.rb
|
46
46
|
- app/models/unidom/inventory/grouped_inventory_item.rb
|
47
|
+
- app/models/unidom/inventory/inventory_item_variance.rb
|
47
48
|
- app/models/unidom/inventory/item_issuing.rb
|
48
49
|
- app/models/unidom/inventory/lot.rb
|
49
50
|
- app/models/unidom/inventory/pick_item.rb
|
@@ -53,6 +54,7 @@ files:
|
|
53
54
|
- config/routes.rb
|
54
55
|
- db/migrate/20020901000000_create_unidom_serialized_inventory_items.rb
|
55
56
|
- db/migrate/20020902000000_create_unidom_grouped_inventory_items.rb
|
57
|
+
- db/migrate/20020903000000_create_unidom_inventory_item_variances.rb
|
56
58
|
- db/migrate/20020911000000_create_unidom_lots.rb
|
57
59
|
- db/migrate/20020921000000_create_unidom_pick_lists.rb
|
58
60
|
- db/migrate/20020922000000_create_unidom_pick_items.rb
|