erp_products 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/GPL-3-LICENSE +674 -0
- data/README.rdoc +2 -0
- data/Rakefile +30 -0
- data/app/assets/javascripts/erp_products/application.js +9 -0
- data/app/assets/stylesheets/erp_products/application.css +7 -0
- data/app/controllers/erp_products/erp_app/desktop/product_manager/base_controller.rb +233 -0
- data/app/helpers/erp_products/application_helper.rb +4 -0
- data/app/models/prod_availability_status_type.rb +5 -0
- data/app/models/prod_instance_reln.rb +14 -0
- data/app/models/prod_instance_reln_type.rb +4 -0
- data/app/models/prod_instance_role_type.rb +4 -0
- data/app/models/prod_type_reln.rb +15 -0
- data/app/models/prod_type_reln_type.rb +4 -0
- data/app/models/prod_type_role_type.rb +4 -0
- data/app/models/product_instance.rb +21 -0
- data/app/models/product_offer.rb +11 -0
- data/app/models/product_package.rb +7 -0
- data/app/models/product_type.rb +37 -0
- data/app/models/simple_product_offer.rb +4 -0
- data/app/views/layouts/erp_products/application.html.erb +14 -0
- data/config/routes.rb +4 -0
- data/db/data_migrations/20110324010232_product_role_types.rb +23 -0
- data/db/data_migrations/20110527160807_add_default_prod_avail_types.rb +26 -0
- data/db/data_migrations/20110728201730_create_desktop_app_product_manager.rb +25 -0
- data/db/migrate/20080805000040_base_products.rb +232 -0
- data/db/migrate/20080805000041_base_products_indexes.rb +58 -0
- data/lib/erp_products/engine.rb +16 -0
- data/lib/erp_products/extensions/active_record/acts_as_product_instance.rb +50 -0
- data/lib/erp_products/extensions/active_record/acts_as_product_offer.rb +52 -0
- data/lib/erp_products/extensions/active_record/acts_as_product_type.rb +59 -0
- data/lib/erp_products/extensions.rb +3 -0
- data/lib/erp_products/version.rb +3 -0
- data/lib/erp_products.rb +5 -0
- data/lib/tasks/erp_products_tasks.rake +4 -0
- data/public/javascripts/erp_app/desktop/applications/product_manager/module.js +799 -0
- data/public/javascripts/erp_app/desktop/applications/product_manager/product_list_panel.js +141 -0
- data/public/stylesheets/erp_app/desktop/applications/product_manager/style.css +71 -0
- metadata +119 -0
@@ -0,0 +1,232 @@
|
|
1
|
+
class BaseProducts < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
unless table_exists?(:product_types)
|
5
|
+
create_table :product_types do |t|
|
6
|
+
#these columns are required to support the behavior of the plugin 'better_nested_set'
|
7
|
+
#ALL products have the ability to act as packages in a nested set-type structure
|
8
|
+
#
|
9
|
+
#The package behavior is treated differently from other product_relationship behavior
|
10
|
+
#which is implemented using a standard relationship structure.
|
11
|
+
#
|
12
|
+
#This is to allow quick construction of highly nested product types.
|
13
|
+
t.column :parent_id, :integer
|
14
|
+
t.column :lft, :integer
|
15
|
+
t.column :rgt, :integer
|
16
|
+
|
17
|
+
#custom columns go here
|
18
|
+
t.column :description, :string
|
19
|
+
t.column :product_type_record_id, :integer
|
20
|
+
t.column :product_type_record_type, :string
|
21
|
+
t.column :external_identifier, :string
|
22
|
+
t.column :external_id_source, :string
|
23
|
+
t.column :default_image_url, :string
|
24
|
+
t.column :list_view_image_id, :integer
|
25
|
+
t.timestamps
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
unless table_exists?(:product_instances)
|
30
|
+
create_table :product_instances do |t|
|
31
|
+
#these columns are required to support the behavior of the plugin 'better_nested_set'
|
32
|
+
#ALL products have the ability to act as packages in a nested set-type structure
|
33
|
+
#
|
34
|
+
#The package behavior is treated differently from other product_relationship behavior
|
35
|
+
#which is implemented using a standard relationship structure.
|
36
|
+
#
|
37
|
+
#This is to allow quick construction of highly nested product types.
|
38
|
+
t.column :parent_id, :integer
|
39
|
+
t.column :lft, :integer
|
40
|
+
t.column :rgt, :integer
|
41
|
+
|
42
|
+
#custom columns go here
|
43
|
+
t.column :description, :string
|
44
|
+
t.column :product_instance_record_id, :integer
|
45
|
+
t.column :product_instance_record_type, :string
|
46
|
+
t.column :external_identifier, :string
|
47
|
+
t.column :external_id_source, :string
|
48
|
+
t.column :product_type_id, :integer
|
49
|
+
t.column :type, :string
|
50
|
+
|
51
|
+
t.references :prod_availability_status_type
|
52
|
+
|
53
|
+
t.timestamps
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
unless table_exists?(:product_offers)
|
58
|
+
create_table :product_offers do |t|
|
59
|
+
t.column :description, :string
|
60
|
+
t.column :product_offer_record_id, :integer
|
61
|
+
t.column :product_offer_record_type, :string
|
62
|
+
t.column :external_identifier, :string
|
63
|
+
t.column :external_id_source, :string
|
64
|
+
t.timestamps
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
unless table_exists?(:simple_product_offers)
|
69
|
+
create_table :simple_product_offers do |t|
|
70
|
+
t.column :description, :string
|
71
|
+
t.column :product_id, :integer
|
72
|
+
t.column :base_price, :float
|
73
|
+
t.column :uom, :integer
|
74
|
+
t.timestamps
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
unless table_exists?(:prod_instance_reln_types)
|
79
|
+
create_table :prod_instance_reln_types do |t|
|
80
|
+
t.column :parent_id, :integer
|
81
|
+
t.column :lft, :integer
|
82
|
+
t.column :rgt, :integer
|
83
|
+
|
84
|
+
#custom columns go here
|
85
|
+
t.column :description, :string
|
86
|
+
t.column :comments, :string
|
87
|
+
t.column :internal_identifier, :string
|
88
|
+
t.column :external_identifier, :string
|
89
|
+
t.column :external_id_source, :string
|
90
|
+
t.timestamps
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
unless table_exists?(:prod_instance_role_types)
|
95
|
+
create_table :prod_instance_role_types do |t|
|
96
|
+
t.column :parent_id, :integer
|
97
|
+
t.column :lft, :integer
|
98
|
+
t.column :rgt, :integer
|
99
|
+
#custom columns go here
|
100
|
+
t.column :description, :string
|
101
|
+
t.column :comments, :string
|
102
|
+
t.column :internal_identifier, :string
|
103
|
+
t.column :external_identifier, :string
|
104
|
+
t.column :external_id_source, :string
|
105
|
+
t.timestamps
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
unless table_exists?(:prod_instance_relns)
|
110
|
+
create_table :prod_instance_relns do |t|
|
111
|
+
t.column :prod_instance_reln_type_id, :integer
|
112
|
+
t.column :description, :string
|
113
|
+
t.column :prod_instance_id_from, :integer
|
114
|
+
t.column :prod_instance_id_to, :integer
|
115
|
+
t.column :role_type_id_from, :integer
|
116
|
+
t.column :role_type_id_to, :integer
|
117
|
+
t.column :status_type_id, :integer
|
118
|
+
t.column :from_date, :date
|
119
|
+
t.column :thru_date, :date
|
120
|
+
t.timestamps
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
unless table_exists?(:prod_type_reln_types)
|
125
|
+
create_table :prod_type_reln_types do |t|
|
126
|
+
t.column :parent_id, :integer
|
127
|
+
t.column :lft, :integer
|
128
|
+
t.column :rgt, :integer
|
129
|
+
#custom columns go here
|
130
|
+
t.column :description, :string
|
131
|
+
t.column :comments, :string
|
132
|
+
t.column :internal_identifier, :string
|
133
|
+
t.column :external_identifier, :string
|
134
|
+
t.column :external_id_source, :string
|
135
|
+
t.timestamps
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
unless table_exists?(:prod_type_role_types)
|
140
|
+
create_table :prod_type_role_types do |t|
|
141
|
+
t.column :parent_id, :integer
|
142
|
+
t.column :lft, :integer
|
143
|
+
t.column :rgt, :integer
|
144
|
+
#custom columns go here
|
145
|
+
t.column :description, :string
|
146
|
+
t.column :comments, :string
|
147
|
+
t.column :internal_identifier, :string
|
148
|
+
t.column :external_identifier, :string
|
149
|
+
t.column :external_id_source, :string
|
150
|
+
t.timestamps
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
unless table_exists?(:prod_type_relns)
|
155
|
+
create_table :prod_type_relns do |t|
|
156
|
+
t.column :prod_type_reln_type_id, :integer
|
157
|
+
t.column :description, :string
|
158
|
+
t.column :prod_type_id_from, :integer
|
159
|
+
t.column :prod_type_id_to, :integer
|
160
|
+
t.column :role_type_id_from, :integer
|
161
|
+
t.column :role_type_id_to, :integer
|
162
|
+
t.column :status_type_id, :integer
|
163
|
+
t.column :from_date, :date
|
164
|
+
t.column :thru_date, :date
|
165
|
+
t.timestamps
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
unless table_exists?(:product_instance_status_types)
|
170
|
+
create_table :product_instance_status_types do |t|
|
171
|
+
#better nested set colummns
|
172
|
+
t.column :parent_id, :integer
|
173
|
+
t.column :lft, :integer
|
174
|
+
t.column :rgt, :integer
|
175
|
+
|
176
|
+
t.column :description, :string
|
177
|
+
t.column :internal_identifier, :string
|
178
|
+
t.column :external_identifier, :string
|
179
|
+
t.column :external_id_source, :string
|
180
|
+
|
181
|
+
t.timestamps
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
unless table_exists?(:prod_availability_status_types)
|
186
|
+
create_table :prod_availability_status_types do |t|
|
187
|
+
#better nested set colummns
|
188
|
+
t.column :parent_id, :integer
|
189
|
+
t.column :lft, :integer
|
190
|
+
t.column :rgt, :integer
|
191
|
+
|
192
|
+
t.column :description, :string
|
193
|
+
t.column :internal_identifier, :string
|
194
|
+
t.column :external_identifier, :string
|
195
|
+
t.column :external_id_source, :string
|
196
|
+
|
197
|
+
t.timestamps
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
unless table_exists?(:prod_availability_status_types)
|
202
|
+
create_table :prod_availability_status_types do |t|
|
203
|
+
#better nested set colummns
|
204
|
+
t.column :parent_id, :integer
|
205
|
+
t.column :lft, :integer
|
206
|
+
t.column :rgt, :integer
|
207
|
+
|
208
|
+
t.column :description, :string
|
209
|
+
t.column :internal_identifier, :string
|
210
|
+
t.column :external_identifier, :string
|
211
|
+
t.column :external_id_source, :string
|
212
|
+
|
213
|
+
t.timestamps
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.down
|
221
|
+
[
|
222
|
+
:prod_type_relns, :prod_type_role_types, :prod_type_reln_types,
|
223
|
+
:prod_instance_relns, :prod_instance_role_types, :prod_instance_reln_types,
|
224
|
+
:simple_product_offers, :product_offers, :product_instances,
|
225
|
+
:product_types,:prod_availability_status_types
|
226
|
+
].each do |tbl|
|
227
|
+
if table_exists?(tbl)
|
228
|
+
drop_table tbl
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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
|
+
end
|
31
|
+
|
32
|
+
def self.down
|
33
|
+
remove_index :product_types, :parent_id
|
34
|
+
remove_index :product_types, :name => "bpi_1"
|
35
|
+
|
36
|
+
remove_index :product_instances, :parent_id
|
37
|
+
remove_index :product_instances, :name => "bpi_2"
|
38
|
+
remove_index :product_instances, :product_type_id
|
39
|
+
|
40
|
+
remove_index :product_offers, :name => "bpi_3"
|
41
|
+
|
42
|
+
remove_index :simple_product_offers, :product_id
|
43
|
+
|
44
|
+
remove_index :prod_instance_reln_types, :parent_id
|
45
|
+
|
46
|
+
remove_index :prod_instance_role_types, :parent_id
|
47
|
+
|
48
|
+
remove_index :prod_instance_relns, :prod_instance_reln_type_id
|
49
|
+
remove_index :prod_instance_relns, :status_type_id
|
50
|
+
|
51
|
+
remove_index :prod_type_reln_types, :parent_id
|
52
|
+
|
53
|
+
remove_index :prod_type_role_types, :parent_id
|
54
|
+
|
55
|
+
remove_index :prod_type_relns, :prod_type_reln_type_id
|
56
|
+
remove_index :prod_type_relns, :status_type_id
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ErpProducts
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
isolate_namespace ErpProducts
|
4
|
+
|
5
|
+
initializer "erp_products.merge_public" do |app|
|
6
|
+
app.middleware.insert_before Rack::Lock, ::ActionDispatch::Static, "#{root}/public"
|
7
|
+
end
|
8
|
+
|
9
|
+
ActiveSupport.on_load(:active_record) do
|
10
|
+
include ErpProducts::Extensions::ActiveRecord::ActsAsProductInstance
|
11
|
+
include ErpProducts::Extensions::ActiveRecord::ActsAsProductOffer
|
12
|
+
include ErpProducts::Extensions::ActiveRecord::ActsAsProductType
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ErpProducts
|
2
|
+
module Extensions
|
3
|
+
module ActiveRecord
|
4
|
+
module ActsAsProductInstance
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def acts_as_product_instance
|
11
|
+
extend ActsAsProductInstance::SingletonMethods
|
12
|
+
include ActsAsProductInstance::InstanceMethods
|
13
|
+
|
14
|
+
after_initialize :initialize_product_instance
|
15
|
+
after_create :save_product_instance
|
16
|
+
after_update :save_product_instance
|
17
|
+
after_destroy :destroy_product_instance
|
18
|
+
|
19
|
+
has_one :product_instance, :as => :product_instance_record
|
20
|
+
|
21
|
+
[:product_type,:product_type=,:description,:description=].each do |m| delegate m, :to => :product_instance end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module SingletonMethods
|
27
|
+
end
|
28
|
+
|
29
|
+
module InstanceMethods
|
30
|
+
def save_product_instance
|
31
|
+
self.product_instance.save
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize_product_instance
|
35
|
+
if self.new_record? && self.product_instance.nil?
|
36
|
+
product_instance = ProductInstance.new
|
37
|
+
self.product_instance = product_instance
|
38
|
+
product_instance.product_instance_record = self
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy_product_instance
|
43
|
+
self.product_instance.destroy if (self.product_instance && !self.product_instance.frozen?)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module ErpProducts
|
2
|
+
module Extensions
|
3
|
+
module ActiveRecord
|
4
|
+
module ActsAsProductOffer
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def acts_as_product_offer
|
12
|
+
extend ActsAsProductOffer::SingletonMethods
|
13
|
+
include ActsAsProductOffer::InstanceMethods
|
14
|
+
|
15
|
+
after_initialize :initialize_product_offer
|
16
|
+
after_create :save_product_offer
|
17
|
+
after_update :save_product_offer
|
18
|
+
after_destroy :destroy_product_offer
|
19
|
+
|
20
|
+
has_one :product_offer, :as => :product_offer_record
|
21
|
+
|
22
|
+
[:description, :description=].each do |m| delegate m, :to => :product_offer end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module SingletonMethods
|
27
|
+
end
|
28
|
+
|
29
|
+
module InstanceMethods
|
30
|
+
def initialize_product_offer
|
31
|
+
if self.new_record? && self.product_offer.nil?
|
32
|
+
product_offer = ProductOffer.new
|
33
|
+
self.product_offer = product_offer
|
34
|
+
product_offer.save
|
35
|
+
self.save
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def save_product_offer
|
40
|
+
self.product_offer.description = self.description
|
41
|
+
self.product_offer.save
|
42
|
+
end
|
43
|
+
|
44
|
+
def destroy_product_offer
|
45
|
+
self.product_offer.destroy if (self.product_offer && !self.product_offer.frozen?)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ErpProducts
|
2
|
+
module Extensions
|
3
|
+
module ActiveRecord
|
4
|
+
module ActsAsProductType
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def acts_as_product_type()
|
12
|
+
extend ActsAsProductType::SingletonMethods
|
13
|
+
include ActsAsProductType::InstanceMethods
|
14
|
+
|
15
|
+
after_initialize :initialize_product_type
|
16
|
+
after_create :save_product_type
|
17
|
+
after_update :save_product_type
|
18
|
+
after_destroy :destroy_product_type
|
19
|
+
|
20
|
+
has_one :product_type, :as => :product_type_record
|
21
|
+
|
22
|
+
[:children, :description, :description=].each do |m| delegate m, :to => :product_type end
|
23
|
+
|
24
|
+
def self.find_roots
|
25
|
+
ProductType.find_roots
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.find_children(parent_id = nil)
|
29
|
+
ProductType.find_children(parent_id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module SingletonMethods
|
35
|
+
end
|
36
|
+
|
37
|
+
module InstanceMethods
|
38
|
+
def initialize_product_type
|
39
|
+
if self.new_record? && self.product_type.nil?
|
40
|
+
product_type = ProductType.new
|
41
|
+
self.product_type = product_type
|
42
|
+
product_type.save
|
43
|
+
self.save
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def save_product_type
|
48
|
+
self.product_type.save
|
49
|
+
end
|
50
|
+
|
51
|
+
def destroy_product_type
|
52
|
+
self.product_type.destroy if (self.product_type && !self.product_type.frozen?)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/erp_products.rb
ADDED