erp_inventory 4.0.0 → 4.2.0

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: 1638c2774d64dc7ed63045210a81eb744a6ae1ae
4
- data.tar.gz: a5322287991cb59a81325728dfb91705639e733c
3
+ metadata.gz: c6c26466e517aa3286ea97a123572507345bde28
4
+ data.tar.gz: 7621d6a8fcd6306fc86e8248a165c13e64c726d5
5
5
  SHA512:
6
- metadata.gz: 26d4ccfe361cf001c191a730ebe7a808d7f5c95bde625562e237e3e6ef67e64bed9ef7bd57efec034dde6e3bea2c7944d84048063e0cd303be14eaf65e5d38b3
7
- data.tar.gz: b7225b9252a044cb0ff127407b727e9f35592717dfc5afbceb5ddb9c3bdb12c630ff840b3c6902972ce9149488b4b22325921279aca4c99d272dd30eb121c7c7
6
+ metadata.gz: 78e634ffac7fd14325cef9c0901fb2ea4ac706f53c55fcfafc345d2c4f4b2c7644a126c5762e737663da8d049ba8530e1ea34c7c5b26c239f8abeb69d023314b
7
+ data.tar.gz: 12533987b22a989661c9fa522aa9543ac69b2260586ba7bc75d724bce45600c58450b99a2e68a80b9d1d85bf7870a05e3d42e481f93635747efc1ab1d8742fbb
@@ -75,6 +75,9 @@ module ErpInventory
75
75
  rescue => ex
76
76
  Rails.logger.error ex.message
77
77
  Rails.logger.error ex.backtrace.join("\n")
78
+
79
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
80
+
78
81
  render :json => {:success => false, :message => ex.message}
79
82
  end
80
83
  end
@@ -6,18 +6,13 @@ class Facility < ActiveRecord::Base
6
6
  belongs_to :postal_address
7
7
 
8
8
  def to_data_hash
9
- {
10
- :id => self.id,
11
- :description => self.description,
12
- :postal_address_id => self.postal_address_id,
13
- :address_line_1 => (self.postal_address.address_line_1 rescue nil),
14
- :address_line_2 => (self.postal_address.address_line_2 rescue nil),
15
- :city => (self.postal_address.city rescue nil),
16
- :state => (self.postal_address.state rescue nil),
17
- :zip => (self.postal_address.zip rescue nil),
18
- :created_at => self.created_at,
19
- :updated_at => self.updated_at,
20
- }
9
+ to_hash(only: [
10
+ :id,
11
+ :description,
12
+ :created_at,
13
+ :updated_at
14
+ ],
15
+ postal_address: try(:postal_address).try(:to_data_hash))
21
16
  end
22
17
 
23
18
  end
@@ -1,11 +1,11 @@
1
1
  class InventoryEntry < ActiveRecord::Base
2
2
  attr_protected :created_at, :updated_at
3
3
 
4
- belongs_to :inventory_entry_record, :polymorphic => true
5
- belongs_to :product_type
6
- has_one :classification, :as => :classification, :class_name => 'CategoryClassification'
7
- has_many :prod_instance_inv_entries
8
- has_many :product_instances, :through => :prod_instance_inv_entries do
4
+ belongs_to :inventory_entry_record, :polymorphic => true
5
+ belongs_to :product_type
6
+ has_one :classification, :as => :classification, :class_name => 'CategoryClassification'
7
+ has_many :prod_instance_inv_entries
8
+ has_many :product_instances, :through => :prod_instance_inv_entries do
9
9
  def available
10
10
  includes([:prod_availability_status_type]).where('prod_availability_status_types.internal_identifier = ?', 'available')
11
11
  end
@@ -16,7 +16,7 @@ class InventoryEntry < ActiveRecord::Base
16
16
  end
17
17
  has_many :inventory_entry_locations
18
18
  has_many :facilities, :through => :inventory_entry_locations
19
- belongs_to :unit_of_measurement
19
+ belongs_to :unit_of_measurement
20
20
 
21
21
  alias_method :storage_facilities, :facilities
22
22
 
@@ -45,21 +45,30 @@ class InventoryEntry < ActiveRecord::Base
45
45
  end
46
46
 
47
47
  def to_data_hash
48
- {
49
- :id => self.id,
50
- :description => self.description,
51
- :number_available => self.number_available,
52
- :number_in_stock => self.number_in_stock,
53
- :sku => self.get_sku,
54
- :unit_of_measurement_id => (self.get_uom.id rescue nil),
55
- :unit_of_measurement_description => (self.get_uom.description rescue nil),
56
- :inventory_storage_facility_id => (self.current_storage_facility.id rescue nil),
57
- :inventory_storage_facility_description => (self.current_storage_facility.description rescue nil),
58
- :created_at => self.created_at,
59
- :updated_at => self.updated_at,
60
- :product_type_id =>self.product_type_id,
61
- :product_type_description => (self.product_type_description rescue nil)
62
- }
48
+ data = to_hash(only: [
49
+ :id,
50
+ :description,
51
+ :number_available,
52
+ :number_in_stock,
53
+ :created_at,
54
+ :updated_at
55
+ ],
56
+ sku: get_sku,
57
+ product_type: try(:product_type).try(:to_data_hash))
58
+
59
+ if get_uom
60
+ data[:unit_of_measurement] = get_uom.to_data_hash
61
+ else
62
+ data[:unit_of_measurement] = nil
63
+ end
64
+
65
+ if current_storage_facility
66
+ data[:inventory_storage_facility] = current_storage_facility.to_data_hash
67
+ else
68
+ data[:inventory_storage_facility] = nil
69
+ end
70
+
71
+ data
63
72
  end
64
73
 
65
74
  def to_label
@@ -67,7 +76,7 @@ class InventoryEntry < ActiveRecord::Base
67
76
  end
68
77
 
69
78
  def get_sku
70
- if self.sku.blank?
79
+ if self.sku.blank? and self.product_type
71
80
  self.product_type_sku
72
81
  else
73
82
  self.sku
@@ -75,7 +84,7 @@ class InventoryEntry < ActiveRecord::Base
75
84
  end
76
85
 
77
86
  def get_uom
78
- if self.unit_of_measurement.nil?
87
+ if self.unit_of_measurement.nil? and self.product_type
79
88
  self.product_type_unit_of_measurement
80
89
  else
81
90
  self.unit_of_measurement
@@ -1,90 +1,156 @@
1
1
  class BaseInventory < ActiveRecord::Migration
2
2
  def self.up
3
-
3
+
4
4
  unless table_exists?(:inventory_entries)
5
5
  create_table :inventory_entries do |t|
6
- t.column :description, :string
7
- t.column :inventory_entry_record_id, :integer
8
- t.column :inventory_entry_record_type, :string
9
- t.column :external_identifier, :string
10
- t.column :external_id_source, :string
11
- t.column :product_type_id, :integer
12
- t.column :number_available, :integer
13
- t.string :sku
14
- t.integer :number_sold
15
-
6
+ t.column :description, :string
7
+ t.column :inventory_entry_record_id, :integer
8
+ t.column :inventory_entry_record_type, :string
9
+ t.column :external_identifier, :string
10
+ t.column :external_id_source, :string
11
+ t.column :product_type_id, :integer
12
+ t.column :number_available, :integer
13
+ t.string :sku
14
+ t.integer :number_sold
15
+ t.references :unit_of_measurement
16
+ t.integer :number_in_stock
17
+
16
18
  t.timestamps
17
19
  end
20
+
21
+ add_index :inventory_entries, :unit_of_measurement_id, :name => 'inv_entry_uom_idx'
22
+ add_index :inventory_entries, [:inventory_entry_record_id, :inventory_entry_record_type], :name => "bii_1"
23
+ add_index :inventory_entries, :product_type_id
18
24
  end
19
-
25
+
20
26
  unless table_exists?(:inv_entry_reln_types)
21
27
  create_table :inv_entry_reln_types do |t|
22
- t.column :parent_id, :integer
23
- t.column :lft, :integer
24
- t.column :rgt, :integer
25
- #custom columns go here
26
- t.column :description, :string
27
- t.column :comments, :string
28
- t.column :internal_identifier, :string
29
- t.column :external_identifier, :string
30
- t.column :external_id_source, :string
31
-
28
+ t.column :parent_id, :integer
29
+ t.column :lft, :integer
30
+ t.column :rgt, :integer
31
+ #custom columns go here
32
+ t.column :description, :string
33
+ t.column :comments, :string
34
+ t.column :internal_identifier, :string
35
+ t.column :external_identifier, :string
36
+ t.column :external_id_source, :string
37
+
32
38
  t.timestamps
33
39
  end
40
+
41
+ add_index :inv_entry_reln_types, :parent_id
34
42
  end
35
-
43
+
36
44
  unless table_exists?(:inv_entry_role_types)
37
45
  create_table :inv_entry_role_types do |t|
38
- t.column :parent_id, :integer
39
- t.column :lft, :integer
40
- t.column :rgt, :integer
41
- #custom columns go here
42
- t.column :description, :string
43
- t.column :comments, :string
44
- t.column :internal_identifier, :string
45
- t.column :external_identifier, :string
46
- t.column :external_id_source, :string
47
-
46
+ t.column :parent_id, :integer
47
+ t.column :lft, :integer
48
+ t.column :rgt, :integer
49
+ #custom columns go here
50
+ t.column :description, :string
51
+ t.column :comments, :string
52
+ t.column :internal_identifier, :string
53
+ t.column :external_identifier, :string
54
+ t.column :external_id_source, :string
55
+
48
56
  t.timestamps
49
57
  end
58
+
59
+ add_index :inv_entry_role_types, :parent_id
50
60
  end
51
-
61
+
52
62
  unless table_exists?(:inv_entry_relns)
53
63
  create_table :inv_entry_relns do |t|
54
- t.column :inv_entry_reln_type_id, :integer
55
- t.column :description, :string
56
- t.column :inv_entry_id_from, :integer
57
- t.column :inv_entry_id_to, :integer
58
- t.column :role_type_id_from, :integer
59
- t.column :role_type_id_to, :integer
60
- t.column :status_type_id, :integer
61
- t.column :from_date, :date
62
- t.column :thru_date, :date
63
-
64
+ t.column :inv_entry_reln_type_id, :integer
65
+ t.column :description, :string
66
+ t.column :inv_entry_id_from, :integer
67
+ t.column :inv_entry_id_to, :integer
68
+ t.column :role_type_id_from, :integer
69
+ t.column :role_type_id_to, :integer
70
+ t.column :status_type_id, :integer
71
+ t.column :from_date, :date
72
+ t.column :thru_date, :date
73
+
64
74
  t.timestamps
65
75
  end
76
+
77
+ add_index :inv_entry_relns, :inv_entry_reln_type_id
78
+ add_index :inv_entry_relns, :status_type_id
66
79
  end
67
-
80
+
68
81
  unless table_exists?(:prod_instance_inv_entries)
69
82
  create_table :prod_instance_inv_entries do |t|
70
- t.column :product_instance_id, :integer
71
- t.column :inventory_entry_id, :integer
72
-
83
+ t.column :product_instance_id, :integer
84
+ t.column :inventory_entry_id, :integer
85
+
73
86
  t.timestamps
74
87
  end
88
+
89
+ add_index :prod_instance_inv_entries, :product_instance_id
90
+ add_index :prod_instance_inv_entries, :inventory_entry_id
75
91
  end
76
92
 
93
+ unless table_exists?(:inventory_entry_locations)
94
+ create_table :inventory_entry_locations do |t|
95
+
96
+ t.references :inventory_entry
97
+ t.references :facility
98
+ t.datetime :valid_from
99
+ t.datetime :valid_thru
100
+
101
+ t.timestamps
102
+ end
103
+
104
+ add_index :inventory_entry_locations, :inventory_entry_id, :name => "inv_entry_loc_inv_entry_idx"
105
+ add_index :inventory_entry_locations, :facility_id, :name => "inv_entry_loc_facility_idx"
106
+ end
107
+
108
+ unless table_exists?(:inventory_pickup_txns)
109
+ create_table :inventory_pickup_txns do |t|
110
+
111
+ t.references :fixed_asset
112
+ t.string :description
113
+ t.integer :quantity
114
+ t.integer :unit_of_measurement_id
115
+ t.text :comment
116
+ t.references :inventory_entry
117
+
118
+ t.timestamps
119
+ end
120
+
121
+ add_index :inventory_pickup_txns, :fixed_asset_id
122
+ add_index :inventory_pickup_txns, :inventory_entry_id
123
+ end
124
+
125
+ unless table_exists?(:inventory_dropoff_txns)
126
+ create_table :inventory_dropoff_txns do |t|
127
+
128
+ t.references :fixed_asset
129
+ t.string :description
130
+ t.integer :quantity
131
+ t.integer :unit_of_measurement_id
132
+ t.text :comment
133
+ t.references :inventory_entry
134
+
135
+ t.timestamps
136
+
137
+ end
138
+
139
+ add_index :inventory_dropoff_txns, :fixed_asset_id
140
+ add_index :inventory_dropoff_txns, :inventory_entry_id
141
+ end
77
142
  end
78
143
 
79
144
  def self.down
80
145
  [
81
- :prod_instance_inv_entries,:inv_entry_relns,
82
- :inv_entry_role_types, :inv_entry_reln_types, :inventory_entries
146
+ :prod_instance_inv_entries,:inv_entry_relns,
147
+ :inv_entry_role_types, :inv_entry_reln_types,
148
+ :inventory_entries, :inventory_entry_locations
83
149
  ].each do |tbl|
84
150
  if table_exists?(tbl)
85
151
  drop_table tbl
86
152
  end
87
153
  end
88
154
  end
89
-
155
+
90
156
  end
@@ -2,10 +2,6 @@ module ErpInventory
2
2
  class Engine < Rails::Engine
3
3
  isolate_namespace ErpInventory
4
4
 
5
- initializer "erp_inventory.merge_public" do |app|
6
- app.middleware.insert_before Rack::Runtime, ::ActionDispatch::Static, "#{root}/public"
7
- end
8
-
9
5
  ActiveSupport.on_load(:active_record) do
10
6
  include ErpInventory::Extensions::ActiveRecord::ActsAsInventoryEntry
11
7
  end
@@ -1,7 +1,7 @@
1
1
  module ErpInventory
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 4
4
- MINOR = 0
4
+ MINOR = 2
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erp_inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Koloski, Russell Holmes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erp_orders
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.2'
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: '4.0'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: erp_dev_svcs
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '4.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '4.2'
41
41
  description: The Inventory Engine in CompassAE implements a set of models for storing
42
42
  information about the availability and location of ProductTypes and optionally Product
43
43
  Instances. It is also the root for yield and revenue management requirements to
@@ -73,14 +73,6 @@ files:
73
73
  - config/routes.rb
74
74
  - db/data_migrations/20131206033154_create_inv_txn_types.rb
75
75
  - db/migrate/20080805000050_base_inventory.rb
76
- - db/migrate/20080805000051_base_inventory_indexes.rb
77
- - db/migrate/20130925202059_create_inventory_entry_locations.rb
78
- - db/migrate/20130925222100_create_inventory_pickup_txns.rb
79
- - db/migrate/20130925222150_create_inventory_dropoff_txns.rb
80
- - db/migrate/20131206035027_add_inv_entry_to_inventory_txns.rb
81
- - db/migrate/20131211170059_change_fixed_asset_to_facility_for_inventory_locations.rb
82
- - db/migrate/20140103183635_add_uom_to_inventory_entry.rb
83
- - db/migrate/20140104182403_add_number_in_stock_inventory.rb
84
76
  - lib/erp_inventory.rb
85
77
  - lib/erp_inventory/engine.rb
86
78
  - lib/erp_inventory/extensions.rb
@@ -138,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
130
  version: '0'
139
131
  requirements: []
140
132
  rubyforge_project:
141
- rubygems_version: 2.2.2
133
+ rubygems_version: 2.4.8
142
134
  signing_key:
143
135
  specification_version: 4
144
136
  summary: The Inventory Engine in CompassAE implements a set of models for storing
@@ -1,47 +0,0 @@
1
- class BaseInventoryIndexes < ActiveRecord::Migration
2
- def self.up
3
- add_index :inventory_entries, [:inventory_entry_record_id, :inventory_entry_record_type],
4
- :name => "bii_1"
5
-
6
- add_index :inv_entry_reln_types, :parent_id
7
-
8
- add_index :inv_entry_role_types, :parent_id
9
-
10
- add_index :inv_entry_relns, :inv_entry_reln_type_id
11
- add_index :inv_entry_relns, :status_type_id
12
-
13
- add_index :prod_instance_inv_entries, :product_instance_id
14
- add_index :prod_instance_inv_entries, :inventory_entry_id
15
-
16
- ### Conditional checks: since these columns may have been added with a later migration,
17
- ### we check that the column exists before adding an index on it.
18
-
19
- if columns(:inventory_entries).include?('product_type_id')
20
- add_index :inventory_entries, :product_type_id
21
- end
22
- end
23
-
24
- def self.down
25
- remove_index :inventory_entries, :name => "bii_1"
26
-
27
- remove_index :inv_entry_reln_types, :parent_id
28
-
29
- remove_index :inv_entry_role_types, :parent_id
30
-
31
- remove_index :inv_entry_relns, :inv_entry_reln_type_id
32
- remove_index :inv_entry_relns, :status_type_id
33
-
34
- remove_index :prod_instance_inv_entries, :product_instance_id
35
- remove_index :prod_instance_inv_entries, :inventory_entry_id
36
-
37
- ### Conditional checks: since these columns were originally added in a later
38
- ### migration that may not yet have already been run,
39
- ### we check that the column exists before removing an index on it.
40
-
41
- if indexes(:inventory_entries).collect {|i|
42
- i.name}.include?('index_inventory_entries_on_product_type_id')
43
- remove_index :inventory_entries, :product_type_id
44
- end
45
-
46
- end
47
- end
@@ -1,13 +0,0 @@
1
- class CreateInventoryEntryLocations < ActiveRecord::Migration
2
- def change
3
- create_table :inventory_entry_locations do |t|
4
-
5
- t.references :inventory_entry
6
- t.references :fixed_asset
7
- t.datetime :valid_from
8
- t.datetime :valid_thru
9
-
10
- t.timestamps
11
- end
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- class CreateInventoryPickupTxns < ActiveRecord::Migration
2
- def change
3
- create_table :inventory_pickup_txns do |t|
4
-
5
- t.references :fixed_asset
6
- t.string :description
7
- t.integer :quantity
8
- t.integer :unit_of_measurement_id
9
- t.text :comment
10
-
11
- t.timestamps
12
- end
13
-
14
- add_index :inventory_pickup_txns, :fixed_asset_id
15
-
16
- end
17
- end
@@ -1,18 +0,0 @@
1
- class CreateInventoryDropoffTxns < ActiveRecord::Migration
2
- def change
3
- create_table :inventory_dropoff_txns do |t|
4
-
5
- t.references :fixed_asset
6
- t.string :description
7
- t.integer :quantity
8
- t.integer :unit_of_measurement_id
9
- t.text :comment
10
-
11
- t.timestamps
12
-
13
- end
14
-
15
- add_index :inventory_dropoff_txns, :fixed_asset_id
16
-
17
- end
18
- end
@@ -1,15 +0,0 @@
1
- class AddInvEntryToInventoryTxns < ActiveRecord::Migration
2
- def change
3
-
4
- #Where are we picking inventory up from
5
- add_column :inventory_pickup_txns, :inventory_entry_id, :integer
6
-
7
- #Where are we placing the inventory. Can be final destination or interim destination
8
- #For inventory movements
9
- add_column :inventory_dropoff_txns, :inventory_entry_id, :integer
10
-
11
- add_index :inventory_pickup_txns, :inventory_entry_id
12
- add_index :inventory_dropoff_txns, :inventory_entry_id
13
-
14
- end
15
- end
@@ -1,8 +0,0 @@
1
- class ChangeFixedAssetToFacilityForInventoryLocations < ActiveRecord::Migration
2
-
3
- def change
4
- remove_column :inventory_entry_locations, :fixed_asset_id
5
- add_column :inventory_entry_locations, :facility_id, :integer
6
- end
7
-
8
- end
@@ -1,5 +0,0 @@
1
- class AddUomToInventoryEntry < ActiveRecord::Migration
2
- def change
3
- add_column :inventory_entries, :unit_of_measurement_id, :integer
4
- end
5
- end
@@ -1,9 +0,0 @@
1
- class AddNumberInStockInventory < ActiveRecord::Migration
2
- def up
3
- add_column :inventory_entries, :number_in_stock, :integer
4
- end
5
-
6
- def down
7
- remove_column :inventory_entries, :number_in_stock
8
- end
9
- end