quickbooks-ruby 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/quickbooks-ruby.rb +1 -1
- data/lib/quickbooks/model/report.rb +52 -0
- data/lib/quickbooks/service/base_service.rb +2 -6
- data/lib/quickbooks/service/reports.rb +4 -9
- data/lib/quickbooks/version.rb +1 -1
- metadata +15 -15
- data/lib/quickbooks/model/reports.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd738a2e9e6bfa63ccf460226aa60dfe3688713d
|
4
|
+
data.tar.gz: e91dc8fc720d196c8075fe706667ec8c6c657e24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c466d28cb539140345cddc3a39bd11678b659c2150d98b6fcf8b8e04640fae6ab028f00de73bc17512a38af3f0baa03715973dc32463c2d475a9348b9a3ada63
|
7
|
+
data.tar.gz: e2dca1296eedcbf25578ec27e6eae67fd95ec1c382147cc5d554b7a44ddce2aa914be370c51391ad62cb71ddadfc04906e08084cf07f48a3518cfb854cbc8990
|
data/lib/quickbooks-ruby.rb
CHANGED
@@ -106,7 +106,7 @@ require 'quickbooks/model/invoice_change'
|
|
106
106
|
require 'quickbooks/model/customer_change'
|
107
107
|
require 'quickbooks/model/vendor_change'
|
108
108
|
require 'quickbooks/model/item_change'
|
109
|
-
require 'quickbooks/model/
|
109
|
+
require 'quickbooks/model/report'
|
110
110
|
require 'quickbooks/model/credit_memo_change'
|
111
111
|
require 'quickbooks/model/payment_change'
|
112
112
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class Report < BaseModel
|
4
|
+
|
5
|
+
attr_accessor :xml
|
6
|
+
|
7
|
+
def all_rows
|
8
|
+
@all_rows ||= xml.css("ColData:first-child").map {|node| parse_row(node.parent) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def columns
|
12
|
+
@columns ||= begin
|
13
|
+
nodes = xml.css('Column')
|
14
|
+
nodes.map do |node|
|
15
|
+
# There is also a ColType field, but it does not seem valuable to capture
|
16
|
+
node.at('ColTitle').content
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_row(label)
|
22
|
+
all_rows.find {|r| r[0] == label }
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Parses the given row:
|
28
|
+
# <Row type="Data">
|
29
|
+
# <ColData value="Checking" id="35"/>
|
30
|
+
# <ColData value="1201.00"/>
|
31
|
+
# <ColData value="200.50"/>
|
32
|
+
# </Row>
|
33
|
+
#
|
34
|
+
# To:
|
35
|
+
# ['Checking', BigDecimal(1201.00), BigDecimal(200.50)]
|
36
|
+
def parse_row(row_node)
|
37
|
+
row_node.elements.map.with_index do |el, i|
|
38
|
+
value = el.attr('value')
|
39
|
+
|
40
|
+
if i.zero? # Return the first column as a string, its the label.
|
41
|
+
value
|
42
|
+
elsif value.blank?
|
43
|
+
nil
|
44
|
+
else
|
45
|
+
BigDecimal(value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -125,13 +125,9 @@ module Quickbooks
|
|
125
125
|
collection.count = xml.xpath(path_to_nodes).count
|
126
126
|
if collection.count > 0
|
127
127
|
xml.xpath(path_to_nodes).each do |xa|
|
128
|
-
|
129
|
-
addition = xml.xpath(path_to_nodes)[0].xpath("//xmlns:Currency").children.to_s if "#{model::XML_NODE}" == "Reports"
|
130
|
-
entry.currency = addition if "#{model::XML_NODE}" == "Reports"
|
131
|
-
collection.body = response.body if "#{model::XML_NODE}" == "Reports"
|
132
|
-
results << entry
|
128
|
+
results << model.from_xml(xa)
|
133
129
|
end
|
134
|
-
end
|
130
|
+
end
|
135
131
|
|
136
132
|
collection.entries = results
|
137
133
|
rescue => ex
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# Docs: https://developer.intuit.com/docs/0100_accounting/0400_references/reports
|
1
2
|
module Quickbooks
|
2
3
|
module Service
|
3
4
|
class Reports < BaseService
|
@@ -16,21 +17,15 @@ module Quickbooks
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
def fetch_collection(model, date_macro, object_query, options = {})
|
20
|
-
response = do_http_get(url_for_query(object_query, date_macro, options))
|
21
|
-
|
22
|
-
parse_collection(response, model)
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
20
|
def query(object_query = 'BalanceSheet', date_macro = 'This Fiscal Year-to-date', options = {})
|
27
|
-
|
21
|
+
do_http_get(url_for_query(object_query, date_macro, options))
|
22
|
+
model.new(:xml => @last_response_xml)
|
28
23
|
end
|
29
24
|
|
30
25
|
private
|
31
26
|
|
32
27
|
def model
|
33
|
-
Quickbooks::Model::
|
28
|
+
Quickbooks::Model::Report
|
34
29
|
end
|
35
30
|
|
36
31
|
end
|
data/lib/quickbooks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickbooks-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Caughlan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|
@@ -42,42 +42,42 @@ dependencies:
|
|
42
42
|
name: nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activemodel
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: multipart-post
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
@@ -112,14 +112,14 @@ dependencies:
|
|
112
112
|
name: rr
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 1.0.2
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.0.2
|
125
125
|
- !ruby/object:Gem::Dependency
|
@@ -184,6 +184,7 @@ executables: []
|
|
184
184
|
extensions: []
|
185
185
|
extra_rdoc_files: []
|
186
186
|
files:
|
187
|
+
- lib/quickbooks-ruby.rb
|
187
188
|
- lib/quickbooks/model/access_token_response.rb
|
188
189
|
- lib/quickbooks/model/account.rb
|
189
190
|
- lib/quickbooks/model/account_based_expense_line_detail.rb
|
@@ -255,7 +256,7 @@ files:
|
|
255
256
|
- lib/quickbooks/model/purchase_order.rb
|
256
257
|
- lib/quickbooks/model/purchase_tax_rate_list.rb
|
257
258
|
- lib/quickbooks/model/refund_receipt.rb
|
258
|
-
- lib/quickbooks/model/
|
259
|
+
- lib/quickbooks/model/report.rb
|
259
260
|
- lib/quickbooks/model/sales_item_line_detail.rb
|
260
261
|
- lib/quickbooks/model/sales_receipt.rb
|
261
262
|
- lib/quickbooks/model/sales_tax_rate_list.rb
|
@@ -331,7 +332,6 @@ files:
|
|
331
332
|
- lib/quickbooks/util/name_entity.rb
|
332
333
|
- lib/quickbooks/util/query_builder.rb
|
333
334
|
- lib/quickbooks/version.rb
|
334
|
-
- lib/quickbooks-ruby.rb
|
335
335
|
homepage: http://github.com/ruckus/quickbooks-ruby
|
336
336
|
licenses:
|
337
337
|
- MIT
|
@@ -342,17 +342,17 @@ require_paths:
|
|
342
342
|
- lib
|
343
343
|
required_ruby_version: !ruby/object:Gem::Requirement
|
344
344
|
requirements:
|
345
|
-
- -
|
345
|
+
- - ">="
|
346
346
|
- !ruby/object:Gem::Version
|
347
347
|
version: '0'
|
348
348
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
349
349
|
requirements:
|
350
|
-
- -
|
350
|
+
- - ">="
|
351
351
|
- !ruby/object:Gem::Version
|
352
352
|
version: '0'
|
353
353
|
requirements: []
|
354
354
|
rubyforge_project:
|
355
|
-
rubygems_version: 2.
|
355
|
+
rubygems_version: 2.4.6
|
356
356
|
signing_key:
|
357
357
|
specification_version: 4
|
358
358
|
summary: REST API to Quickbooks Online
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Quickbooks
|
2
|
-
module Model
|
3
|
-
class Reports < BaseModel
|
4
|
-
XML_COLLECTION_NODE = "Reports"
|
5
|
-
XML_NODE = "Reports"
|
6
|
-
REST_RESOURCE = 'reports'
|
7
|
-
|
8
|
-
REPORT_TYPES = ['BalanceSheet', 'ProfitandLoss', 'ProfitAndLossDetail', 'TrialBalance', 'CashFlow', 'InventoryValuationSummary', 'CustomerSales', 'ItemSales', 'DepartmentSales', 'ClassSales', 'CustomerIncome', 'CustomerBalance', 'CustomerBalanceDetail', 'AgedReceivables', 'AgedReceivableDetail', 'VendorBalance', 'VendorBalanceDetail', 'AgedPayables', 'AgedPayableDetail', 'VendorExpenses', 'GeneralLedgerDetail']
|
9
|
-
|
10
|
-
xml_name XML_NODE
|
11
|
-
|
12
|
-
xml_accessor :currency, :from => 'Header/Currency'
|
13
|
-
xml_accessor :body
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|