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.
Files changed (51) hide show
  1. data/app/models/category.rb +2 -1
  2. data/app/models/category_classification.rb +2 -0
  3. data/app/models/compass_ae_instance.rb +1 -1
  4. data/app/models/contact.rb +34 -32
  5. data/app/models/contact_purpose.rb +6 -4
  6. data/app/models/contact_type.rb +3 -1
  7. data/app/models/currency.rb +6 -4
  8. data/app/models/descriptive_asset.rb +2 -0
  9. data/app/models/email_address.rb +2 -0
  10. data/app/models/geo_country.rb +2 -0
  11. data/app/models/geo_zone.rb +2 -0
  12. data/app/models/individual.rb +2 -0
  13. data/app/models/iso_country_code.rb +0 -1
  14. data/app/models/money.rb +1 -0
  15. data/app/models/note.rb +2 -0
  16. data/app/models/note_type.rb +2 -0
  17. data/app/models/organization.rb +2 -0
  18. data/app/models/party.rb +4 -3
  19. data/app/models/party_relationship.rb +6 -5
  20. data/app/models/party_role.rb +7 -5
  21. data/app/models/phone_number.rb +2 -0
  22. data/app/models/postal_address.rb +2 -0
  23. data/app/models/relationship_type.rb +7 -5
  24. data/app/models/role_type.rb +2 -0
  25. data/app/models/valid_note_type.rb +2 -0
  26. data/app/models/view_type.rb +2 -0
  27. data/db/data_migrations/20110913145838_setup_compass_ae_instance.rb +1 -1
  28. data/db/migrate/20080805000020_base_erp_services.rb +222 -222
  29. data/lib/erp_base_erp_svcs/engine.rb +2 -0
  30. data/lib/erp_base_erp_svcs/extensions/active_record/migration.rb +39 -0
  31. data/lib/erp_base_erp_svcs/extensions.rb +1 -2
  32. data/lib/erp_base_erp_svcs/version.rb +2 -2
  33. data/lib/erp_base_erp_svcs.rb +15 -15
  34. data/lib/tasks/erp_base_erp_svcs_tasks.rake +58 -23
  35. data/spec/dummy/config/application.rb +6 -0
  36. data/spec/dummy/config/environments/spec.rb +3 -0
  37. data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
  38. data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
  39. data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
  40. data/spec/dummy/db/migrate/20130107214414_base_erp_services.erp_base_erp_svcs.rb +461 -0
  41. data/spec/dummy/db/schema.rb +383 -0
  42. data/spec/dummy/db/spec.sqlite3 +0 -0
  43. data/spec/dummy/log/spec.log +17576 -0
  44. data/spec/models/email_address_spec.rb +1 -1
  45. data/spec/models/party_spec.rb +19 -19
  46. data/spec/spec_helper.rb +14 -5
  47. metadata +70 -149
  48. data/db/migrate/20110913145329_create_compass_ae_instance.rb +0 -15
  49. data/db/migrate/upgrade/20110907171257_add_notes.rb +0 -63
  50. data/lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb +0 -46
  51. data/lib/erp_base_erp_svcs/extensions/active_record/migrator.rb +0 -76
@@ -1,6 +1,7 @@
1
1
  class Category < ActiveRecord::Base
2
2
  acts_as_nested_set
3
- include ErpTechSvcs::Utils::DefaultNestedSetMethods
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
@@ -1,4 +1,6 @@
1
1
  class CategoryClassification < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  belongs_to :classification, :polymorphic => true
3
5
  belongs_to :category
4
6
  end
@@ -1,5 +1,5 @@
1
1
  class CompassAeInstance < ActiveRecord::Base
2
- has_file_assets
2
+ attr_protected :created_at, :updated_at
3
3
 
4
4
  def installed_engines
5
5
  Rails.application.config.erp_base_erp_svcs.compass_ae_engines.map do |compass_ae_engine|
@@ -1,42 +1,44 @@
1
1
  class Contact < ActiveRecord::Base
2
- has_and_belongs_to_many :contact_purposes
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
- def description=(d)
14
- @description=d
15
- end
4
+ has_and_belongs_to_many :contact_purposes
5
+ belongs_to :party
6
+ belongs_to :contact_mechanism, :polymorphic => true, :dependent => :destroy
16
7
 
17
- #delegate our need to provide a label to scaffolds to the implementer of
18
- #the -contact_mechanism- interface.
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
- def to_label
21
- "#{contact_mechanism.description}"
22
- end
11
+ def description
12
+ @description = contact_mechanism.description
13
+ end
23
14
 
24
- def summary_line
25
- "#{contact_mechanism.summary_line}"
26
- end
15
+ def description=(d)
16
+ @description=d
17
+ end
27
18
 
28
- # return first contact purpose
29
- def purpose
30
- contact_purposes.first.description
31
- end
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
- # return all contact purposes as an array
34
- def purposes
35
- p = []
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
- return p
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
@@ -1,6 +1,8 @@
1
1
  class ContactPurpose < ActiveRecord::Base
2
- acts_as_nested_set
3
- acts_as_erp_type
4
-
5
- has_and_belongs_to_many :contacts
2
+ attr_protected :created_at, :updated_at
3
+
4
+ acts_as_nested_set
5
+ acts_as_erp_type
6
+
7
+ has_and_belongs_to_many :contacts
6
8
  end
@@ -1,3 +1,5 @@
1
1
  class ContactType < ActiveRecord::Base
2
- acts_as_nested_set
2
+ attr_protected :created_at, :updated_at
3
+
4
+ acts_as_nested_set
3
5
  end
@@ -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
- # Pull the usd currency from GeoCountry
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
@@ -1,4 +1,6 @@
1
1
  class DescriptiveAsset < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  belongs_to :view_type
3
5
  belongs_to :described_record, :polymorphic => true
4
6
  end
@@ -1,4 +1,6 @@
1
1
  class EmailAddress < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  has_contact
3
5
 
4
6
  validates_format_of :email_address, :with => /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/, :message => "Must be a valid email address"
@@ -1,4 +1,6 @@
1
1
  class GeoCountry < ActiveRecord::Base
2
+ attr_accessible :name, :created_at, :external_id, :iso_code_2, :iso_code_3, :id, :display
3
+
2
4
  has_many :postal_addresses
3
5
  has_many :geo_zones
4
6
 
@@ -1,4 +1,6 @@
1
1
  class GeoZone < ActiveRecord::Base
2
+ attr_accessible :geo_country_id, :zone_code, :zone_name
3
+
2
4
  belongs_to :geo_country
3
5
  has_many :postal_addresses
4
6
 
@@ -1,4 +1,6 @@
1
1
  class Individual < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  require 'attr_encrypted'
3
5
 
4
6
  after_create :create_party
@@ -1,5 +1,4 @@
1
1
  class IsoCountryCode < GeoCountry
2
-
3
2
  has_many :currencies, :through => :locales
4
3
  # TODO validate identifier is iso alphabetic two digit code
5
4
 
data/app/models/money.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  class Money < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
2
3
 
3
4
  belongs_to :currency
4
5
  before_save :parse_currency_code
data/app/models/note.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  class Note < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  belongs_to :note_type
3
5
  belongs_to :noted_record, :polymorphic => true
4
6
  belongs_to :created_by, :class_name => 'Party', :foreign_key => 'created_by_id'
@@ -1,4 +1,6 @@
1
1
  class NoteType < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  acts_as_nested_set
3
5
  acts_as_erp_type
4
6
 
@@ -1,4 +1,6 @@
1
1
  class Organization < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  after_create :create_party
3
5
  after_save :save_party
4
6
  after_destroy :destroy_party
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
- belongs_to :from_party, :class_name => "Party", :foreign_key => "party_id_from"
4
- belongs_to :to_party, :class_name => "Party", :foreign_key => "party_id_to"
5
- belongs_to :from_role, :class_name => "RoleType", :foreign_key => "role_type_id_from"
6
- belongs_to :to_role, :class_name => "RoleType", :foreign_key => "role_type_id_to"
7
- belongs_to :relationship_type, :class_name => "RelationshipType"
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
@@ -1,8 +1,10 @@
1
1
  class PartyRole < ActiveRecord::Base
2
- belongs_to :party, :class_name => "Party", :foreign_key => "party_id"
3
- belongs_to :role_type, :class_name => "RoleType", :foreign_key => "role_type_id"
2
+ attr_protected :created_at, :updated_at
4
3
 
5
- def to_label
6
- self.role_type.description
7
- end
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
@@ -1,4 +1,6 @@
1
1
  class PhoneNumber < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  has_contact
3
5
 
4
6
  def summary_line
@@ -1,4 +1,6 @@
1
1
  class PostalAddress < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  has_contact
3
5
 
4
6
  belongs_to :geo_country
@@ -1,7 +1,9 @@
1
1
  class RelationshipType < ActiveRecord::Base
2
- acts_as_nested_set
3
- acts_as_erp_type
4
-
5
- belongs_to :valid_from_role, :class_name => "RoleType", :foreign_key => "valid_from_role_type_id"
6
- belongs_to :valid_to_role, :class_name => "RoleType", :foreign_key => "valid_to_role_type_id"
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
@@ -1,4 +1,6 @@
1
1
  class RoleType < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  acts_as_nested_set
3
5
  acts_as_erp_type
4
6
 
@@ -1,4 +1,6 @@
1
1
  class ValidNoteType < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  belongs_to :note_type
3
5
  belongs_to :valid_note_record, :polymorphic => true
4
6
  end
@@ -1,3 +1,5 @@
1
1
  class ViewType < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
2
4
  has_many :descriptive_assets
3
5
  end
@@ -1,7 +1,7 @@
1
1
  class SetupCompassAeInstance
2
2
 
3
3
  def self.up
4
- CompassAeInstance.create(version: 3.0)
4
+ CompassAeInstance.create(version: 3.1)
5
5
  end
6
6
 
7
7
  def self.down