erp_base_erp_svcs 3.0.7 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/category.rb +2 -1
- data/app/models/category_classification.rb +2 -0
- data/app/models/compass_ae_instance.rb +1 -1
- data/app/models/contact.rb +34 -32
- data/app/models/contact_purpose.rb +6 -4
- data/app/models/contact_type.rb +3 -1
- data/app/models/currency.rb +6 -4
- data/app/models/descriptive_asset.rb +2 -0
- data/app/models/email_address.rb +2 -0
- data/app/models/geo_country.rb +2 -0
- data/app/models/geo_zone.rb +2 -0
- data/app/models/individual.rb +2 -0
- data/app/models/iso_country_code.rb +0 -1
- data/app/models/money.rb +1 -0
- data/app/models/note.rb +2 -0
- data/app/models/note_type.rb +2 -0
- data/app/models/organization.rb +2 -0
- data/app/models/party.rb +4 -3
- data/app/models/party_relationship.rb +6 -5
- data/app/models/party_role.rb +7 -5
- data/app/models/phone_number.rb +2 -0
- data/app/models/postal_address.rb +2 -0
- data/app/models/relationship_type.rb +7 -5
- data/app/models/role_type.rb +2 -0
- data/app/models/valid_note_type.rb +2 -0
- data/app/models/view_type.rb +2 -0
- data/db/data_migrations/20110913145838_setup_compass_ae_instance.rb +1 -1
- data/db/migrate/20080805000020_base_erp_services.rb +222 -222
- data/lib/erp_base_erp_svcs/engine.rb +2 -0
- data/lib/erp_base_erp_svcs/extensions/active_record/migration.rb +39 -0
- data/lib/erp_base_erp_svcs/extensions.rb +1 -2
- data/lib/erp_base_erp_svcs/version.rb +2 -2
- data/lib/erp_base_erp_svcs.rb +15 -15
- data/lib/tasks/erp_base_erp_svcs_tasks.rake +58 -23
- data/spec/dummy/config/application.rb +6 -0
- data/spec/dummy/config/environments/spec.rb +3 -0
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
- data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/migrate/20130107214414_base_erp_services.erp_base_erp_svcs.rb +461 -0
- data/spec/dummy/db/schema.rb +383 -0
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/spec.log +17576 -0
- data/spec/models/email_address_spec.rb +1 -1
- data/spec/models/party_spec.rb +19 -19
- data/spec/spec_helper.rb +14 -5
- metadata +70 -149
- data/db/migrate/20110913145329_create_compass_ae_instance.rb +0 -15
- data/db/migrate/upgrade/20110907171257_add_notes.rb +0 -63
- data/lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb +0 -46
- data/lib/erp_base_erp_svcs/extensions/active_record/migrator.rb +0 -76
data/app/models/category.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class Category < ActiveRecord::Base
|
2
2
|
acts_as_nested_set
|
3
|
-
|
3
|
+
|
4
|
+
attr_protected :created_at, :updated_at
|
4
5
|
|
5
6
|
belongs_to :category_record, :polymorphic => true
|
6
7
|
has_many :category_classifications, :dependent => :destroy
|
data/app/models/contact.rb
CHANGED
@@ -1,42 +1,44 @@
|
|
1
1
|
class Contact < ActiveRecord::Base
|
2
|
-
|
3
|
-
belongs_to :party
|
4
|
-
belongs_to :contact_mechanism, :polymorphic => true, :dependent => :destroy
|
5
|
-
|
6
|
-
#rather than carry our own description for the abstract -contact-, we'll
|
7
|
-
#delegate that call to the implementer of the -contact_mechanism- interface
|
8
|
-
|
9
|
-
def description
|
10
|
-
@description = contact_mechanism.description
|
11
|
-
end
|
2
|
+
attr_protected :created_at, :updated_at
|
12
3
|
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
has_and_belongs_to_many :contact_purposes
|
5
|
+
belongs_to :party
|
6
|
+
belongs_to :contact_mechanism, :polymorphic => true, :dependent => :destroy
|
16
7
|
|
17
|
-
|
18
|
-
|
8
|
+
#rather than carry our own description for the abstract -contact-, we'll
|
9
|
+
#delegate that call to the implementer of the -contact_mechanism- interface
|
19
10
|
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
def description
|
12
|
+
@description = contact_mechanism.description
|
13
|
+
end
|
23
14
|
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
def description=(d)
|
16
|
+
@description=d
|
17
|
+
end
|
27
18
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
19
|
+
#delegate our need to provide a label to scaffolds to the implementer of
|
20
|
+
#the -contact_mechanism- interface.
|
21
|
+
|
22
|
+
def to_label
|
23
|
+
"#{contact_mechanism.description}"
|
24
|
+
end
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
contact_purposes.each do |cp|
|
37
|
-
p << cp.description
|
38
|
-
end
|
26
|
+
def summary_line
|
27
|
+
"#{contact_mechanism.summary_line}"
|
28
|
+
end
|
39
29
|
|
40
|
-
|
30
|
+
# return first contact purpose
|
31
|
+
def purpose
|
32
|
+
contact_purposes.first.description
|
33
|
+
end
|
34
|
+
|
35
|
+
# return all contact purposes as an array
|
36
|
+
def purposes
|
37
|
+
p = []
|
38
|
+
contact_purposes.each do |cp|
|
39
|
+
p << cp.description
|
41
40
|
end
|
41
|
+
|
42
|
+
return p
|
43
|
+
end
|
42
44
|
end
|
data/app/models/contact_type.rb
CHANGED
data/app/models/currency.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
class Currency < ActiveRecord::Base
|
2
|
+
attr_protected :created_at, :updated_at
|
3
|
+
|
2
4
|
has_many :money
|
3
|
-
|
5
|
+
|
4
6
|
def symbol
|
5
7
|
major_unit_symbol
|
6
8
|
end
|
7
|
-
|
9
|
+
|
8
10
|
def self.usd
|
9
|
-
|
11
|
+
# Pull the usd currency from GeoCountry
|
10
12
|
find_by_internal_identifier("USD")
|
11
13
|
end
|
12
|
-
|
14
|
+
|
13
15
|
def self.blank
|
14
16
|
new
|
15
17
|
end
|
data/app/models/email_address.rb
CHANGED
data/app/models/geo_country.rb
CHANGED
data/app/models/geo_zone.rb
CHANGED
data/app/models/individual.rb
CHANGED
data/app/models/money.rb
CHANGED
data/app/models/note.rb
CHANGED
data/app/models/note_type.rb
CHANGED
data/app/models/organization.rb
CHANGED
data/app/models/party.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class Party < ActiveRecord::Base
|
2
|
+
attr_protected :created_at, :updated_at
|
3
|
+
|
2
4
|
has_notes
|
3
5
|
|
4
6
|
has_many :contacts, :dependent => :destroy
|
@@ -8,8 +10,6 @@ class Party < ActiveRecord::Base
|
|
8
10
|
has_many :party_roles, :dependent => :destroy #role_types
|
9
11
|
has_many :role_types, :through => :party_roles
|
10
12
|
|
11
|
-
has_and_belongs_to_many :security_roles
|
12
|
-
|
13
13
|
after_destroy :destroy_business_party
|
14
14
|
|
15
15
|
attr_reader :relationships
|
@@ -131,6 +131,7 @@ class Party < ActiveRecord::Base
|
|
131
131
|
contact_purposes = [contact_purposes] if !contact_purposes.kind_of?(Array) # gracefully handle a single purpose not in an array
|
132
132
|
contact = find_contact(contact_mechanism_class, contact_mechanism_args, contact_purposes)
|
133
133
|
if contact.nil?
|
134
|
+
contact_mechanism_args.delete_if{|k,v| ['created_at','updated_at'].include? k.to_s}
|
134
135
|
contact_mechanism = contact_mechanism_class.new(contact_mechanism_args)
|
135
136
|
contact_mechanism.contact.party = self
|
136
137
|
contact_mechanism.contact.contact_purposes = contact_purposes
|
@@ -187,7 +188,7 @@ class Party < ActiveRecord::Base
|
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
190
|
-
def respond_to?(m)
|
191
|
+
def respond_to?(m, include_private_methods = false)
|
191
192
|
(super ? true : get_contact_by_method(m.to_s)) rescue super
|
192
193
|
end
|
193
194
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class PartyRelationship < ActiveRecord::Base
|
2
|
+
attr_protected :created_at, :updated_at
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
belongs_to :from_party, :class_name => "Party", :foreign_key => "party_id_from"
|
5
|
+
belongs_to :to_party, :class_name => "Party", :foreign_key => "party_id_to"
|
6
|
+
belongs_to :from_role, :class_name => "RoleType", :foreign_key => "role_type_id_from"
|
7
|
+
belongs_to :to_role, :class_name => "RoleType", :foreign_key => "role_type_id_to"
|
8
|
+
belongs_to :relationship_type, :class_name => "RelationshipType"
|
8
9
|
|
9
10
|
end
|
data/app/models/party_role.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
class PartyRole < ActiveRecord::Base
|
2
|
-
|
3
|
-
belongs_to :role_type, :class_name => "RoleType", :foreign_key => "role_type_id"
|
2
|
+
attr_protected :created_at, :updated_at
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
belongs_to :party, :class_name => "Party", :foreign_key => "party_id"
|
5
|
+
belongs_to :role_type, :class_name => "RoleType", :foreign_key => "role_type_id"
|
6
|
+
|
7
|
+
def to_label
|
8
|
+
self.role_type.description
|
9
|
+
end
|
8
10
|
end
|
data/app/models/phone_number.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
class RelationshipType < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
attr_protected :created_at, :updated_at
|
3
|
+
|
4
|
+
acts_as_nested_set
|
5
|
+
acts_as_erp_type
|
6
|
+
|
7
|
+
belongs_to :valid_from_role, :class_name => "RoleType", :foreign_key => "valid_from_role_type_id"
|
8
|
+
belongs_to :valid_to_role, :class_name => "RoleType", :foreign_key => "valid_to_role_type_id"
|
7
9
|
end
|
data/app/models/role_type.rb
CHANGED
data/app/models/view_type.rb
CHANGED