unidom-inventory 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb92d2f9e70d5f4cd23dda116402fea9179dcc78
4
- data.tar.gz: d0914e4acd8fa703c36f9e8b7bd9a6d1f3891bd1
3
+ metadata.gz: 3def5f3156c518aea115d97b00a070fe8d1f67d4
4
+ data.tar.gz: 8530497bac887d9e94f1f80a3055fa454077cf4b
5
5
  SHA512:
6
- metadata.gz: f4b31cb3d59e140a72a8bd539ec0c159c602db46169914cbb837ad181907c4e01354f73e9679d74a737cd7a266ce94086a48c2cac850d0cd9c764b0a9222a331
7
- data.tar.gz: b467454a0b92364431e71f90f4fce6ae58fe8b67b4ebd092c6f364e830934c9a6896178ee8d8cc78c62a469d0a3763c4541ed6120128329acf6e5260fe0efe98
6
+ metadata.gz: 1eea9bb7dc43e33bfa6f2758a537727ba799781fe088ce75029050eb3b6fd17fc172f80d5a12b80e81484bae5bdc9547d9ac81a17bd3ac027b99e3f49de4db57
7
+ data.tar.gz: 9b0522a0c0c2294297654e6d6f582734ac1f300dd38b93c6530d3a4aa28b13669604787634ffadd390ddafbc3c913a26268fd37563e4a931dc7756e70d57a4fa
data/README.md CHANGED
@@ -67,22 +67,48 @@ include Unidom::Inventory::Concerns::AsStored
67
67
 
68
68
  ### As Inventory Item concern
69
69
 
70
- The As Inventory Item concern do the following tasks for the includer automatically:
71
- 1. Define the belongs_to :stored macro as: ``belongs_to :stored, polymorphic: true``
72
- 2. Define the belongs_to :store macro as: ``belongs_to :store, polymorphic: true``
73
- 3. Define the belongs_to :lot macro as: ``belongs_to :lot, class_name: 'Unidom::Inventory::Lot'``
74
- 4. Define the has_many :pick_items macro as: ``has_many :pick_items, class_name: 'Unidom::Inventory::PickItem', as: :inventory_item``
75
- 5. Define the has_many :variances macro as: ``has_many :variances, class_name: 'Unidom::Inventory::InventoryItemVariance', as: :inventory_item``
70
+ The As Inventory Item concern do the following tasks for the includer automatically:
71
+
72
+ 1. Define the belongs_to :stored macro as: ``belongs_to :stored, polymorphic: true``
73
+
74
+ 2. Define the belongs_to :store macro as: ``belongs_to :store, polymorphic: true``
75
+
76
+ 3. Define the belongs_to :lot macro as: ``belongs_to :lot, class_name: 'Unidom::Inventory::Lot'``
77
+
78
+ 4. Define the has_many :pick_items macro as: ``has_many :pick_items, class_name: 'Unidom::Inventory::PickItem', as: :inventory_item``
79
+
80
+ 5. Define the has_many :variances macro as: ``has_many :variances, class_name: 'Unidom::Inventory::InventoryItemVariance', as: :inventory_item``
81
+
76
82
  6. Define the #is_adjusted! method as: ``is_adjusted!(quantity, due_to: nil, at: Time.now, description: nil, instruction: nil)``
77
83
 
78
84
  ### As Store concern
79
85
 
80
- The As Store concern do the following tasks for the includer automatically:
81
- 1. Define the has_many :grouped_inventory_items macro as: ``has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :store_id``
86
+ The As Store concern do the following tasks for the includer automatically:
87
+
88
+ 1. Define the has_many :grouped_inventory_items macro as: ``has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :store_id``
89
+
82
90
  2. Define the has_many :serialized_inventory_items macro as: ``has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem', foreign_key: :store_id``
83
91
 
84
92
  ### As Stored concern
85
93
 
86
- The As Stored concern do the following tasks for the includer automatically:
87
- 1. Define the has_many :grouped_inventory_items macro as: ``has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :stored_id``
94
+ The As Stored concern do the following tasks for the includer automatically:
95
+
96
+ 1. Define the has_many :grouped_inventory_items macro as: ``has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem', foreign_key: :stored_id``
97
+
88
98
  2. Define the has_many :serialized_inventory_items macro as: ``has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem', foreign_key: :stored_id``
99
+
100
+
101
+
102
+ ## Disable the Model & Migration
103
+
104
+ If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
105
+ ```ruby
106
+ # config/initializers/unidom.rb
107
+ Unidom::Common.configure do |options|
108
+
109
+ options[:neglected_namespaces] = %w{
110
+ Unidom::Inventory
111
+ }
112
+
113
+ end
114
+ ```
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
3
+
1
4
  class Unidom::Inventory::ApplicationController < ActionController::Base
2
5
  protect_from_forgery with: :exception
3
6
  end
@@ -1,2 +1,5 @@
1
+ ##
2
+ # Application job 是模块内所有异步任务的基类。
3
+
1
4
  class Unidom::Inventory::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Inventory::ApplicationMailer < ActionMailer::Base
2
5
  default from: 'from@example.com'
3
6
  layout 'mailer'
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application record 是模块内所有模型的抽象基类。
3
+
1
4
  class Unidom::Inventory::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -10,4 +10,4 @@ class Unidom::Inventory::GroupedInventoryItem < Unidom::Inventory::ApplicationRe
10
10
 
11
11
  validates :quantity, presence: true, numericality: true
12
12
 
13
- end
13
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::GroupedInventoryItem'
@@ -18,6 +18,10 @@ class Unidom::Inventory::InventoryItemVariance < Unidom::Inventory::ApplicationR
18
18
  scope :inventory_item_is, ->(inventory_item) { where inventory_item: inventory_item }
19
19
  scope :caused_by, ->(reason) { where reason: reason }
20
20
 
21
+ ##
22
+ # 对库存项 inventory_item 进行调整。调整数量为 quantity ,缺省为 nil 。调整原因为 due_to 。调整时间为 at ,缺省为当前时间。
23
+ # 另有适用于己方的备注信息 description 和适用于对方的备注信息 instruction 。
24
+ # Unidom::Inventory::InventoryItemVariance.adjust! inventory_item, quantity: 3
21
25
  def self.adjust!(inventory_item, quantity: nil, due_to: nil, at: Time.now, description: nil, instruction: nil)
22
26
  if inventory_item.respond_to? :quantity
23
27
  inventory_item.increment! :quantity, quantity
@@ -32,4 +36,4 @@ class Unidom::Inventory::InventoryItemVariance < Unidom::Inventory::ApplicationR
32
36
  create! inventory_item: inventory_item, reason: due_to, quantity: quantity, description: description, instruction: instruction, opened_at: at
33
37
  end
34
38
 
35
- end
39
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::InventoryItemVariance'
@@ -16,4 +16,4 @@ class Unidom::Inventory::ItemIssuing < Unidom::Inventory::ApplicationRecord
16
16
  belongs_to :inventory_item, polymorphic: true
17
17
  belongs_to :target_item, polymorphic: true
18
18
 
19
- end
19
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::ItemIssuing'
@@ -13,4 +13,4 @@ class Unidom::Inventory::Lot < Unidom::Inventory::ApplicationRecord
13
13
  has_many :grouped_inventory_items, class_name: 'Unidom::Inventory::GroupedInventoryItem'
14
14
  has_many :serialized_inventory_items, class_name: 'Unidom::Inventory::SerializedInventoryItem'
15
15
 
16
- end
16
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::Lot'
@@ -12,4 +12,4 @@ class Unidom::Inventory::PickItem < Unidom::Inventory::ApplicationRecord
12
12
  belongs_to :pick_list, class_name: 'Unidom::Inventory::PickList'
13
13
  belongs_to :inventory_item, polymorphic: true
14
14
 
15
- end
15
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::PickItem'
@@ -9,4 +9,4 @@ class Unidom::Inventory::PickList < Unidom::Inventory::ApplicationRecord
9
9
 
10
10
  has_many :items, class_name: 'Unidom::Inventory::PickItem' #, foreign_key: :pick_list_id
11
11
 
12
- end
12
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::PickList'
@@ -10,4 +10,4 @@ class Unidom::Inventory::SerializedInventoryItem < Unidom::Inventory::Applicatio
10
10
 
11
11
  validates :serial_number, presence: true, length: { in: 2..columns_hash['serial_number'].limit }
12
12
 
13
- end
13
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Inventory::SerializedInventoryItem'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Inventory
3
- VERSION = '0.7.4'.freeze
3
+ VERSION = '0.7.5'.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.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-25 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.8'
19
+ version: '1.9'
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.8'
26
+ version: '1.9'
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 (统一领域对象模型)是一系列的领域模型引擎。库存领域模型引擎包括序列化库存项、分组库存项、批量和库存项变化的模型。