intacctrb 0.2.1pre → 0.3pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/intacctrb.rb +1 -0
- data/lib/intacctrb/account.rb +39 -0
- data/lib/intacctrb/base.rb +24 -1
- data/lib/intacctrb/bill.rb +45 -41
- data/lib/intacctrb/vendor.rb +16 -20
- data/lib/intacctrb/version.rb +1 -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: b8ccb356ac2c6933b8dad65d7e8135345c321228
|
4
|
+
data.tar.gz: 75032daf9956d8a9b8f1aa12a87fd965e4904cb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6439c42ff5ba6be1732f5be37f9dabc40297feaa145b42d812f8f8e14f7d27c1b51f24628f32e889c70233ebb92305cd599c039e190d585dbdabfa67a288b9c
|
7
|
+
data.tar.gz: 9d58bca5fd26d4e1458ff0f139cb3a6cc11fdd53b644f76ebcf22681c8036c9f5079a35fb8fdd57bcbbb9d6db6a9456345a4d29a94dc3cd28fab5e43ddfad9d1
|
data/Gemfile.lock
CHANGED
data/lib/intacctrb.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
module IntacctRB
|
2
|
+
class Account < IntacctRB::Base
|
3
|
+
def get_list(options = {})
|
4
|
+
send_xml('get_list') do |xml|
|
5
|
+
xml.function(controlid: "f4") {
|
6
|
+
xml.get_list(object: "glaccount", maxitems: (options[:max_items] || 0),
|
7
|
+
start: (options[:start] || 0), showprivate:"true") {
|
8
|
+
filter_xml(xml, options)
|
9
|
+
if options[:fields]
|
10
|
+
xml.fields {
|
11
|
+
fields.each do |field|
|
12
|
+
xml.field field.to_s
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
}
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
if successful?
|
21
|
+
@data = []
|
22
|
+
@response.xpath('//glaccount').each do |account|
|
23
|
+
@data << OpenStruct.new({
|
24
|
+
id: account.at("glaccountno").content,
|
25
|
+
name: account.at("title").content,
|
26
|
+
normal_balance: account.at("normalbalance").content,
|
27
|
+
account_type: account.at("accounttype").content,
|
28
|
+
closing_type: account.at("closingtype").content,
|
29
|
+
updated_at: account.at("whenmodified").content,
|
30
|
+
status: account.at("status").content
|
31
|
+
})
|
32
|
+
end
|
33
|
+
@data
|
34
|
+
else
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/intacctrb/base.rb
CHANGED
@@ -14,7 +14,10 @@ module IntacctRB
|
|
14
14
|
attr_accessor :response, :data, :sent_xml, :intacct_action
|
15
15
|
|
16
16
|
def initialize *params
|
17
|
-
|
17
|
+
if params[0].is_a? Hash
|
18
|
+
json_data = params[0].to_json
|
19
|
+
params[0] = JSON.parse(json_data, object_class: OpenStruct)
|
20
|
+
end
|
18
21
|
params[0] ||= OpenStruct.new()
|
19
22
|
super(*params)
|
20
23
|
end
|
@@ -108,5 +111,25 @@ module IntacctRB
|
|
108
111
|
end
|
109
112
|
end
|
110
113
|
end
|
114
|
+
|
115
|
+
def filter_xml(xml, options)
|
116
|
+
if options[:filters]
|
117
|
+
xml.filter {
|
118
|
+
options[:filters].each do |filter|
|
119
|
+
xml.expression do
|
120
|
+
xml.field(filter[:field])
|
121
|
+
xml.operator(filter[:operator] || '=')
|
122
|
+
xml.value(filter[:value])
|
123
|
+
end
|
124
|
+
end
|
125
|
+
}
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def date_xml(xml, date)
|
130
|
+
xml.year date.to_date.strftime("%Y")
|
131
|
+
xml.month date.to_date.strftime("%m")
|
132
|
+
xml.day date.to_date.strftime("%d")
|
133
|
+
end
|
111
134
|
end
|
112
135
|
end
|
data/lib/intacctrb/bill.rb
CHANGED
@@ -4,30 +4,30 @@ module IntacctRB
|
|
4
4
|
define_hook :custom_bill_fields, :bill_item_fields
|
5
5
|
|
6
6
|
def create
|
7
|
-
return false if object.
|
7
|
+
return false if object.intacct_system_id.present?
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
send_xml('create') do |xml|
|
10
|
+
xml.function(controlid: "f1") {
|
11
|
+
xml.create {
|
12
|
+
xml.apbill {
|
13
|
+
bill_xml xml
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
intacct_vendor = Intacct::Vendor.new object.vendor
|
20
|
-
if intacct_vendor.create
|
21
|
-
object.vendor = intacct_vendor.object
|
22
|
-
else
|
23
|
-
raise 'Could not create vendor'
|
24
|
-
end
|
25
|
-
end
|
19
|
+
successful?
|
20
|
+
end
|
26
21
|
|
27
|
-
|
22
|
+
def update
|
23
|
+
raise 'You must pass an id to update a bill' unless object.intacct_id.present?
|
24
|
+
|
25
|
+
send_xml('update') do |xml|
|
28
26
|
xml.function(controlid: "f1") {
|
29
|
-
xml.
|
30
|
-
|
27
|
+
xml.update {
|
28
|
+
xml.apbill(key: object.intacct_id) {
|
29
|
+
bill_xml xml
|
30
|
+
}
|
31
31
|
}
|
32
32
|
}
|
33
33
|
end
|
@@ -36,7 +36,7 @@ module IntacctRB
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def delete
|
39
|
-
# return false unless object.
|
39
|
+
# return false unless object.intacct_system_id.present?
|
40
40
|
|
41
41
|
send_xml('delete') do |xml|
|
42
42
|
xml.function(controlid: "1") {
|
@@ -112,46 +112,50 @@ module IntacctRB
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def intacct_object_id
|
115
|
-
"#{intacct_bill_prefix}#{object.
|
115
|
+
"#{intacct_bill_prefix}#{object.id}"
|
116
116
|
end
|
117
117
|
|
118
118
|
def bill_xml xml
|
119
|
-
xml.
|
120
|
-
xml.
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
xml.
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
119
|
+
xml.recordno object.intacct_id
|
120
|
+
xml.vendorid object.vendor_id
|
121
|
+
xml.whenposted object.posted_at
|
122
|
+
xml.whencreated object.invoice_date
|
123
|
+
xml.whendue object.due_date
|
124
|
+
xml.action object.action
|
125
|
+
xml.recordid object.record_id
|
126
|
+
|
127
|
+
xml.apbillitems {
|
128
|
+
object.line_items.each do |line_item|
|
129
|
+
xml.apbillitem {
|
130
|
+
xml.accountno line_item.account_number
|
131
|
+
xml.amount line_item.amount
|
132
|
+
xml.entrydescription line_item.memo
|
133
|
+
xml.locationid line_item.location_id
|
134
|
+
xml.projectid line_item.provider_id
|
135
|
+
}
|
136
|
+
end
|
134
137
|
}
|
138
|
+
|
135
139
|
run_hook :custom_bill_fields, xml
|
136
140
|
run_hook :bill_item_fields, xml
|
137
141
|
end
|
138
142
|
|
139
143
|
def set_intacct_system_id
|
140
|
-
object.
|
144
|
+
object.intacct_system_id = intacct_object_id
|
141
145
|
end
|
142
146
|
|
143
147
|
def delete_intacct_system_id
|
144
|
-
object.
|
148
|
+
object.intacct_system_id = nil
|
145
149
|
end
|
146
150
|
|
147
151
|
def delete_intacct_key
|
148
|
-
object.
|
152
|
+
object.intacct_key = nil
|
149
153
|
end
|
150
154
|
|
151
155
|
def set_date_time type
|
152
156
|
if %w(create update delete).include? type
|
153
|
-
if object.
|
154
|
-
object.
|
157
|
+
if object.respond_to? :"intacct_#{type}d_at"
|
158
|
+
object.send("intacct_#{type}d_at=", DateTime.now)
|
155
159
|
end
|
156
160
|
end
|
157
161
|
end
|
data/lib/intacctrb/vendor.rb
CHANGED
@@ -10,7 +10,11 @@ module IntacctRB
|
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
13
|
-
successful?
|
13
|
+
if !successful?
|
14
|
+
raise(response.at('//error//description2'));
|
15
|
+
end
|
16
|
+
|
17
|
+
true
|
14
18
|
end
|
15
19
|
|
16
20
|
def update updated_vendor = false
|
@@ -46,17 +50,7 @@ module IntacctRB
|
|
46
50
|
xml.function(controlid: "f4") {
|
47
51
|
xml.get_list(object: "vendor", maxitems: (options[:max_items] || 0),
|
48
52
|
start: (options[:start] || 0), showprivate:"true") {
|
49
|
-
|
50
|
-
xml.filter {
|
51
|
-
options[:filters].each do |filter|
|
52
|
-
xml.expression do
|
53
|
-
filter.each_pair do |k,v|
|
54
|
-
xml.send(k,v)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
}
|
59
|
-
end
|
53
|
+
filter_xml(xml, options)
|
60
54
|
if options[:fields]
|
61
55
|
xml.fields {
|
62
56
|
fields.each do |field|
|
@@ -70,14 +64,14 @@ module IntacctRB
|
|
70
64
|
|
71
65
|
if successful?
|
72
66
|
@data = []
|
73
|
-
@response.xpath('//vendor').each do |
|
67
|
+
@response.xpath('//vendor').each do |vendor|
|
74
68
|
@data << OpenStruct.new({
|
75
|
-
id:
|
76
|
-
name:
|
77
|
-
tax_id:
|
78
|
-
total_due:
|
79
|
-
billing_type:
|
80
|
-
vendor_account_number:
|
69
|
+
id: vendor.at("vendorid").content,
|
70
|
+
name: vendor.at("name").content,
|
71
|
+
tax_id: vendor.at("taxid").content,
|
72
|
+
total_due: vendor.at("totaldue").content,
|
73
|
+
billing_type: vendor.at("billingtype").content,
|
74
|
+
vendor_account_number: vendor.at("vendoraccountno").content
|
81
75
|
})
|
82
76
|
end
|
83
77
|
@data
|
@@ -97,9 +91,11 @@ module IntacctRB
|
|
97
91
|
xml.taxid object.tax_id
|
98
92
|
xml.billingtype "balanceforward"
|
99
93
|
xml.status "active"
|
94
|
+
xml.vendoraccountno object.vendor_account_number
|
95
|
+
xml.paymethod object.payment_method
|
100
96
|
xml.contactinfo {
|
101
97
|
xml.contact {
|
102
|
-
xml.contactname
|
98
|
+
xml.contactname object.contact_name
|
103
99
|
xml.printas object.full_name
|
104
100
|
xml.companyname object.company_name
|
105
101
|
xml.firstname object.first_name
|
data/lib/intacctrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intacctrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Hale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- intacctrb.gemspec
|
169
169
|
- lib/.DS_Store
|
170
170
|
- lib/intacctrb.rb
|
171
|
+
- lib/intacctrb/account.rb
|
171
172
|
- lib/intacctrb/ap_payment.rb
|
172
173
|
- lib/intacctrb/base.rb
|
173
174
|
- lib/intacctrb/bill.rb
|