unidom-inventory 0.3 → 0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a3df694f60873ba0b90f9888dc028dd96728d1b
4
- data.tar.gz: 62747b549a23466fe83ba677a298499508d2aeaf
3
+ metadata.gz: 12619e1472bdf219dca48771bb4d211ea9386d2b
4
+ data.tar.gz: 68a778acdbfa624d1e16d14b530318b0ca3988bf
5
5
  SHA512:
6
- metadata.gz: c59fced69360cf4d7f96fbb19aac165f73a06aad97a10eeadb43f49a122ba0874ce30dfbc1c995d6d52b479d726d5e883173fdeef2e5987b14206cf7eb85fae4
7
- data.tar.gz: 933d5fbca5f946d5774efa31f8f1005e95e55acc84cf663eddd226e07eb1bf9bbaf9b1331461502aa6a2ef835fce5d263dc2d11160fe8940fc7a63948fa366b9
6
+ metadata.gz: 5292a0127f1c169d009b7abd74b29ce118df76a1f24111648b5387f738e8b14e47123a1a4541e9e2f75619190471260a9c58fd2159d7108c185785b5b4f84ef2
7
+ data.tar.gz: 9f7b435e07318c2c14c89481f1a4ee5fe3d1237cd849f914e5bec9a13766a86e27be75392212ee96994cfb3d0559e5516bdf2a40858883155d17d4aa22f86ff6
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
4
4
  [![Gem Version](https://badge.fury.io/rb/unidom-inventory.svg)](https://badge.fury.io/rb/unidom-inventory)
5
+ [![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-inventory.svg)](https://gemnasium.com/github.com/topbitdu/unidom-inventory)
5
6
 
6
7
  Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Inventory domain model engine includes the Serialized Inventory Item, the Grouped Inventory Item, the Lot, and the Inventory Item Variance models.
7
8
  Unidom (统一领域对象模型)是一系列的领域模型引擎。库存领域模型引擎包括序列化库存项、分组库存项、批量和库存项变化的模型。
@@ -31,8 +32,14 @@ The migration versions start with 200209.
31
32
 
32
33
  ## Call the Model
33
34
  ```ruby
34
- Unidom::Inventory::SerializedInventoryItem.valid_at.alive.first
35
- Unidom::Inventory::GroupedInventoryItem.valid_at.alive.first
35
+ lot = Unidom::Inventory::Lot.create! identification_number: '20040312', description: '1 more thing', instruction: 'Please note...'
36
+
37
+ serialized_inventory_item = Unidom::Inventory::SerializedInventoryItem.create! store: shop, stored: product, lot: lot, serial_number: '19840101'
38
+ grouped_inventory_item = Unidom::Inventory::GroupedInventoryItem.create! store: shop, stored: product, lot: lot, quantity: 100
39
+ # The lot is optional for the serialized inventory item or the grouped inventory item.
40
+
41
+ lot.grouped_inventory_items.create! store: @shop, stored: @product, quantity: 100
42
+ lot.serialized_inventory_items.create! store: @shop, stored: @product, serial_number: '19840101'
36
43
  ```
37
44
 
38
45
 
@@ -6,6 +6,7 @@ module Unidom::Inventory::Concerns::AsInventoryItem
6
6
 
7
7
  belongs_to :stored, polymorphic: true
8
8
  belongs_to :store, polymorphic: true
9
+ belongs_to :lot, class_name: 'Unidom::Inventory::Lot'
9
10
 
10
11
  end
11
12
 
@@ -0,0 +1,16 @@
1
+ # Lot 是批量。
2
+
3
+ class Unidom::Inventory::Lot < ActiveRecord::Base
4
+
5
+ self.table_name = 'unidom_lots'
6
+
7
+ include Unidom::Common::Concerns::ModelExtension
8
+ include Unidom::Inventory::Concerns::AsInventoryItem
9
+
10
+ validates :quantity, presence: true, numericality: true
11
+ validates :identification_number, presence: true, length: { in: 2..columns_hash['identification_number'].limit }
12
+
13
+ has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem'
14
+ has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem'
15
+
16
+ end
@@ -8,6 +8,7 @@ class CreateUnidomSerializedInventoryItems < ActiveRecord::Migration
8
8
  polymorphic: { null: false, default: '', limit: 200 }
9
9
  t.references :store, type: :uuid, null: false,
10
10
  polymorphic: { null: false, default: '', limit: 200 }
11
+ t.references :lot, type: :uuid, null: true
11
12
 
12
13
  t.string :serial_number, null: false, default: nil, limit: 200
13
14
 
@@ -23,6 +24,7 @@ class CreateUnidomSerializedInventoryItems < ActiveRecord::Migration
23
24
 
24
25
  add_index :unidom_serialized_inventory_items, :stored_id
25
26
  add_index :unidom_serialized_inventory_items, :store_id
27
+ add_index :unidom_serialized_inventory_items, :lot_id
26
28
  add_index :unidom_serialized_inventory_items, :serial_number
27
29
 
28
30
  end
@@ -8,6 +8,7 @@ class CreateUnidomGroupedInventoryItems < ActiveRecord::Migration
8
8
  polymorphic: { null: false, default: '', limit: 200 }
9
9
  t.references :store, type: :uuid, null: false,
10
10
  polymorphic: { null: false, default: '', limit: 200 }
11
+ t.references :lot, type: :uuid, null: true
11
12
 
12
13
  t.decimal :quantity, null: false, default: 0.0, precision: 10, scale: 6
13
14
 
@@ -23,6 +24,7 @@ class CreateUnidomGroupedInventoryItems < ActiveRecord::Migration
23
24
 
24
25
  add_index :unidom_grouped_inventory_items, :stored_id
25
26
  add_index :unidom_grouped_inventory_items, :store_id
27
+ add_index :unidom_grouped_inventory_items, :lot_id
26
28
 
27
29
  end
28
30
 
@@ -0,0 +1,27 @@
1
+ class CreateUnidomLots < ActiveRecord::Migration
2
+
3
+ def change
4
+
5
+ create_table :unidom_lots, id: :uuid do |t|
6
+
7
+ t.string :identification_number, null: false, default: '', limit: 200
8
+ t.decimal :quantity, null: false, default: 0.0, precision: 10, scale: 6
9
+
10
+ t.text :description
11
+ t.text :instruction
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)
16
+ t.boolean :defunct, null: false, default: false
17
+ t.jsonb :notation, null: false, default: {}
18
+
19
+ t.timestamps null: false
20
+
21
+ end
22
+
23
+ add_index :unidom_lots, :identification_number
24
+
25
+ end
26
+
27
+ end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Inventory
3
- VERSION = '0.3'.freeze
3
+ VERSION = '0.4'.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: '0.3'
4
+ version: '0.4'
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-09-29 00:00:00.000000000 Z
11
+ date: 2016-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -44,11 +44,13 @@ 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/lot.rb
47
48
  - app/models/unidom/inventory/serialized_inventory_item.rb
48
49
  - app/views/layouts/unidom/inventory/application.html.erb
49
50
  - config/routes.rb
50
51
  - db/migrate/20020901000000_create_unidom_serialized_inventory_items.rb
51
52
  - db/migrate/20020902000000_create_unidom_grouped_inventory_items.rb
53
+ - db/migrate/20020911000000_create_unidom_lots.rb
52
54
  - lib/tasks/inventory_tasks.rake
53
55
  - lib/unidom/inventory.rb
54
56
  - lib/unidom/inventory/engine.rb