exact 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/exact/models/bank_account.rb +3 -3
- data/lib/exact/models/base.rb +8 -6
- data/lib/exact/models/cost_center.rb +3 -2
- data/lib/exact/models/cost_unit.rb +3 -2
- data/lib/exact/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a092cbb7141b2321d93b2e51967aab2ab1beb85
|
4
|
+
data.tar.gz: c1b18d831d1c400e9a6bdd7f3282c23b07c7e8e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d6efbc561217ca41cd31a953c7726ee24345364347b25b829e920ddff0e79534947f896c1c887e09af5ea6a6787832fedee133bd88bc151dbe4739606a752d3
|
7
|
+
data.tar.gz: 0a2ade87d1590a9594784a92cd97d814bf85292eaaf6e3e4570a5cadfffa0b6c8ed30199efcfda8e712d40de103452aaa73e50e3c5d129dd59f441081ae7297d
|
@@ -22,11 +22,11 @@ module Exact
|
|
22
22
|
attribute :Format, String
|
23
23
|
attribute :IBAN, String
|
24
24
|
attribute :ID, String
|
25
|
-
attribute :Main, Boolean
|
25
|
+
attribute :Main, Boolean, default: true
|
26
26
|
attribute :Modified, DateTime
|
27
27
|
attribute :Modifier, String
|
28
28
|
attribute :ModifierFullName, String
|
29
|
-
attribute :Type, String
|
30
|
-
attribute :TypeDescription, String
|
29
|
+
attribute :Type, String, default: 'A'
|
30
|
+
attribute :TypeDescription, String, default: 'Account'
|
31
31
|
end
|
32
32
|
end
|
data/lib/exact/models/base.rb
CHANGED
@@ -26,7 +26,9 @@ module Exact
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.exact_endpoint
|
29
|
-
|
29
|
+
name = Object.const_get("#{self}::EXACT_ENDPOINT") rescue nil
|
30
|
+
name = to_s.demodulize.pluralize.camelize unless name
|
31
|
+
name
|
30
32
|
end
|
31
33
|
|
32
34
|
def exact_endpoint
|
@@ -50,8 +52,8 @@ module Exact
|
|
50
52
|
end
|
51
53
|
|
52
54
|
def self.create(attributes: {}, client:)
|
53
|
-
exact_obj = Exactonline.const_get(
|
54
|
-
client.send("AddTo#{
|
55
|
+
exact_obj = Exactonline.const_get(exact_endpoint.singularize).new(attributes)
|
56
|
+
client.send("AddTo#{exact_endpoint}", exact_obj)
|
55
57
|
result = client.save_changes
|
56
58
|
result.map! { |obj| Exact.const_get("#{to_s.demodulize}Mapping").convert obj }
|
57
59
|
result.first
|
@@ -88,6 +90,7 @@ module Exact
|
|
88
90
|
end
|
89
91
|
|
90
92
|
def update(client:)
|
93
|
+
return false if guid.blank?
|
91
94
|
client.send(exact_endpoint).filter("#{exact_guid_attribute} eq guid'#{guid}'")
|
92
95
|
result = client.execute
|
93
96
|
return false unless result.any?
|
@@ -101,11 +104,10 @@ module Exact
|
|
101
104
|
end
|
102
105
|
|
103
106
|
def save(client:)
|
104
|
-
if guid.
|
107
|
+
if !guid.blank?
|
105
108
|
update(client: client)
|
106
109
|
else
|
107
|
-
|
108
|
-
self.attributes = result.attributes
|
110
|
+
self.attributes = self.class.create(attributes: attributes, client: client).attributes
|
109
111
|
self
|
110
112
|
end
|
111
113
|
end
|
data/lib/exact/version.rb
CHANGED