erp_base_erp_svcs 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 (85) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v1/base_controller.rb +17 -0
  3. data/app/controllers/api/v1/categories_controller.rb +165 -0
  4. data/app/controllers/api/v1/contact_purposes_controller.rb +24 -0
  5. data/app/controllers/api/v1/geo_zones_controller.rb +25 -0
  6. data/app/controllers/api/v1/note_types_controller.rb +27 -0
  7. data/app/controllers/api/v1/parties_controller.rb +182 -0
  8. data/app/controllers/api/v1/role_types_controller.rb +146 -0
  9. data/app/controllers/api/v1/status_applications_controller.rb +40 -0
  10. data/app/controllers/api/v1/tracked_status_types_controller.rb +146 -0
  11. data/app/controllers/api/v1/unit_of_measurements_controller.rb +16 -0
  12. data/app/models/category.rb +116 -4
  13. data/app/models/contact.rb +16 -2
  14. data/app/models/contact_purpose.rb +13 -0
  15. data/app/models/descriptive_asset.rb +17 -0
  16. data/app/models/email_address.rb +21 -3
  17. data/app/models/entity_party_role.rb +8 -0
  18. data/app/models/fixed_asset.rb +2 -0
  19. data/app/models/fixed_asset_type.rb +1 -0
  20. data/app/models/generated_item.rb +17 -0
  21. data/app/models/geo_country.rb +12 -1
  22. data/app/models/individual.rb +11 -20
  23. data/app/models/note.rb +9 -0
  24. data/app/models/note_type.rb +2 -0
  25. data/app/models/organization.rb +19 -16
  26. data/app/models/party.rb +134 -229
  27. data/app/models/party_unit_of_measurement.rb +17 -1
  28. data/app/models/phone_number.rb +32 -12
  29. data/app/models/postal_address.rb +42 -11
  30. data/app/models/relationship_type.rb +28 -1
  31. data/app/models/role_type.rb +25 -2
  32. data/app/models/status_application.rb +40 -0
  33. data/app/models/tracked_status_type.rb +12 -0
  34. data/app/models/unit_of_measurement.rb +46 -7
  35. data/app/models/view_type.rb +14 -0
  36. data/config/routes.rb +24 -0
  37. data/db/data_migrations/20110913145838_setup_compass_ae_instance.rb +22 -9
  38. data/db/migrate/20080805000020_base_erp_services.rb +235 -6
  39. data/db/migrate/20130713171653_create_party_unit_of_measurements.rb +28 -0
  40. data/db/migrate/20150716201200_add_record_to_contact.rb +42 -0
  41. data/db/migrate/20150814202823_add_party_id_to_status_application.rb +10 -0
  42. data/db/migrate/20160310163040_add_created_by_updated_by_to_erp_base_erp_svcs.rb +44 -0
  43. data/lib/erp_base_erp_svcs.rb +1 -0
  44. data/lib/erp_base_erp_svcs/config.rb +3 -2
  45. data/lib/erp_base_erp_svcs/engine.rb +8 -1
  46. data/lib/erp_base_erp_svcs/extensions.rb +7 -1
  47. data/lib/erp_base_erp_svcs/extensions/active_record/acts_as_category.rb +5 -4
  48. data/lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb +48 -9
  49. data/lib/erp_base_erp_svcs/extensions/active_record/can_be_generated.rb +54 -0
  50. data/lib/erp_base_erp_svcs/extensions/active_record/has_contacts.rb +383 -0
  51. data/lib/erp_base_erp_svcs/extensions/active_record/has_notes.rb +15 -4
  52. data/lib/erp_base_erp_svcs/extensions/active_record/has_party_roles.rb +94 -0
  53. data/lib/erp_base_erp_svcs/extensions/active_record/has_tracked_status.rb +118 -35
  54. data/lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb +94 -0
  55. data/lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb +46 -42
  56. data/lib/erp_base_erp_svcs/extensions/active_record/is_tenantable.rb +40 -0
  57. data/lib/erp_base_erp_svcs/extensions/active_record/tracks_created_by_updated_by.rb +39 -0
  58. data/lib/erp_base_erp_svcs/extensions/core/numbers.rb +29 -18
  59. data/lib/erp_base_erp_svcs/extensions/core/object.rb +5 -0
  60. data/lib/erp_base_erp_svcs/extensions/core/string.rb +53 -0
  61. data/lib/erp_base_erp_svcs/non_escape_json_string.rb +1 -1
  62. data/lib/erp_base_erp_svcs/time_zone_helper.rb +57 -0
  63. data/lib/erp_base_erp_svcs/version.rb +1 -1
  64. data/lib/tasks/erp_base_erp_svcs_tasks.rake +20 -23
  65. data/spec/dummy/log/development.log +3 -0
  66. metadata +29 -22
  67. data/db/data_migrations/20110525001935_add_usd_currency.rb +0 -11
  68. data/db/data_migrations/20110609150135_add_iso_codes.rb +0 -18
  69. data/db/data_migrations/20130211555555_upgrade_compass_ae_instances_data.rb +0 -18
  70. data/db/data_migrations/20130404201756_add_guid_to_instances.rb +0 -9
  71. data/db/migrate/20120606183856_add_txn_status.rb +0 -36
  72. data/db/migrate/20130211444444_upgrade_compass_ae_instances.rb +0 -33
  73. data/db/migrate/20130404171435_add_uuid_compass_ae_instance.rb +0 -16
  74. data/db/migrate/20130411125210_add_long_lat_to_address.rb +0 -15
  75. data/db/migrate/20130522125404_create_facilities.rb +0 -114
  76. data/db/migrate/20130621182047_create_unit_of_measurements.rb +0 -18
  77. data/db/migrate/20130909163912_add_iid_index_to_role_types.rb +0 -9
  78. data/db/migrate/20130926023541_add_domain_to_unit_of_measure.rb +0 -13
  79. data/db/migrate/20130929025342_add_type_semantics_to_uom.rb +0 -54
  80. data/db/migrate/20131112013047_add_primary_to_contacts.rb +0 -13
  81. data/db/migrate/20131112013048_add_erp_base_erp_svcs_missing_indexes.rb +0 -33
  82. data/db/migrate/20131211180831_add_postal_address_to_facility.rb +0 -5
  83. data/db/migrate/20140102154311_create_fixed_asset_party_roles.rb +0 -12
  84. data/db/migrate/20140401072612_add_custom_fields_to_party.rb +0 -12
  85. data/lib/erp_base_erp_svcs/extensions/active_record/has_contact.rb +0 -69
@@ -1,11 +0,0 @@
1
- class AddUsdCurrency
2
-
3
- def self.up
4
- Currency.create(:name => 'US Dollar', :internal_identifier => 'USD', :major_unit_symbol => "$")
5
- end
6
-
7
- def self.down
8
- Currency.usd.destroy
9
- end
10
-
11
- end
@@ -1,18 +0,0 @@
1
- require 'yaml'
2
-
3
- class AddIsoCodes
4
-
5
- def self.up
6
- #find the erp_base_erp_svcs engine
7
- engine_path = Rails::Application::Railties.engines.find{|item| item.engine_name == 'erp_base_erp_svcs'}.config.root.to_s
8
-
9
- GeoCountry.load_from_file(File.join(engine_path,'db/data_sets/geo_countries.yml'))
10
- GeoZone.load_from_file(File.join(engine_path,'db/data_sets/geo_zones.yml'))
11
- end
12
-
13
- def self.down
14
- GeoCountry.delete_all
15
- GeoZone.delete_all
16
- end
17
-
18
- end
@@ -1,18 +0,0 @@
1
- class UpgradeCompassAeInstancesData < ActiveRecord::Migration
2
- def self.up
3
- if CompassAeInstance.find_by_internal_identifier('base').nil?
4
- c = CompassAeInstance.order('id ASC').first
5
- c.description = 'Base CompassAE Instance'
6
- c.internal_identifier = 'base'
7
- c.schema = 'public'
8
- c.save
9
- end
10
-
11
- if RoleType.find_by_internal_identifier('compass_ae_instance_owner').nil?
12
- rt = RoleType.new
13
- rt.description = 'CompassAE Instance Owner'
14
- rt.internal_identifier = 'compass_ae_instance_owner'
15
- rt.save
16
- end
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- class AddGuidToInstances
2
-
3
- def self.up
4
- CompassAeInstance.all.each do |instance|
5
- instance.setup_guid
6
- end
7
- end
8
-
9
- end
@@ -1,36 +0,0 @@
1
- class AddTxnStatus < ActiveRecord::Migration
2
- def up
3
- unless table_exists?(:status_applications)
4
- create_table :status_applications do |t|
5
- t.references :tracked_status_type
6
- t.references :status_application_record, :polymorphic => true
7
- t.datetime :from_date
8
- t.datetime :thru_date
9
-
10
- t.timestamps
11
- end
12
-
13
- add_index :status_applications, [:status_application_record_id, :status_application_record_type], :name => 'status_applications_record_idx'
14
- add_index :status_applications, :tracked_status_type_id, :name => 'tracked_status_type_id_idx'
15
- add_index :status_applications, :from_date, :name => 'from_date_idx'
16
- add_index :status_applications, :thru_date, :name => 'thru_date_idx'
17
- end
18
-
19
- unless table_exists?(:tracked_status_types)
20
- create_table :tracked_status_types do |t|
21
- t.string :description
22
- t.string :internal_identifier
23
- t.string :external_identifier
24
-
25
- t.timestamps
26
- end
27
-
28
- add_index :tracked_status_types, :internal_identifier, :name => 'tracked_status_types_iid_idx'
29
- end
30
- end
31
-
32
- def down
33
- drop_table :status_applications if table_exists?(:status_applications)
34
- drop_table :tracked_status_types if table_exists?(:tracked_status_types)
35
- end
36
- end
@@ -1,33 +0,0 @@
1
- # This migration comes from erp_base_erp_svcs (originally 20130211444444)
2
- class UpgradeCompassAeInstances < ActiveRecord::Migration
3
- def self.up
4
- unless columns(:compass_ae_instances).collect {|c| c.name}.include?('type')
5
- add_column :compass_ae_instances, :description, :string
6
- add_column :compass_ae_instances, :internal_identifier, :string
7
- add_column :compass_ae_instances, :type, :string
8
- add_column :compass_ae_instances, :schema, :string, :default => 'public'
9
- add_column :compass_ae_instances, :parent_id, :integer
10
-
11
- add_index :compass_ae_instances, :internal_identifier, :name => "iid_idx"
12
- add_index :compass_ae_instances, :schema, :name => "schema_idx"
13
- add_index :compass_ae_instances, :type, :name => "type_idx"
14
- add_index :compass_ae_instances, :parent_id, :name => "parent_id_idx"
15
- end
16
- end
17
-
18
- unless table_exists?(:compass_ae_instance_party_roles)
19
- create_table :compass_ae_instance_party_roles do |t|
20
- t.string :description
21
- t.integer :compass_ae_instance_id
22
- t.integer :party_id
23
- t.integer :role_type_id
24
-
25
- t.timestamps
26
- end
27
-
28
- add_index :compass_ae_instance_party_roles, :compass_ae_instance_id, :name => "compass_ae_instance_id_idx"
29
- add_index :compass_ae_instance_party_roles, :party_id, :name => "party_id_idx"
30
- add_index :compass_ae_instance_party_roles, :role_type_id, :name => "role_type_id_idx"
31
- end
32
-
33
- end
@@ -1,16 +0,0 @@
1
- require 'uuid'
2
-
3
- class AddUuidCompassAeInstance < ActiveRecord::Migration
4
- def self.up
5
- unless columns(:compass_ae_instances).collect {|c| c.name}.include?('guid')
6
- add_column :compass_ae_instances, :guid, :string
7
- add_index :compass_ae_instances, :guid, :name => "guid_idx"
8
- end
9
- end
10
-
11
- def self.down
12
- if columns(:compass_ae_instances).collect {|c| c.name}.include?('guid')
13
- remove_column :compass_ae_instances, :guid
14
- end
15
- end
16
- end
@@ -1,15 +0,0 @@
1
- class AddLongLatToAddress < ActiveRecord::Migration
2
- def up
3
- unless columns(:postal_addresses).collect {|c| c.name}.include?('latitude')
4
- add_column :postal_addresses, :latitude, :decimal, :precision => 12, :scale => 8
5
- add_column :postal_addresses, :longitude, :decimal, :precision => 12, :scale => 8
6
- end
7
- end
8
-
9
- def down
10
- if columns(:postal_addresses).collect {|c| c.name}.include?('latitude')
11
- remove_column :postal_addresses, :latitude
12
- remove_column :postal_addresses, :longitude
13
- end
14
- end
15
- end
@@ -1,114 +0,0 @@
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
@@ -1,18 +0,0 @@
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
@@ -1,9 +0,0 @@
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
@@ -1,13 +0,0 @@
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
@@ -1,54 +0,0 @@
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
@@ -1,13 +0,0 @@
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
@@ -1,33 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- class AddPostalAddressToFacility < ActiveRecord::Migration
2
- def change
3
- add_column :facilities, :postal_address_id, :integer
4
- end
5
- end
@@ -1,12 +0,0 @@
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