activerecord_sqlserver_crm 4.2.1 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +10 -2
- data/app/models/crm/invoice.rb +1 -0
- data/config/initializers/extensions.rb +1 -0
- data/lib/active_record_extension.rb +9 -0
- data/lib/activerecord_sqlserver_crm/version.rb +1 -1
- data/lib/big_decimal.rb +9 -0
- data/lib/odata/create_operation.rb +2 -1
- data/lib/odata/operation.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56cc4e33a17be02061fd797451ea601d4f78b132
|
4
|
+
data.tar.gz: 40660f517f298f71a484ea136a71d8756e27b026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4994e5a739fa5a9e865cb78e8e00e705bacc9213f0c46b1d85f3a1ed09c1fd9fb18c2b5d6d023a46198b80c3563df895d1988aac25e7ae86c00638b7333ebec2
|
7
|
+
data.tar.gz: f419c76f57b1202eaadc4a072d5dd5447182c3531345296114f342331a802cbb2a451b86c844c7310e1f0d2e61c3036aa0782222f48a5f5fd201f3758d301946
|
data/README.rdoc
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
-
= ActiverecordSqlserverCrm
|
1
|
+
= ActiverecordSqlserverCrm Developer Guide:
|
2
|
+
|
3
|
+
== Building gem
|
4
|
+
|
5
|
+
gem build activerecord_sqlserver_crm.gemspec
|
6
|
+
|
7
|
+
== Publishing gem
|
8
|
+
|
9
|
+
gem push activerecord_sqlserver_crm-0.0.1.gem
|
10
|
+
|
2
11
|
|
3
|
-
This project rocks and uses MIT-LICENSE.
|
data/app/models/crm/invoice.rb
CHANGED
@@ -6,6 +6,7 @@ module Crm
|
|
6
6
|
belongs_to :account, foreign_key: 'AccountId', crm_key: 'customerid_account'
|
7
7
|
belongs_to :contact, foreign_key: 'ContactId', crm_key: 'customerid_contact'
|
8
8
|
belongs_to :price_list, foreign_key: 'PriceLevelId', crm_key: 'pricelevelid'
|
9
|
+
belongs_to :currency, foreign_key: 'TransactionCurrencyId', crm_key: 'transactioncurrencyid'
|
9
10
|
|
10
11
|
has_many :invoice_products, foreign_key: 'InvoiceId'
|
11
12
|
has_many :notes, foreign_key: 'ObjectId'
|
@@ -73,6 +73,15 @@ module ActiveRecordExtension
|
|
73
73
|
associations = reflect_on_all_associations
|
74
74
|
associations.select { |a| a.macro == :belongs_to }
|
75
75
|
end
|
76
|
+
|
77
|
+
# If odata referes to table differently than table name when using associations, you can use this method
|
78
|
+
def odata_table_reference
|
79
|
+
@odata_table_reference
|
80
|
+
end
|
81
|
+
|
82
|
+
def odata_table_reference=(value)
|
83
|
+
@odata_table_reference = value
|
84
|
+
end
|
76
85
|
end
|
77
86
|
end
|
78
87
|
|
data/lib/big_decimal.rb
ADDED
@@ -20,7 +20,8 @@ module OData
|
|
20
20
|
# If a belongs to field, add association the way OData wants it
|
21
21
|
if @ar.class.belongs_to_field?(field)
|
22
22
|
belongs_to_field = @ar.class.belongs_to_field(field)
|
23
|
-
|
23
|
+
odata_table_ref = @ar.class.odata_table_reference || table_pluralize(belongs_to_field.table_name).downcase
|
24
|
+
body["#{belongs_to_field.options[:crm_key]}@odata.bind"] = "/#{odata_table_ref}(#{values[1]})"
|
24
25
|
else
|
25
26
|
body[field.downcase] = values[1]
|
26
27
|
end
|
data/lib/odata/operation.rb
CHANGED
@@ -26,7 +26,7 @@ module OData
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def entity_name
|
29
|
-
|
29
|
+
table_pluralize(@ar.class.table_name).downcase
|
30
30
|
end
|
31
31
|
|
32
32
|
def handle_operation_response(response)
|
@@ -64,6 +64,10 @@ module OData
|
|
64
64
|
ODATA_CONFIG[Rails.env]['username']
|
65
65
|
end
|
66
66
|
|
67
|
+
def table_pluralize(name)
|
68
|
+
name.end_with?('s') ? "#{name}es" : name.pluralize
|
69
|
+
end
|
70
|
+
|
67
71
|
def run
|
68
72
|
response = send_odata
|
69
73
|
handle_operation_response(response)
|
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.2
|
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-
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/activerecord_sqlserver_crm.rb
|
144
144
|
- lib/activerecord_sqlserver_crm/engine.rb
|
145
145
|
- lib/activerecord_sqlserver_crm/version.rb
|
146
|
+
- lib/big_decimal.rb
|
146
147
|
- lib/odata/create_operation.rb
|
147
148
|
- lib/odata/delete_operation.rb
|
148
149
|
- lib/odata/model.rb
|