intacctrb 0.1 → 0.2pre

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: 45a40492167d51e7797d13f93b234a27664e2259
4
- data.tar.gz: db414b02a91fcf344bbf9ba469523f47eb41b4e6
3
+ metadata.gz: 7b907457bb9c38a786dc11039cfe95cbbc3866d9
4
+ data.tar.gz: 1bac18e1a52376b34b634c3eedadb67cd1fcf6be
5
5
  SHA512:
6
- metadata.gz: f1d43f1bbf87b2a14a0156086b879ecd6b823a11f6e411434879ea784821122e3c925af4e79a216e60a09256aa849d4f1c5785e2700280ff2da8ade6e690daf9
7
- data.tar.gz: c8333a7159f91daffa3af90f30a5e5040410a7a82b3e564edf1286741714034f5333a8d569ce62a6ea7fb02f32b1b6731de0f09d231c49bef0bae05e9f954937
6
+ metadata.gz: 86af4bdd45ff5e41850300a35551f50fdeed91f58bab0eeebdf127ac2cbfe90418e0c7727eb99fb33ac138adf59233d5ac90084dc31d8239767934e9e0308118
7
+ data.tar.gz: bfdd573f465fa321000ec80406e118ab350a143834020ac55faf3025d8b5a3d3516dac5d9689e22e87e964d48870258a51c1cc11a1b87cf048dbf81c24705b1d
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  .ruby-version
2
+ pkg/*
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- intacctrb (0.1)
4
+ intacctrb (0.2pre)
5
5
  hooks
6
6
  nokogiri
7
7
 
@@ -31,7 +31,7 @@ module IntacctRB
31
31
  xml.password IntacctRB.xml_password
32
32
  xml.controlid "INVOICE XML"
33
33
  xml.uniqueid "false"
34
- xml.dtdversion "2.1"
34
+ xml.dtdversion "3.0"
35
35
  }
36
36
  xml.operation(transaction: "false") {
37
37
  xml.authentication {
@@ -59,8 +59,8 @@ module IntacctRB
59
59
  @response = Nokogiri::XML(res.body)
60
60
  puts res.body
61
61
  if successful?
62
- if key = response.at('//result//key')
63
- set_intacct_key key.content
62
+ if key = response.at('//result//recordno')
63
+ set_intacct_id key.content if object
64
64
  end
65
65
 
66
66
  if intacct_action
@@ -82,30 +82,18 @@ module IntacctRB
82
82
  end
83
83
  end
84
84
 
85
- %w(invoice bill vendor customer).each do |type|
85
+ %w(invoice bill vendor customer journal_entry).each do |type|
86
86
  define_method "intacct_#{type}_prefix" do
87
- Intacct.send("#{type}_prefix")
87
+ IntacctRB.send("#{type}_prefix")
88
88
  end
89
89
  end
90
90
 
91
- def intacct_system_id
92
- intacct_object_id
91
+ def set_intacct_id id
92
+ object.intacct_id = id
93
93
  end
94
94
 
95
- def set_intacct_system_id
96
- object.intacct_system_id = intacct_object_id
97
- end
98
-
99
- def delete_intacct_system_id
100
- object.intacct_system_id = nil
101
- end
102
-
103
- def set_intacct_key key
104
- object.intacct_key = key if object.respond_to? :intacct_key
105
- end
106
-
107
- def delete_intacct_key
108
- object.intacct_key = nil if object.respond_to? :intacct_key
95
+ def delete_intacct_id
96
+ object.intacct_id = nil if object.respond_to? :intacct_id
109
97
  end
110
98
 
111
99
  def set_date_time type
@@ -2,11 +2,28 @@ module IntacctRB
2
2
  class JournalEntry < IntacctRB::Base
3
3
 
4
4
  def create
5
- return false if object.intacct_system_id.present?
5
+ return false if object.intacct_id.present?
6
6
  send_xml('create') do |xml|
7
7
  xml.function(controlid: "f1") {
8
- xml.send("create_gltransaction") {
9
- je_xml xml
8
+ xml.send("create") {
9
+ xml.glbatch {
10
+ je_xml xml
11
+ }
12
+ }
13
+ }
14
+ end
15
+
16
+ successful?
17
+ end
18
+
19
+ def update
20
+ return false unless object.intacct_id.present?
21
+ send_xml('update') do |xml|
22
+ xml.function(controlid: "f1") {
23
+ xml.send("update") {
24
+ xml.glbatch {
25
+ je_xml xml
26
+ }
10
27
  }
11
28
  }
12
29
  end
@@ -26,21 +43,48 @@ module IntacctRB
26
43
  end
27
44
 
28
45
  def get_list(options = {})
29
- send_xml('get_list') do |xml|
46
+ send_xml('readByQuery') do |xml|
30
47
  xml.function(controlid: "f4") {
31
- xml.get_list(object: "gltransaction", maxitems: (options[:max_items] || 0),
32
- start: (options[:start] || 0), showprivate:"true") {
33
- if options[:filters]
34
- xml.filter {
35
- options[:filters].each do |filter|
36
- xml.expression do
37
- filter.each_pair do |k,v|
38
- xml.send(k,v)
39
- end
40
- end
48
+ xml.readByQuery {
49
+ xml.object "glbatch"
50
+ xml.pagesize (options[:max_items] || 0)
51
+ xml.query options[:filter]
52
+ if options[:fields]
53
+ xml.fields {
54
+ fields.each do |field|
55
+ xml.field field.to_s
41
56
  end
42
57
  }
43
58
  end
59
+ }
60
+ }
61
+ end
62
+
63
+ if successful?
64
+ @data = []
65
+ @response.xpath('//glbatch').each do |invoice|
66
+ @data << OpenStruct.new({
67
+ id: invoice.at("RECORDNO").content,
68
+ batch_number: invoice.at("BATCHNO").content,
69
+ journal_id: invoice.at("JOURNAL").content,
70
+ date: Date.strptime(invoice.at("BATCH_DATE").content,'%m/%d/%Y'),
71
+ modified_at: DateTime.strptime(invoice.at("MODIFIED").content, '%m/%d/%Y %H:%H:%S'),
72
+ description: invoice.at("description").content,
73
+ state: invoice.at("STATE").content
74
+ })
75
+ end
76
+ @data
77
+ else
78
+ false
79
+ end
80
+ end
81
+
82
+ def get(options = {})
83
+ send_xml('read') do |xml|
84
+ xml.function(controlid: "f4") {
85
+ xml.read {
86
+ xml.object "glbatch"
87
+ xml.keys object.intacct_id || options[:intact_id]
44
88
  if options[:fields]
45
89
  xml.fields {
46
90
  fields.each do |field|
@@ -54,23 +98,47 @@ module IntacctRB
54
98
 
55
99
  if successful?
56
100
  @data = []
57
- @response.xpath('//bill').each do |invoice|
101
+ @response.xpath('//glbatch').each do |je|
58
102
  @data << OpenStruct.new({
59
- id: invoice.at("key").content,
60
- batch_number: invoice.at("batchno").content,
61
- journal_id: invoice.at("journalid").content,
62
- date_created: get_date_at('datecreated', invoice),
63
- date_modified: get_date_at('datemodified', invoice),
64
- description: invoice.at("description").content,
65
- state: invoice.at("state").content
103
+ id: je.at("RECORDNO").content,
104
+ batch_number: je.at("BATCHNO").content,
105
+ journal_id: je.at("JOURNAL").content,
106
+ date: Date.strptime(je.at("BATCH_DATE").content,'%Y-%m-%d'),
107
+ modified_at: DateTime.strptime(je.at("WHENMODIFIED").content, '%Y-%m-%dT%H:%M:%S'),
108
+ description: je.at("BATCH_TITLE").content,
109
+ state: je.at("STATE").content,
110
+ rows: get_rows(je)
66
111
  })
67
112
  end
68
- @data
113
+ if @data.empty?
114
+ false
115
+ else
116
+ @data
117
+ end
69
118
  else
70
119
  false
71
120
  end
72
121
  end
73
122
 
123
+ def get_rows(je)
124
+ rows = []
125
+ je.xpath('//glentry').each do |row|
126
+ rows << {
127
+ type: row.at('TR_TYPE').content,
128
+ amount: row.at('AMOUNT').content,
129
+ account_number: (row.at('ACCOUNTNO') ? row.at('ACCOUNTNO').content : nil),
130
+ memo: (row.at('DESCRIPTION') ? row.at('DESCRIPTION').content : nil),
131
+ location_id: (row.at('LOCATION') ? row.at('LOCATION').content : nil),
132
+ department_id: (row.at('DEPARTMENT') ? row.at('DEPARTMENT').content : nil),
133
+ customer_id: (row.at('CUSTOMER') ? row.at('CUSTOMER').content : nil),
134
+ employee_id: (row.at('EMPLOYEE') ? row.at('EMPLOYEE').content : nil),
135
+ project_id: (row.at('PROJECT') ? row.at('PROJECT').content : nil),
136
+ item_id: (row.at('ITEM') ? row.at('ITEM').content : nil)
137
+ }
138
+ end
139
+ rows
140
+ end
141
+
74
142
  def get_date_at(xpath, object)
75
143
  year = object.at("#{xpath}/year").content
76
144
  month = object.at("#{xpath}/month").content
@@ -83,84 +151,39 @@ module IntacctRB
83
151
  end
84
152
 
85
153
  def intacct_object_id
86
- "#{intacct_bill_prefix}#{object.payment.id}"
154
+ object.intacct_key
87
155
  end
88
156
 
89
157
  def je_xml xml
90
- xml.journalid object.journal_id
91
- if object.date
92
- xml.datecreated {
93
- xml.year object.date.strftime("%Y")
94
- xml.month object.date.strftime("%m")
95
- xml.day object.date.strftime("%d")
96
- }
97
- end
98
- if object.reverse_date
99
- xml.reversedate {
100
- xml.year object.reverse_date.strftime("%Y")
101
- xml.month object.reverse_date.strftime("%m")
102
- xml.day object.reverse_date.strftime("%d")
103
- }
104
- end
105
- xml.description object.description
158
+ xml.recordno object.intacct_id if object.intacct_id
159
+ xml.journal object.journal_id
160
+ xml.batch_date object.date.strftime('%Y-%m-%d') if object.date
161
+ xml.reverse_date object.reverse_date.strftime('%Y-%m-%d') if object.reverse_date
162
+ xml.batch_title object.description
106
163
  xml.referenceno object.reference_number
107
164
  je_item_fields(xml)
108
165
  end
109
166
 
110
- def set_intacct_system_id
111
- object.payment.intacct_system_id = intacct_object_id
112
- end
113
-
114
- def delete_intacct_system_id
115
- object.payment.intacct_system_id = nil
116
- end
117
-
118
- def delete_intacct_key
119
- object.payment.intacct_key = nil
120
- end
121
-
122
- def set_date_time type
123
- if %w(create update delete).include? type
124
- if object.payment.respond_to? :"intacct_#{type}d_at"
125
- object.payment.send("intacct_#{type}d_at=", DateTime.now)
126
- end
127
- end
128
- end
129
-
130
167
  def je_item_fields xml
131
- puts "object:: #{object}"
132
- xml.gltransactionentries {
168
+ xml.entries {
133
169
  object.rows.each do |row|
134
170
  xml.glentry {
135
- xml.trtype row[:type]
171
+ puts "row[:specialty_id]: #{row[:specialty_id]}"
172
+ xml.tr_type row[:type]
136
173
  xml.amount row[:amount]
137
- xml.glaccountno row[:account_number]
138
- if row[:date]
139
- xml.datecreated {
140
- xml.year row[:date].strftime("%Y")
141
- xml.month row[:date].strftime("%m")
142
- xml.day row[:date].strftime("%d")
143
- }
144
- end
145
- xml.memo row[:memo]
146
- xml.locationid row[:location_id] if row[:location_id]
147
- xml.departmentid row[:department_id] if row[:department_id]
148
- xml.customerid row[:customer_id] if row[:customer_id]
149
- xml.employeeid row[:employee_id] if row[:employee_id]
150
- xml.projectid row[:project_id] if row[:project_id]
151
- xml.itemid row[:item_id] if row[:itemid]
152
- xml.classid row[:class_id] if row[:class_id]
174
+ xml.accountno row[:account_number]
175
+ xml.description row[:memo]
176
+ xml.location row[:location_id] if row[:location_id]
177
+ xml.department row[:department_id] if row[:department_id]
178
+ xml.customer row[:customer_id] if row[:customer_id]
179
+ xml.employee row[:employee_id] if row[:employee_id]
180
+ xml.project row[:project_id] if row[:project_id]
181
+ xml.specialty row[:specialty_id] if row[:specialty_id]
182
+ xml.item row[:item_id] if row[:itemid]
183
+ xml.class row[:class_id] if row[:class_id]
153
184
  }
154
185
  end
155
186
  }
156
187
  end
157
-
158
- def to_date_xml xml, field_name, date
159
- xml.send(field_name) {
160
- xml.year date.strftime("%Y")
161
- xml.month date.strftime("%m")
162
- xml.day date.strftime("%d")
163
- }
164
- end
165
188
  end
166
189
  end
@@ -1,3 +1,3 @@
1
1
  module IntacctRB
2
- VERSION = "0.1"
2
+ VERSION = "0.2pre"
3
3
  end
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.1'
4
+ version: 0.2pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Hale
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-13 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -176,6 +176,7 @@ files:
176
176
  - lib/intacctrb/journal_entry.rb
177
177
  - lib/intacctrb/vendor.rb
178
178
  - lib/intacctrb/version.rb
179
+ - pkg/intacctrb-0.1.gem
179
180
  - spec/features/intacct_bill.feature
180
181
  - spec/features/intacct_customer.feature
181
182
  - spec/features/intacct_invoice.feature
@@ -201,9 +202,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
202
  version: '0'
202
203
  required_rubygems_version: !ruby/object:Gem::Requirement
203
204
  requirements:
204
- - - ">="
205
+ - - ">"
205
206
  - !ruby/object:Gem::Version
206
- version: '0'
207
+ version: 1.3.1
207
208
  requirements: []
208
209
  rubyforge_project:
209
210
  rubygems_version: 2.5.1