erp_base_erp_svcs 3.1.5 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/erp_base_erp_svcs/shared/units_of_measurement_controller.rb +32 -0
  3. data/app/models/compass_ae_instance.rb +2 -0
  4. data/app/models/contact.rb +4 -0
  5. data/app/models/email_address.rb +4 -1
  6. data/app/models/facility.rb +12 -0
  7. data/app/models/facility_type.rb +8 -0
  8. data/app/models/fixed_asset.rb +8 -0
  9. data/app/models/fixed_asset_party_role.rb +8 -0
  10. data/app/models/fixed_asset_type.rb +9 -0
  11. data/app/models/individual.rb +10 -14
  12. data/app/models/party.rb +138 -51
  13. data/app/models/party_unit_of_measurement.rb +6 -0
  14. data/app/models/phone_number.rb +5 -1
  15. data/app/models/postal_address.rb +5 -1
  16. data/app/models/unit_of_measurement.rb +16 -0
  17. data/config/initializers/root_loader.rb +9 -0
  18. data/config/routes.rb +5 -0
  19. data/db/migrate/20080805000020_base_erp_services.rb +1 -29
  20. data/db/migrate/20130522125404_create_facilities.rb +114 -0
  21. data/db/migrate/20130621182047_create_unit_of_measurements.rb +18 -0
  22. data/db/migrate/20130909163912_add_iid_index_to_role_types.rb +9 -0
  23. data/db/migrate/20130926023541_add_domain_to_unit_of_measure.rb +13 -0
  24. data/db/migrate/20130929025342_add_type_semantics_to_uom.rb +54 -0
  25. data/db/migrate/20131112013047_add_primary_to_contacts.rb +13 -0
  26. data/db/migrate/20131112013048_add_erp_base_erp_svcs_missing_indexes.rb +33 -0
  27. data/db/migrate/20131211180831_add_postal_address_to_facility.rb +5 -0
  28. data/db/migrate/20140102154311_create_fixed_asset_party_roles.rb +12 -0
  29. data/db/migrate/20140401072612_add_custom_fields_to_party.rb +12 -0
  30. data/lib/erp_base_erp_svcs.rb +5 -5
  31. data/lib/erp_base_erp_svcs/engine.rb +5 -3
  32. data/lib/erp_base_erp_svcs/extensions.rb +3 -0
  33. data/lib/erp_base_erp_svcs/extensions/active_record/acts_as_facility.rb +54 -0
  34. data/lib/erp_base_erp_svcs/extensions/active_record/acts_as_fixed_asset.rb +54 -0
  35. data/lib/erp_base_erp_svcs/extensions/active_record/has_contact.rb +25 -12
  36. data/lib/erp_base_erp_svcs/extensions/active_record/has_notes.rb +25 -2
  37. data/lib/erp_base_erp_svcs/extensions/active_record/has_tracked_status.rb +58 -6
  38. data/lib/erp_base_erp_svcs/extensions/active_record/to_hash.rb +12 -12
  39. data/lib/erp_base_erp_svcs/extensions/core/acts_as_aspector_on.rb +73 -0
  40. data/lib/erp_base_erp_svcs/extensions/core/object.rb +7 -0
  41. data/lib/erp_base_erp_svcs/version.rb +7 -3
  42. data/lib/tasks/compass_backup.rake +11 -6
  43. data/lib/tasks/erp_base_erp_svcs_tasks.rake +22 -9
  44. data/spec/models/party_spec.rb +9 -1
  45. metadata +80 -113
  46. data/app/assets/javascripts/erp_base_erp_svcs/application.js +0 -9
  47. data/app/assets/stylesheets/erp_base_erp_svcs/application.css +0 -7
  48. data/app/controllers/erp_base_erp_svcs/application_controller.rb +0 -4
  49. data/app/views/layouts/erp_base_erp_svcs/application.html.erb +0 -14
  50. data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +0 -12
  51. data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +0 -19
  52. data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +0 -12
  53. data/spec/dummy/db/data_migrations/20130422154233_upgrade_compass_ae_instances_data.erp_base_erp_svcs.rb +0 -19
  54. data/spec/dummy/db/data_migrations/20130422154234_add_guid_to_instances.erp_base_erp_svcs.rb +0 -10
  55. data/spec/dummy/db/migrate/20130105143821_base_erp_services.erp_base_erp_svcs.rb +0 -461
  56. data/spec/dummy/db/migrate/20130422154229_add_txn_status.erp_base_erp_svcs.rb +0 -37
  57. data/spec/dummy/db/migrate/20130422154230_upgrade_compass_ae_instances.erp_base_erp_svcs.rb +0 -34
  58. data/spec/dummy/db/migrate/20130422154231_add_uuid_compass_ae_instance.erp_base_erp_svcs.rb +0 -17
  59. data/spec/dummy/db/migrate/20130422154232_add_long_lat_to_address.erp_base_erp_svcs.rb +0 -16
  60. data/spec/dummy/db/schema.rb +0 -435
  61. data/spec/dummy/db/spec.sqlite3 +0 -0
@@ -0,0 +1,6 @@
1
+ class PartyUnitOfMeasurement < ActiveRecord::Base
2
+ attr_accessible :description, :scope_filter, :party_id, :unit_of_measurement_id, :internal_identifier
3
+ belongs_to :party
4
+ belongs_to :unit_of_measurement
5
+
6
+ end
@@ -12,7 +12,11 @@ class PhoneNumber < ActiveRecord::Base
12
12
  end
13
13
 
14
14
  def to_label
15
- "#{description} : #{phone_number}"
15
+ "#{description} : #{to_s}"
16
16
  end
17
+
18
+ def to_s
19
+ "#{phone_number}"
20
+ end
17
21
 
18
22
  end
@@ -14,9 +14,13 @@ class PostalAddress < ActiveRecord::Base
14
14
  if block_given?
15
15
  block.call(self)
16
16
  else
17
- "#{description} : #{address_line_1}, #{city}"
17
+ "#{description} : #{to_s}"
18
18
  end
19
19
  end
20
+
21
+ def to_s
22
+ "#{address_line_1}, #{city}, #{state} - #{zip}"
23
+ end
20
24
 
21
25
  def zip_eql_to?(zip)
22
26
  self.zip.downcase.gsub(/[^a-zA-Z0-9]/, "")[0..4] == zip.to_s.downcase.gsub(/[^a-zA-Z0-9]/,"")[0..4]
@@ -0,0 +1,16 @@
1
+ class UnitOfMeasurement < ActiveRecord::Base
2
+
3
+ has_one :carrier_unit_of_measurement
4
+
5
+ attr_accessible :description
6
+
7
+ def to_data_hash
8
+
9
+ {
10
+ :id => self.id,
11
+ :description => self.description
12
+ }
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,9 @@
1
+ if Rails.application.config.cache_classes
2
+ Rails.application.config.after_initialize do
3
+ ErpBaseErpSvcs.load_root_compass_ae_framework_extensions
4
+ end
5
+ else
6
+ Rails.application.config.to_prepare do
7
+ ErpBaseErpSvcs.load_root_compass_ae_framework_extensions
8
+ end
9
+ end
@@ -1,2 +1,7 @@
1
1
  ErpBaseErpSvcs::Engine.routes.draw do
2
+
3
+ namespace 'shared' do
4
+ resources 'units_of_measurement'
5
+ end
6
+
2
7
  end
@@ -83,6 +83,7 @@ class BaseErpServices < ActiveRecord::Migration
83
83
  t.column :external_id_source, :string
84
84
  t.timestamps
85
85
  end
86
+ add_index :role_types, :internal_identifier, :name => "role_types_iid_idx"
86
87
  end
87
88
 
88
89
  # Create relationship_types table
@@ -275,35 +276,6 @@ class BaseErpServices < ActiveRecord::Migration
275
276
  end
276
277
  end
277
278
 
278
- unless table_exists?(:party_search_facts)
279
- create_table :party_search_facts do |t|
280
- t.column :party_id, :integer
281
- t.column :eid, :string
282
- t.column :type, :string
283
- t.column :roles, :text
284
- t.column :party_description, :string
285
- t.column :party_business_party_type, :string
286
- t.column :user_login, :string
287
- t.column :individual_current_last_name, :string
288
- t.column :individual_current_first_name, :string
289
- t.column :individual_current_middle_name, :string
290
- t.column :individual_birth_date, :string
291
- t.column :individual_ssn, :string
292
- t.column :party_phone_number, :string
293
- t.column :party_email_address, :string
294
- t.column :party_address_1, :string
295
- t.column :party_address_2, :string
296
- t.column :party_primary_address_city, :string
297
- t.column :party_primary_address_state, :string
298
- t.column :party_primary_address_zip, :string
299
- t.column :party_primary_address_country, :string
300
- t.column :user_enabled, :boolean
301
- t.column :user_type, :string
302
- t.column :reindex, :boolean
303
- t.timestamps
304
- end
305
- end
306
-
307
279
  unless table_exists?(:money)
308
280
  create_table :money do |t|
309
281
  t.string :description
@@ -0,0 +1,114 @@
1
+ class CreateFacilities < ActiveRecord::Migration
2
+ def up
3
+
4
+ unless table_exists?(:facilities)
5
+ create_table :facilities do |t|
6
+
7
+ t.string :description
8
+ t.string :internal_identifier
9
+ t.integer :facility_type_id
10
+
11
+ #polymorphic columns
12
+ t.integer :facility_record_id
13
+ t.integer :facility_record_type
14
+
15
+ t.timestamps
16
+ end
17
+
18
+ add_index :facilities, [:facility_record_id, :facility_record_type], :name => "facility_record_idx"
19
+ end
20
+
21
+ unless table_exists?(:facility_types)
22
+ create_table :facility_types do |t|
23
+
24
+ t.string :description
25
+ t.string :internal_identifier
26
+ t.string :external_identifier
27
+ t.string :external_identifer_source
28
+
29
+ #these columns are required to support the behavior of the plugin 'awesome_nested_set'
30
+ t.integer :parent_id
31
+ t.integer :lft
32
+ t.integer :rgt
33
+
34
+ t.timestamps
35
+ end
36
+
37
+ add_index :facility_types, [:parent_id, :lft, :rgt], :name => "facility_types_nested_set_idx"
38
+ end
39
+
40
+ ##********************************************************************************************
41
+ ## Infrastructure and Accounting
42
+ ##********************************************************************************************
43
+ ## TODO Move to a basic accounting engine
44
+ unless table_exists?(:fixed_assets)
45
+ create_table :fixed_assets do |t|
46
+
47
+ #foreign key references
48
+ t.references :fixed_asset_type
49
+
50
+ #custom columns go here
51
+ t.string :description
52
+ t.string :comments
53
+ t.string :internal_identifier
54
+ t.string :external_identifier
55
+ t.string :external_id_source
56
+
57
+ #polymorphic columns
58
+ t.string :fixed_asset_record_type
59
+ t.integer :fixed_asset_record_id
60
+
61
+ t.timestamps
62
+ end
63
+
64
+ add_index :fixed_assets, [:fixed_asset_record_type, :fixed_asset_record_id], :name => "fixed_assets_record_idx"
65
+ add_index :fixed_assets, :fixed_asset_type_id, :name => "fixed_assets_fixed_asset_type_idx"
66
+ end
67
+
68
+ unless table_exists?(:fixed_asset_types)
69
+ create_table :fixed_asset_types do |t|
70
+ #these columns are required to support the behavior of the plugin 'awesome_nested_set'
71
+ t.integer :parent_id
72
+ t.integer :lft
73
+ t.integer :rgt
74
+
75
+ #custom columns go here
76
+ t.string :description
77
+ t.string :comments
78
+ t.string :internal_identifier
79
+ t.string :external_identifier
80
+ t.string :external_id_source
81
+
82
+ t.timestamps
83
+ end
84
+
85
+ add_index :fixed_asset_types, [:parent_id, :lft, :rgt], :name => "fixed_asset_types_nested_set_idx"
86
+ end
87
+
88
+ ##Not a relationship with work_effort, but stores which fixed assets are assigned to or checked-out by parties
89
+ unless table_exists?(:party_fixed_asset_assignments)
90
+ create_table :party_fixed_asset_assignments do |t|
91
+ #foreign key references
92
+ t.references :party
93
+ t.references :fixed_asset
94
+
95
+ t.datetime :assigned_from
96
+ t.datetime :assigned_thru
97
+ t.integer :allocated_cost_money_id
98
+
99
+ t.timestamps
100
+ end
101
+
102
+ add_index :party_fixed_asset_assignments, [:party_id, :fixed_asset_id], :name => "party_fixed_asset_assign_idx"
103
+ end
104
+
105
+ end
106
+
107
+ def down
108
+ drop_table :facilities
109
+ drop_table :facility_types
110
+ drop_table :fixed_assets
111
+ drop_table :fixed_asset_types
112
+ drop_table :party_fixed_asset_assignments
113
+ end
114
+ end
@@ -0,0 +1,18 @@
1
+ class CreateUnitOfMeasurements < ActiveRecord::Migration
2
+ def up
3
+ unless table_exists?(:unit_of_measurements)
4
+ create_table :unit_of_measurements do |t|
5
+ t.column :description, :string
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ [:unit_of_measurements].each do |tbl|
13
+ if table_exists?(tbl)
14
+ drop_table tbl
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ class AddIidIndexToRoleTypes < ActiveRecord::Migration
2
+ def up
3
+ add_index :role_types, :internal_identifier, :name => "role_types_iid_idx" unless indexes(:role_types).collect {|i| i.name}.include?('role_types_iid_idx')
4
+ end
5
+
6
+ def down
7
+ remove_index :role_types, :internal_identifier if indexes(:role_types).collect {|i| i.name}.include?('role_types_iid_idx')
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class AddDomainToUnitOfMeasure < ActiveRecord::Migration
2
+ def up
3
+ unless columns(:unit_of_measurements).collect {|c| c.name}.include?('domain')
4
+ add_column :unit_of_measurements, :domain, :string
5
+ end
6
+ end
7
+
8
+ def down
9
+ if columns(:unit_of_measurements).collect {|c| c.name}.include?('domain')
10
+ remove_column :unit_of_measurements, :domain
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,54 @@
1
+ class AddTypeSemanticsToUom < ActiveRecord::Migration
2
+ def up
3
+
4
+ #Nested set fields
5
+ unless columns(:unit_of_measurements).collect {|c| c.name}.include?('lft')
6
+ add_column :unit_of_measurements, :lft, :integer
7
+ end
8
+ unless columns(:unit_of_measurements).collect {|c| c.name}.include?('rgt')
9
+ add_column :unit_of_measurements, :rgt, :integer
10
+ end
11
+ unless columns(:unit_of_measurements).collect {|c| c.name}.include?('parent_id')
12
+ add_column :unit_of_measurements, :parent_id, :integer
13
+ end
14
+ unless columns(:unit_of_measurements).collect {|c| c.name}.include?('internal_identifier')
15
+ add_column :unit_of_measurements, :internal_identifier, :string
16
+ end
17
+ unless columns(:unit_of_measurements).collect {|c| c.name}.include?('comments')
18
+ add_column :unit_of_measurements, :comments, :text
19
+ end
20
+
21
+ #External Identifier fields
22
+ unless columns(:unit_of_measurements).collect {|c| c.name}.include?('external_identifier')
23
+ add_column :unit_of_measurements, :external_identifier, :string
24
+ end
25
+ unless columns(:unit_of_measurements).collect {|c| c.name}.include?('external_id_source')
26
+ add_column :unit_of_measurements, :external_id_source, :string
27
+ end
28
+
29
+ end
30
+
31
+ def down
32
+ if columns(:unit_of_measurements).collect {|c| c.name}.include?('lft')
33
+ remove_column :unit_of_measurements, :lft
34
+ end
35
+ if columns(:unit_of_measurements).collect {|c| c.name}.include?('rgt')
36
+ remove_column :unit_of_measurements, :rgt
37
+ end
38
+ if columns(:unit_of_measurements).collect {|c| c.name}.include?('parent_id')
39
+ remove_column :unit_of_measurements, :rgt
40
+ end
41
+ if columns(:unit_of_measurements).collect {|c| c.name}.include?('internal_identifier')
42
+ remove_column :unit_of_measurements, :rgt
43
+ end
44
+ if columns(:unit_of_measurements).collect {|c| c.name}.include?('comments')
45
+ remove_column :unit_of_measurements, :rgt
46
+ end
47
+ if columns(:unit_of_measurements).collect {|c| c.name}.include?('external_identifier')
48
+ remove_column :unit_of_measurements, :rgt
49
+ end
50
+ if columns(:unit_of_measurements).collect {|c| c.name}.include?('external_id_source')
51
+ remove_column :unit_of_measurements, :rgt
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,13 @@
1
+ class AddPrimaryToContacts < ActiveRecord::Migration
2
+ def up
3
+ unless columns(:contacts).collect {|c| c.name}.include?('is_primary')
4
+ add_column :contacts, :is_primary, :boolean
5
+ end
6
+ end
7
+
8
+ def down
9
+ if columns(:contacts).collect {|c| c.name}.include?('is_primary')
10
+ remove_column :contacts, :is_primary
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ class AddErpBaseErpSvcsMissingIndexes < ActiveRecord::Migration
2
+ def up
3
+ if indexes(:relationship_types).select { |index| index.name == 'relationship_types_parent_id_idx' }.empty?
4
+ add_index :relationship_types, :parent_id, :name => 'relationship_types_parent_id_idx'
5
+ add_index :relationship_types, :internal_identifier, :name => 'relationship_types_internal_identifier_idx'
6
+ add_index :contact_types, :internal_identifier, :name => 'contact_types_internal_identifier_idx'
7
+ add_index :contact_purposes, :internal_identifier, :name => 'contact_purposes_internal_identifier_idx'
8
+ add_index :categories, :internal_identifier, :name => 'categories_internal_identifier_idx'
9
+ add_index :categories, :parent_id, :name => 'categories_parent_id_idx'
10
+ add_index :category_classifications, :category_id, :name => 'category_classifications_category_id_idx'
11
+ add_index :descriptive_assets, :internal_identifier, :name => 'descriptive_assets_internal_identifier_idx'
12
+ add_index :view_types, :internal_identifier, :name => 'view_types_internal_identifier_idx'
13
+ add_index :note_types, :parent_id, :name => 'note_types_parent_id_idx'
14
+ add_index :note_types, :internal_identifier, :name => 'note_types_internal_identifier_idx'
15
+ end
16
+ end
17
+
18
+ def down
19
+ unless indexes(:relationship_types).select { |index| index.name == 'relationship_types_parent_id_idx' }.empty?
20
+ remove_index :relationship_types, :parent_id
21
+ remove_index :relationship_types, :internal_identifier
22
+ remove_index :contact_types, :internal_identifier
23
+ remove_index :contact_purposes, :internal_identifier
24
+ remove_index :categories, :internal_identifier
25
+ remove_index :categories, :parent_id
26
+ remove_index :category_classifications, :category_id
27
+ remove_index :descriptive_assets, :internal_identifier
28
+ remove_index :view_types, :internal_identifier
29
+ remove_index :note_types, :parent_id
30
+ remove_index :note_types, :internal_identifier
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ class AddPostalAddressToFacility < ActiveRecord::Migration
2
+ def change
3
+ add_column :facilities, :postal_address_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ class CreateFixedAssetPartyRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table :fixed_asset_party_roles do |t|
4
+
5
+ t.references :party
6
+ t.references :fixed_asset
7
+ t.references :role_type
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class AddCustomFieldsToParty < ActiveRecord::Migration
2
+ def change
3
+ if ::ActiveRecord::Base.connection.instance_values["config"][:adapter] == 'postgresql'
4
+ execute('CREATE EXTENSION IF NOT EXISTS hstore;')
5
+
6
+ add_column :parties, :custom_fields, :hstore
7
+ add_hstore_index :parties, :custom_fields
8
+ else
9
+ add_column :parties, :custom_fields, :text
10
+ end
11
+ end
12
+ end
@@ -6,7 +6,8 @@ require "erp_base_erp_svcs/non_escape_json_string"
6
6
 
7
7
  module ErpBaseErpSvcs
8
8
  class << self
9
-
9
+ @@root_engine_loaded = false
10
+
10
11
  def installed_engines
11
12
  ErpBaseErpSvcs::Config.compass_ae_engines
12
13
  end
@@ -33,14 +34,13 @@ module ErpBaseErpSvcs
33
34
 
34
35
  def register_as_compass_ae_engine(config, engine)
35
36
  setup_compass_ae_callback(config, engine) do |engine|
36
- ErpBaseErpSvcs.load_compass_ae_engine(engine)
37
+ ErpBaseErpSvcs.load_compass_ae_engine(engine)
37
38
  end
38
39
  end
39
40
 
40
41
  def load_compass_ae_engine(engine)
41
42
  installed_engines << engine unless installed_engines.include?(engine)
42
43
  load_compass_ae_extensions(engine)
43
- load_root_compass_ae_framework_extensions
44
44
  end
45
45
 
46
46
  #forces rails to reload model extensions and framework extensions
@@ -112,7 +112,7 @@ module ErpBaseErpSvcs
112
112
  end
113
113
 
114
114
  def load_root_compass_ae_framework_extensions
115
- Dir.glob(File.join(Rails.root,"lib/extensions/compass_ae/**/*.rb")).each do |file|
115
+ Dir.glob(File.join(Rails.root,"lib/extensions/compass_ae/**/*.rb")).sort.each do |file|
116
116
  load file
117
117
  end
118
118
  end
@@ -121,4 +121,4 @@ module ErpBaseErpSvcs
121
121
  end
122
122
 
123
123
  #load the engine after this module is defined
124
- require "erp_base_erp_svcs/engine"
124
+ require "erp_base_erp_svcs/engine"