activerecord_sqlserver_crm 4.2.16 → 4.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/crm/account.rb +1 -1
- data/app/models/crm/account_note.rb +5 -0
- data/app/models/crm/campaign.rb +1 -1
- data/app/models/crm/campaign_note.rb +5 -0
- data/app/models/crm/campaign_response.rb +1 -1
- data/app/models/crm/campaign_response_note.rb +5 -0
- data/app/models/crm/case.rb +1 -1
- data/app/models/crm/case_note.rb +5 -0
- data/app/models/crm/contact.rb +1 -1
- data/app/models/crm/contact_note.rb +5 -0
- data/app/models/crm/invoice.rb +1 -1
- data/app/models/crm/invoice_note.rb +5 -0
- data/app/models/crm/note.rb +4 -7
- data/app/models/crm/opportunity.rb +1 -1
- data/app/models/crm/opportunity_note.rb +5 -0
- data/lib/active_record_extension.rb +4 -3
- data/lib/activerecord_sqlserver_crm/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93c0eff44335f7842dde181e98c5e9426de30a49
|
4
|
+
data.tar.gz: d19ca3cb0226bf278dc369015b8b9852bea58ae6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1a7212f1b7b5de08c16e9e5556fc5a879d76e48141608452d19e66f2db571321a53fe4891a15d590894bc6ee73c8bdaf31a1d03826ece51d424d20ac55ee87
|
7
|
+
data.tar.gz: 6db9fcdd432ddac99002d602f9a4a6faadec9d7af6a5f338feb736f9642222226acaa779d7510c1e2302371000665e88f4837f414419463d6d51c7f4ab0751d3
|
data/app/models/crm/account.rb
CHANGED
@@ -3,7 +3,7 @@ module Crm
|
|
3
3
|
self.table_name = "Account"
|
4
4
|
self.primary_key = "AccountId"
|
5
5
|
|
6
|
-
has_many :notes, foreign_key: 'ObjectId'
|
6
|
+
has_many :notes, foreign_key: 'ObjectId', class_name: "Crm::AccountNote"
|
7
7
|
has_many :cases, foreign_key: 'AccountId'
|
8
8
|
|
9
9
|
validates :Name, presence: true
|
data/app/models/crm/campaign.rb
CHANGED
@@ -5,7 +5,7 @@ module Crm
|
|
5
5
|
|
6
6
|
belongs_to :currency, foreign_key: 'TransactionCurrencyId', crm_key: 'transactioncurrencyid'
|
7
7
|
|
8
|
-
has_many :notes, foreign_key: 'ObjectId'
|
8
|
+
has_many :notes, foreign_key: 'ObjectId', class_name: "Crm::CampaignNote"
|
9
9
|
has_many :campaign_responses, foreign_key: 'RegardingObjectId'
|
10
10
|
|
11
11
|
validates :Name, presence: true
|
@@ -5,7 +5,7 @@ module Crm
|
|
5
5
|
|
6
6
|
belongs_to :campaign, foreign_key: 'RegardingObjectId', crm_key: 'regardingobjectid_campaign_campaignresponse'
|
7
7
|
|
8
|
-
has_many :notes, foreign_key: 'ObjectId'
|
8
|
+
has_many :notes, foreign_key: 'ObjectId', class_name: "Crm::CampaignResponseNote"
|
9
9
|
|
10
10
|
validates :Subject, presence: true
|
11
11
|
validates :campaign, presence: true
|
data/app/models/crm/case.rb
CHANGED
@@ -6,7 +6,7 @@ module Crm
|
|
6
6
|
belongs_to :contact, foreign_key: 'ContactId', crm_key: 'customerid_contact'
|
7
7
|
belongs_to :account, foreign_key: 'AccountId', crm_key: 'customerid_account'
|
8
8
|
|
9
|
-
has_many :notes, foreign_key: 'ObjectId'
|
9
|
+
has_many :notes, foreign_key: 'ObjectId', class_name: "Crm::CaseNote"
|
10
10
|
|
11
11
|
validates :Title, presence: true
|
12
12
|
validate :contact_xor_account
|
data/app/models/crm/contact.rb
CHANGED
@@ -5,7 +5,7 @@ module Crm
|
|
5
5
|
|
6
6
|
has_many :cases, foreign_key: 'ContactId'
|
7
7
|
has_many :invoices, foreign_key: 'ContactId'
|
8
|
-
has_many :notes, foreign_key: 'ObjectId'
|
8
|
+
has_many :notes, foreign_key: 'ObjectId', class_name: "Crm::ContactNote"
|
9
9
|
|
10
10
|
validates :FirstName, presence: true
|
11
11
|
validates :LastName, presence: true
|
data/app/models/crm/invoice.rb
CHANGED
@@ -10,7 +10,7 @@ module Crm
|
|
10
10
|
belongs_to :currency, foreign_key: 'TransactionCurrencyId', crm_key: 'transactioncurrencyid'
|
11
11
|
|
12
12
|
has_many :invoice_products, foreign_key: 'InvoiceId'
|
13
|
-
has_many :notes, foreign_key: 'ObjectId'
|
13
|
+
has_many :notes, foreign_key: 'ObjectId', class_name: "Crm::InvoiceNote"
|
14
14
|
|
15
15
|
validates :Name, presence: true
|
16
16
|
validates :price_list, presence: true
|
data/app/models/crm/note.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
+
# This is treated as an abstract class. We cant use the same objectId as a foreign key for each Entity Type.
|
2
|
+
# To get around this issue we create a Note type for each Entity type. Each EntityNote contains only a single
|
3
|
+
# entry for the ObjectId.
|
1
4
|
module Crm
|
2
5
|
class Note < ActiveRecord::Base
|
3
6
|
self.table_name = "Annotation"
|
4
7
|
self.primary_key = "AnnotationId"
|
5
8
|
|
6
|
-
|
7
|
-
belongs_to :campaign, foreign_key: 'ObjectId', crm_key: 'objectid_campaign'
|
8
|
-
belongs_to :campaign_response, foreign_key: 'ObjectId', crm_key: 'objectid_campaignresponse'
|
9
|
-
belongs_to :case, foreign_key: 'ObjectId', crm_key: 'objectid_case'
|
10
|
-
belongs_to :contact, foreign_key: 'ObjectId', crm_key: 'objectid_contact'
|
11
|
-
belongs_to :invoice, foreign_key: 'ObjectId', crm_key: 'objectid_invoice'
|
12
|
-
belongs_to :opportunity, foreign_key: 'ObjectId', crm_key: 'objectid_opportunity'
|
9
|
+
# *** Dont add ObjectIds here. Foreign Keys must be unique
|
13
10
|
|
14
11
|
validates :Subject, presence: true
|
15
12
|
|
@@ -10,7 +10,7 @@ module Crm
|
|
10
10
|
belongs_to :parent_contact, foreign_key: 'ParentContactId', crm_key: 'parentcontactid', class_name: 'Crm::Contact'
|
11
11
|
|
12
12
|
has_many :invoices, foreign_key: 'OpportunityId'
|
13
|
-
has_many :notes, foreign_key: 'ObjectId'
|
13
|
+
has_many :notes, foreign_key: 'ObjectId', class_name: "Crm::OpportunityNote"
|
14
14
|
|
15
15
|
end
|
16
16
|
end
|
@@ -67,7 +67,9 @@ module ActiveRecordExtension
|
|
67
67
|
|
68
68
|
def belongs_to_field(field)
|
69
69
|
@belongs_to_fields ||= belongs_to_fields
|
70
|
-
@belongs_to_fields.select{|f| f.foreign_key == field}
|
70
|
+
matching_fields = @belongs_to_fields.select{|f| f.foreign_key == field}
|
71
|
+
raise "Multiple matching foreign_keys. Only unique foreign keys allowed [#{field}]" if matching_fields.count > 1
|
72
|
+
matching_fields.first
|
71
73
|
end
|
72
74
|
|
73
75
|
def belongs_to_field_by_name(name)
|
@@ -76,8 +78,7 @@ module ActiveRecordExtension
|
|
76
78
|
end
|
77
79
|
|
78
80
|
def belongs_to_fields
|
79
|
-
|
80
|
-
associations.select { |a| a.macro == :belongs_to }
|
81
|
+
reflect_on_all_associations(:belongs_to)
|
81
82
|
end
|
82
83
|
|
83
84
|
# If odata refers to table differently than table name when using associations, you can use this method
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_sqlserver_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rolf Lawrenz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -136,15 +136,22 @@ files:
|
|
136
136
|
- README.rdoc
|
137
137
|
- Rakefile
|
138
138
|
- app/models/crm/account.rb
|
139
|
+
- app/models/crm/account_note.rb
|
139
140
|
- app/models/crm/campaign.rb
|
141
|
+
- app/models/crm/campaign_note.rb
|
140
142
|
- app/models/crm/campaign_response.rb
|
143
|
+
- app/models/crm/campaign_response_note.rb
|
141
144
|
- app/models/crm/case.rb
|
145
|
+
- app/models/crm/case_note.rb
|
142
146
|
- app/models/crm/contact.rb
|
147
|
+
- app/models/crm/contact_note.rb
|
143
148
|
- app/models/crm/currency.rb
|
144
149
|
- app/models/crm/invoice.rb
|
150
|
+
- app/models/crm/invoice_note.rb
|
145
151
|
- app/models/crm/invoice_product.rb
|
146
152
|
- app/models/crm/note.rb
|
147
153
|
- app/models/crm/opportunity.rb
|
154
|
+
- app/models/crm/opportunity_note.rb
|
148
155
|
- app/models/crm/price_list.rb
|
149
156
|
- app/models/crm/price_list_item.rb
|
150
157
|
- app/models/crm/product.rb
|