erp_products 4.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v1/product_types_controller.rb +140 -0
  3. data/app/controllers/erp_products/shared/product_features_controller.rb +46 -0
  4. data/app/models/extensions/biz_txn_acct_root.rb +5 -0
  5. data/app/models/product_feature.rb +117 -0
  6. data/app/models/product_feature_applicability.rb +17 -0
  7. data/app/models/product_feature_interaction.rb +21 -0
  8. data/app/models/product_feature_interaction_type.rb +17 -0
  9. data/app/models/product_feature_type.rb +70 -0
  10. data/app/models/product_feature_type_product_feature_value.rb +16 -0
  11. data/app/models/product_feature_value.rb +42 -0
  12. data/app/models/product_instance.rb +4 -0
  13. data/app/models/product_offer.rb +25 -3
  14. data/app/models/product_type.rb +185 -21
  15. data/app/models/product_type_pty_role.rb +2 -0
  16. data/app/models/simple_product_offer.rb +3 -1
  17. data/config/routes.rb +15 -4
  18. data/db/data_migrations/20141222195727_add_product_type_view_types.rb +24 -0
  19. data/db/migrate/20080805000040_base_products.rb +284 -136
  20. data/db/migrate/20150304211841_add_shipping_cost_to_product_types.rb +7 -0
  21. data/db/migrate/20150507075057_add_dimensions_to_product_types.rb +12 -0
  22. data/db/migrate/20150622150625_add_taxable_to_product_types.rb +5 -0
  23. data/db/migrate/20150711194216_update_product_feature_interactions.rb +21 -0
  24. data/db/migrate/20151216235328_add_biz_txn_acct_root_to_products.rb +15 -0
  25. data/db/migrate/20160310163055_add_created_by_updated_by_to_erp_products.rb +43 -0
  26. data/lib/erp_products/engine.rb +0 -4
  27. data/lib/erp_products/extensions/active_record/acts_as_product_offer.rb +7 -4
  28. data/lib/erp_products/version.rb +1 -1
  29. metadata +24 -14
  30. data/app/controllers/erp_products/shared/product_types_controller.rb +0 -96
  31. data/app/views/erp_products/shared/product_types/show_details.html.erb +0 -8
  32. data/db/migrate/20080805000041_base_products_indexes.rb +0 -61
  33. data/db/migrate/20130131204335_add_product_instances_nested_set_indexes.rb +0 -9
  34. data/db/migrate/20130131204336_add_type_column_to_product_types.rb +0 -9
  35. data/db/migrate/20140124185720_add_product_party_roles.rb +0 -17
  36. data/db/migrate/20140130211433_add_sku_comment_uom_to_product_type.rb +0 -7
@@ -0,0 +1,7 @@
1
+ class AddShippingCostToProductTypes < ActiveRecord::Migration
2
+ def change
3
+ unless column_exists? :product_types, :shipping_cost
4
+ add_column :product_types, :shipping_cost, :decimal, :precision => 8, :scale => 2 unless column_exists?(:product_types, :shipping_cost)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ class AddDimensionsToProductTypes < ActiveRecord::Migration
2
+ def change
3
+ unless column_exists? :product_types, :length
4
+ add_column :product_types, :length, :decimal
5
+ add_column :product_types, :width, :decimal
6
+ add_column :product_types, :height, :decimal
7
+ add_column :product_types, :weight, :decimal
8
+ add_column :product_types, :cylindrical, :boolean
9
+ remove_column :product_types, :shipping_cost
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddTaxableToProductTypes < ActiveRecord::Migration
2
+ def change
3
+ add_column :product_types, :taxable, :boolean unless column_exists? :product_types, :taxable
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ class UpdateProductFeatureInteractions < ActiveRecord::Migration
2
+ def up
3
+ rename_column :product_feature_interactions, :product_feature_id, :product_feature_from_id unless column_exists? :product_feature_interactions, :product_feature_from_id
4
+ rename_column :product_feature_interactions, :interacted_product_feature_id, :product_feature_to_id unless column_exists? :product_feature_interactions, :product_feature_to_id
5
+
6
+ add_index :product_feature_values, :internal_identifier, :name => 'product_ft_vals_iid_idx' unless index_exists? :product_feature_values, name: 'product_ft_vals_iid_idx'
7
+ add_index :product_feature_interaction_types, :internal_identifier, name: 'product_ft_int_types_iid_idx' unless index_exists? :product_feature_interaction_types, name: 'product_ft_int_types_iid_idx'
8
+ add_index :product_feature_types, :internal_identifier, name: 'product_ft_types_iid_idx' unless index_exists? :product_feature_types, name: 'product_ft_types_iid_idx'
9
+ add_index :product_feature_types, [:rgt, :lft, :parent_id], name: 'product_ft_types_nested_set_idx' unless index_exists? :product_feature_types, 'product_ft_types_nested_set_idx'
10
+ end
11
+
12
+ def down
13
+ rename_column :product_feature_interactions, :product_feature_from_id, :product_feature_id if column_exists? :product_feature_interactions, :product_feature_from_id
14
+ rename_column :product_feature_interactions, :product_feature_to_id, :interacted_product_feature_id if column_exists? :product_feature_interactions, :product_feature_to_id
15
+
16
+ remove_index :product_feature_values, name: 'product_ft_vals_iid_idx' if index_exists? :product_feature_values, 'product_ft_vals_iid_idx'
17
+ remove_index :product_feature_interaction_types, name: 'product_ft_int_types_iid_idx' if index_exists? :product_feature_interaction_types, 'product_ft_int_types_iid_idx'
18
+ remove_index :product_feature_types, name: 'product_ft_types_iid_idx' if index_exists? :product_feature_types, 'product_ft_types_iid_idx'
19
+ remove_index :product_feature_types, name: 'product_ft_types_nested_set_idx' if index_exists? :product_feature_types, 'product_ft_types_nested_set_idx'
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ class AddBizTxnAcctRootToProducts < ActiveRecord::Migration
2
+ def up
3
+ unless column_exists? :product_types, :biz_txn_acct_root_id
4
+ add_column :product_types, :biz_txn_acct_root_id, :integer
5
+
6
+ add_index :product_types, :biz_txn_acct_root_id
7
+ end
8
+ end
9
+
10
+ def down
11
+ if column_exists? :product_types, :biz_txn_acct_root_id
12
+ remove_column :product_types, :biz_txn_acct_root_id
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ class AddCreatedByUpdatedByToErpProducts < ActiveRecord::Migration
2
+ def up
3
+ %w{product_feature_types
4
+ product_feature_values
5
+ product_features
6
+ product_offers
7
+ product_types}.each do |table|
8
+
9
+ unless column_exists? table.to_sym, :created_by_party_id
10
+ add_column table.to_sym, :created_by_party_id, :integer
11
+
12
+ add_index table.to_sym, :created_by_party_id, name: "#{table}_created_by_pty_idx"
13
+ end
14
+
15
+ unless column_exists? table.to_sym, :updated_by_party_id
16
+ add_column table.to_sym, :updated_by_party_id, :integer
17
+
18
+ add_index table.to_sym, :updated_by_party_id, name: "#{table}_updated_by_pty_idx"
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ def down
26
+ %w{product_feature_types
27
+ product_feature_values
28
+ product_features
29
+ product_offers
30
+ product_types}.each do |table|
31
+
32
+ if column_exists? table.to_sym, :created_by_party_id
33
+ remove_column table.to_sym, :created_by_party_id
34
+ end
35
+
36
+ if column_exists? table.to_sym, :updated_by_party_id
37
+ remove_column table.to_sym, :updated_by_party_id
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -1,10 +1,6 @@
1
1
  module ErpProducts
2
2
  class Engine < Rails::Engine
3
3
  isolate_namespace ErpProducts
4
-
5
- initializer "erp_products.merge_public" do |app|
6
- app.middleware.insert_before Rack::Runtime, ::ActionDispatch::Static, "#{root}/public"
7
- end
8
4
 
9
5
  ActiveSupport.on_load(:active_record) do
10
6
  include ErpProducts::Extensions::ActiveRecord::ActsAsProductInstance
@@ -1,7 +1,7 @@
1
1
  module ErpProducts
2
- module Extensions
3
- module ActiveRecord
4
- module ActsAsProductOffer
2
+ module Extensions
3
+ module ActiveRecord
4
+ module ActsAsProductOffer
5
5
 
6
6
  def self.included(base)
7
7
  base.extend(ClassMethods)
@@ -19,7 +19,10 @@ module ErpProducts
19
19
 
20
20
  has_one :product_offer, :as => :product_offer_record
21
21
 
22
- [:description, :description=].each do |m| delegate m, :to => :product_offer end
22
+ [:description, :description=, :valid_from,
23
+ :valid_from=, :valid_to, :valid_to=].each do |m|
24
+ delegate m, :to => :product_offer
25
+ end
23
26
  end
24
27
  end
25
28
 
@@ -1,7 +1,7 @@
1
1
  module ErpProducts
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_products
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_app
@@ -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 Products Engine implements ProductType and ProductInstance, as well
42
42
  as a number of classes to support product catalog-type functions and search/shopping
43
43
  scenarios. '
@@ -50,7 +50,9 @@ files:
50
50
  - GPL-3-LICENSE
51
51
  - README.rdoc
52
52
  - Rakefile
53
- - app/controllers/erp_products/shared/product_types_controller.rb
53
+ - app/controllers/api/v1/product_types_controller.rb
54
+ - app/controllers/erp_products/shared/product_features_controller.rb
55
+ - app/models/extensions/biz_txn_acct_root.rb
54
56
  - app/models/prod_availability_status_type.rb
55
57
  - app/models/prod_instance_reln.rb
56
58
  - app/models/prod_instance_reln_type.rb
@@ -58,23 +60,31 @@ files:
58
60
  - app/models/prod_type_reln.rb
59
61
  - app/models/prod_type_reln_type.rb
60
62
  - app/models/prod_type_role_type.rb
63
+ - app/models/product_feature.rb
64
+ - app/models/product_feature_applicability.rb
65
+ - app/models/product_feature_interaction.rb
66
+ - app/models/product_feature_interaction_type.rb
67
+ - app/models/product_feature_type.rb
68
+ - app/models/product_feature_type_product_feature_value.rb
69
+ - app/models/product_feature_value.rb
61
70
  - app/models/product_instance.rb
62
71
  - app/models/product_offer.rb
63
72
  - app/models/product_package.rb
64
73
  - app/models/product_type.rb
65
74
  - app/models/product_type_pty_role.rb
66
75
  - app/models/simple_product_offer.rb
67
- - app/views/erp_products/shared/product_types/show_details.html.erb
68
76
  - config/routes.rb
69
77
  - db/data_migrations/20110324010232_product_role_types.rb
70
78
  - db/data_migrations/20110527160807_add_default_prod_avail_types.rb
71
79
  - db/data_migrations/20140130204915_add_vendor_consumer_product_roles_to_role_type.rb
80
+ - db/data_migrations/20141222195727_add_product_type_view_types.rb
72
81
  - db/migrate/20080805000040_base_products.rb
73
- - db/migrate/20080805000041_base_products_indexes.rb
74
- - db/migrate/20130131204335_add_product_instances_nested_set_indexes.rb
75
- - db/migrate/20130131204336_add_type_column_to_product_types.rb
76
- - db/migrate/20140124185720_add_product_party_roles.rb
77
- - db/migrate/20140130211433_add_sku_comment_uom_to_product_type.rb
82
+ - db/migrate/20150304211841_add_shipping_cost_to_product_types.rb
83
+ - db/migrate/20150507075057_add_dimensions_to_product_types.rb
84
+ - db/migrate/20150622150625_add_taxable_to_product_types.rb
85
+ - db/migrate/20150711194216_update_product_feature_interactions.rb
86
+ - db/migrate/20151216235328_add_biz_txn_acct_root_to_products.rb
87
+ - db/migrate/20160310163055_add_created_by_updated_by_to_erp_products.rb
78
88
  - lib/erp_products.rb
79
89
  - lib/erp_products/engine.rb
80
90
  - lib/erp_products/extensions.rb
@@ -141,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
151
  version: '0'
142
152
  requirements: []
143
153
  rubyforge_project:
144
- rubygems_version: 2.2.2
154
+ rubygems_version: 2.4.8
145
155
  signing_key:
146
156
  specification_version: 4
147
157
  summary: The Products Engine implements ProductType and ProductInstance, as well as
@@ -1,96 +0,0 @@
1
- module ErpProducts
2
- module Shared
3
- class ProductTypesController < ::ErpApp::Organizer::BaseController
4
-
5
- def index
6
-
7
- party_id = params[:party_id]
8
- party_role = params[:party_role]
9
-
10
- #
11
- # Get all product types
12
- #
13
- product_types = ProductType.order('created_at asc')
14
-
15
- #
16
- # Scope by party id and/or party role if specified
17
- #
18
- unless party_id.blank? and party_role.blank?
19
-
20
- product_types = product_types.joins(:product_type_pty_roles)
21
- product_types = product_types.where('product_type_pty_roles.party_id = ?', party_id) unless party_id.blank?
22
-
23
- unless party_role.blank?
24
- role_type = RoleType.iid(party_role)
25
- product_types = product_types.where('product_type_pty_roles.role_type_id = ?', role_type)
26
- end
27
- end
28
-
29
- total = product_types.count
30
-
31
- render :json => {:success => true, :total => total, :product_types => product_types.collect { |product_type| product_type.to_data_hash }}
32
-
33
- end
34
-
35
- def show
36
-
37
- product_type = ProductType.find(params[:product_type_id])
38
- render :json => {:success => true, :data => product_type.to_data_hash}
39
-
40
- end
41
-
42
- def show_details
43
-
44
- @product_type = ProductType.find(params[:id]) rescue nil
45
-
46
- end
47
-
48
- def create
49
-
50
- product_type = ProductType.new
51
- product_type.description = params[:description]
52
- product_type.sku = params[:sku]
53
- product_type.unit_of_measurement_id = params[:unit_of_measurement]
54
- product_type.comment = params[:comment]
55
- product_type.save
56
-
57
- #
58
- # For scoping by party, add party_id and role_type 'vendor' to product_party_roles table. However may want to override controller elsewhere
59
- # so that default is no scoping in erp_products engine
60
- #
61
- party_role = params[:party_role]
62
- party_id = params[:party_id]
63
- unless party_role.blank? or party_id.blank?
64
- product_type_party_role = ProductTypePtyRole.new
65
- product_type_party_role.product_type = product_type
66
- product_type_party_role.party_id = party_id
67
- product_type_party_role.role_type = RoleType.iid(party_role)
68
- product_type_party_role.save
69
- end
70
-
71
- render :json => {:success => true, :product_type_id => product_type.id, :data => product_type.to_hash(:only => [:id, :description, :sku, :created_at, :updated_at])}
72
- end
73
-
74
- def update
75
-
76
- product_type = ProductType.find(params[:product_type_id])
77
- product_type.description = params[:description]
78
- product_type.sku = params[:sku]
79
- product_type.unit_of_measurement_id = params[:unit_of_measurement]
80
- product_type.comment = params[:comment]
81
- product_type.save
82
-
83
- render :json => {:success => true, :data => product_type.to_hash(:only => [:id, :description, :sku, :created_at, :updated_at])}
84
-
85
- end
86
-
87
- def destroy
88
-
89
- ProductType.find(params[:product_type_id]).destroy
90
- render :json => {:success => true}
91
-
92
- end
93
-
94
- end
95
- end
96
- end
@@ -1,8 +0,0 @@
1
- <div style='padding: 10px;'>
2
-
3
- <h1>Description: <%= @product_type.description %></h1>
4
- <h2>SKU: <%= @product_type.sku %></h2>
5
- <h2>Unit of Measurement: <%= @product_type.unit_of_measurement.description rescue nil%></h2>
6
- <h2>Details: <%= @product_type.comment %></h2>
7
-
8
- </div>
@@ -1,61 +0,0 @@
1
- class BaseProductsIndexes < ActiveRecord::Migration
2
- def self.up
3
- add_index :product_types, :parent_id
4
- add_index :product_types, [:product_type_record_id, :product_type_record_type],
5
- :name => "bpi_1"
6
-
7
- add_index :product_instances, :parent_id
8
- add_index :product_instances, [:product_instance_record_id, :product_instance_record_type],
9
- :name => "bpi_2"
10
- add_index :product_instances, :product_type_id
11
-
12
- add_index :product_offers, [:product_offer_record_id, :product_offer_record_type],
13
- :name => "bpi_3"
14
-
15
- add_index :simple_product_offers, :product_id
16
-
17
- add_index :prod_instance_reln_types, :parent_id
18
-
19
- add_index :prod_instance_role_types, :parent_id
20
-
21
- add_index :prod_instance_relns, :prod_instance_reln_type_id
22
- add_index :prod_instance_relns, :status_type_id
23
-
24
- add_index :prod_type_reln_types, :parent_id
25
-
26
- add_index :prod_type_role_types, :parent_id
27
-
28
- add_index :prod_type_relns, :prod_type_reln_type_id
29
- add_index :prod_type_relns, :status_type_id
30
-
31
- add_index :product_instances, :lft, :name => 'lft_index' unless indexes(:product_instances).collect {|i| i.name}.include?('lft_index')
32
- add_index :product_instances, :rgt, :name => 'rgt_index' unless indexes(:product_instances).collect {|i| i.name}.include?('rgt_index')
33
- end
34
-
35
- def self.down
36
- remove_index :product_types, :parent_id
37
- remove_index :product_types, :name => "bpi_1"
38
-
39
- remove_index :product_instances, :parent_id
40
- remove_index :product_instances, :name => "bpi_2"
41
- remove_index :product_instances, :product_type_id
42
-
43
- remove_index :product_offers, :name => "bpi_3"
44
-
45
- remove_index :simple_product_offers, :product_id
46
-
47
- remove_index :prod_instance_reln_types, :parent_id
48
-
49
- remove_index :prod_instance_role_types, :parent_id
50
-
51
- remove_index :prod_instance_relns, :prod_instance_reln_type_id
52
- remove_index :prod_instance_relns, :status_type_id
53
-
54
- remove_index :prod_type_reln_types, :parent_id
55
-
56
- remove_index :prod_type_role_types, :parent_id
57
-
58
- remove_index :prod_type_relns, :prod_type_reln_type_id
59
- remove_index :prod_type_relns, :status_type_id
60
- end
61
- end
@@ -1,9 +0,0 @@
1
- class AddProductInstancesNestedSetIndexes < ActiveRecord::Migration
2
- def up
3
- add_index :product_instances, :lft, :name => 'lft_index' unless indexes(:product_instances).collect {|i| i.name}.include?('lft_index')
4
- add_index :product_instances, :rgt, :name => 'rgt_index' unless indexes(:product_instances).collect {|i| i.name}.include?('rgt_index')
5
- end
6
-
7
- def down
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddTypeColumnToProductTypes < ActiveRecord::Migration
2
- def up
3
- add_column :product_types, :type, :string
4
- end
5
-
6
- def down
7
- remove_column :product_types, :type
8
- end
9
- end