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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58f5d55f80f886812ebcd10bee5a4685bcf0ded4
4
- data.tar.gz: 2118671c90509972b88871cc3b126e6d9511aa22
3
+ metadata.gz: 56cc4e33a17be02061fd797451ea601d4f78b132
4
+ data.tar.gz: 40660f517f298f71a484ea136a71d8756e27b026
5
5
  SHA512:
6
- metadata.gz: 94fae9165910482746862c27512a9fe967d86a5386e7e246f9c65d4d1593aef562b59c1f3c84f806661323f3ee6e352fbf3dc6c0e79b8245d85fde41467ff14e
7
- data.tar.gz: b35ceec6e79c81afdfc9f5b9816ca26c9dc78b11e4c29be858503268bcd22689dfcbef01c40ff938989cacdf2cb9532af99791e7ebaedb84a5026fb27b096e7a
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.
@@ -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'
@@ -1 +1,2 @@
1
1
  require "active_record_extension"
2
+ require "big_decimal"
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module ActiverecordSqlserverCrm
2
- VERSION = "4.2.1"
2
+ VERSION = "4.2.2"
3
3
  end
@@ -0,0 +1,9 @@
1
+ class BigDecimal
2
+ def as_json(options = nil) #:nodoc:
3
+ if finite?
4
+ self.to_f
5
+ else
6
+ NilClass::AS_JSON
7
+ end
8
+ end
9
+ end
@@ -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
- body["#{belongs_to_field.options[:crm_key]}@odata.bind"] = "/#{belongs_to_field.class_name.downcase}s(#{values[1]})"
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
@@ -26,7 +26,7 @@ module OData
26
26
  end
27
27
 
28
28
  def entity_name
29
- "#{@ar.class.table_name.downcase}s"
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.1
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-06-29 00:00:00.000000000 Z
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