quickbooks-ruby 0.2.2 → 0.2.3

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: fc2f4401510ff725d9f746e57a8de1d4931da81d
4
- data.tar.gz: c5e667d5a6a04b855e3dd09ef18aad5c5aa9a8cd
3
+ metadata.gz: 24d6dec4cc2648c1f89dbae32ce9420d39fe9349
4
+ data.tar.gz: 8f26780aa09b6fafaf97cb828f004268f03403be
5
5
  SHA512:
6
- metadata.gz: 4e64551e8c02a945d1f58a0de0d8593ec495bb2a5f53ed2f20054d3ae55a22f7c4289b6872d4d77e26bdeaf8cf8098132927685698c009433686fac7a9887686
7
- data.tar.gz: 57d7788ccbf821a300a35e490068c840f9cb1ce2b6ed49e509b66ae4922ba2f93774ad6ddd2d6ae45d50f753ce1b0c1a9f71179852688da21d7d28c298be8935
6
+ metadata.gz: 1d0f9f637b9feadba851884ebaeb5108a8a88ef8b7b1f78fbb72537b87156dd8095f251e8c3655381e8d64df6876f3f87491e34c3a32bc2a68337c2b506d66f6
7
+ data.tar.gz: 20850df806e99bb8acb64f2a0590a1d9059f2ecc44c5bd9951eabe970a4124175329d867884c25ca3cbd8dac86ae92ef90c25854915898fcc259d3ac4148261d
@@ -15,6 +15,7 @@ require 'quickbooks/util/name_entity'
15
15
  require 'quickbooks/util/query_builder'
16
16
 
17
17
  #== Models
18
+ require 'quickbooks/model/definition'
18
19
  require 'quickbooks/model/validator'
19
20
  require 'quickbooks/model/base_model'
20
21
  require 'quickbooks/model/base_reference'
@@ -100,6 +101,7 @@ require 'quickbooks/model/invoice_change'
100
101
  require 'quickbooks/model/customer_change'
101
102
  require 'quickbooks/model/vendor_change'
102
103
  require 'quickbooks/model/item_change'
104
+ require 'quickbooks/model/reports'
103
105
 
104
106
 
105
107
  #== Services
@@ -142,6 +144,7 @@ require 'quickbooks/service/upload'
142
144
  require 'quickbooks/util/multipart'
143
145
  require 'quickbooks/service/vendor_change'
144
146
  require 'quickbooks/service/item_change'
147
+ require 'quickbooks/service/reports'
145
148
 
146
149
  module Quickbooks
147
150
  @@sandbox_mode = false
@@ -1,6 +1,7 @@
1
1
  module Quickbooks
2
2
  module Model
3
3
  class BaseModel
4
+ include Definition
4
5
  include ActiveModel::Validations
5
6
  include Validator
6
7
  include ROXML
@@ -0,0 +1,42 @@
1
+ module Definition
2
+
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ # https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services
9
+ TRANSACTION_ENTITIES = %w{
10
+ Bill
11
+ BillPayment
12
+ CreditMemo
13
+ Estimate
14
+ Invoice
15
+ JournalEntry
16
+ Payment
17
+ Purchase
18
+ PurchaseOrder
19
+ RefundReceipt
20
+ SalesReceipt
21
+ TimeActivity
22
+ VendorCredit
23
+ }
24
+
25
+ def is_transaction_entity?
26
+ TRANSACTION_ENTITIES.include?(self.name.demodulize)
27
+ end
28
+
29
+ def is_name_list_entity?
30
+ !self.is_transaction_entity?
31
+ end
32
+ end
33
+
34
+ def is_transaction_entity?
35
+ self.class.is_transaction_entity?
36
+ end
37
+
38
+ def is_name_list_entity?
39
+ self.class.is_name_list_entity?
40
+ end
41
+
42
+ end
@@ -5,6 +5,7 @@ module Quickbooks
5
5
  include ROXML
6
6
  xml_name 'Error'
7
7
  xml_accessor :code, :from => "@code"
8
+ xml_accessor :element, :from => "@element"
8
9
  xml_accessor :message, :from => "Message"
9
10
  xml_accessor :detail, :from => "Detail"
10
11
  end
@@ -0,0 +1,17 @@
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
+ REPORTS = ['BalanceSheet', 'ProfitandLoss', 'ProfitandLossDetail', 'CashFlow']
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
@@ -85,6 +85,7 @@ module Quickbooks
85
85
 
86
86
  start_position = ((page - 1) * per_page) + 1 # page=2, per_page=10 then we want to start at 11
87
87
  max_results = per_page
88
+
88
89
  response = do_http_get(url_for_query(query, start_position, max_results))
89
90
 
90
91
  parse_collection(response, model)
@@ -121,9 +122,13 @@ module Quickbooks
121
122
  if collection.count > 0
122
123
  xml.xpath(path_to_nodes).each do |xa|
123
124
  entry = model.from_xml(xa)
125
+ addition = xml.xpath(path_to_nodes)[0].xpath("//xmlns:Currency").children.to_s if "#{model::XML_NODE}" == "Reports"
126
+ entry.currency = addition if "#{model::XML_NODE}" == "Reports"
127
+ collection.body = response.body if "#{model::XML_NODE}" == "Reports"
124
128
  results << entry
125
129
  end
126
- end
130
+ end
131
+
127
132
  collection.entries = results
128
133
  rescue => ex
129
134
  raise Quickbooks::IntuitRequestException.new("Error parsing XML: #{ex.message}")
@@ -286,6 +291,10 @@ module Quickbooks
286
291
  if code_attr
287
292
  error[:code] = code_attr.value
288
293
  end
294
+ element_attr = error_element.attributes['element']
295
+ if code_attr
296
+ error[:element] = code_attr.value
297
+ end
289
298
  error[:message] = error_element.xpath("//xmlns:Message").text
290
299
  error[:detail] = error_element.xpath("//xmlns:Detail").text
291
300
  end
@@ -0,0 +1,28 @@
1
+ module Quickbooks
2
+ module Service
3
+ class Reports < BaseService
4
+
5
+ def url_for_query(which_report = 'BalanceSheet', date_macro = 'This Fiscal Year-to-date')
6
+ "#{url_for_base}/reports/#{which_report}?date_macro=#{URI.encode_www_form_component(date_macro)}"
7
+ end
8
+
9
+ def fetch_collection(model, date_macro, object_query)
10
+ response = do_http_get(url_for_query(object_query, date_macro))
11
+
12
+ parse_collection(response, model)
13
+
14
+ end
15
+
16
+ def query(object_query = 'BalanceSheet', date_macro = 'This Fiscal Year-to-date')
17
+ fetch_collection(model, date_macro , object_query)
18
+ end
19
+
20
+ private
21
+
22
+ def model
23
+ Quickbooks::Model::Reports
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -3,6 +3,8 @@ module Quickbooks
3
3
  include Enumerable
4
4
  attr_accessor :entries
5
5
 
6
+ attr_accessor :body
7
+
6
8
  # Legacy Attributes (v2)
7
9
  attr_accessor :count, :current_page
8
10
 
@@ -1,5 +1,5 @@
1
1
  module Quickbooks
2
2
 
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
 
5
5
  end
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.2.2
4
+ version: 0.2.3
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-04-08 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth
@@ -209,6 +209,7 @@ files:
209
209
  - lib/quickbooks/model/custom_field.rb
210
210
  - lib/quickbooks/model/customer.rb
211
211
  - lib/quickbooks/model/customer_change.rb
212
+ - lib/quickbooks/model/definition.rb
212
213
  - lib/quickbooks/model/delivery_info.rb
213
214
  - lib/quickbooks/model/department.rb
214
215
  - lib/quickbooks/model/deposit.rb
@@ -250,6 +251,7 @@ files:
250
251
  - lib/quickbooks/model/purchase_order.rb
251
252
  - lib/quickbooks/model/purchase_tax_rate_list.rb
252
253
  - lib/quickbooks/model/refund_receipt.rb
254
+ - lib/quickbooks/model/reports.rb
253
255
  - lib/quickbooks/model/sales_item_line_detail.rb
254
256
  - lib/quickbooks/model/sales_receipt.rb
255
257
  - lib/quickbooks/model/sales_tax_rate_list.rb
@@ -297,6 +299,7 @@ files:
297
299
  - lib/quickbooks/service/purchase.rb
298
300
  - lib/quickbooks/service/purchase_order.rb
299
301
  - lib/quickbooks/service/refund_receipt.rb
302
+ - lib/quickbooks/service/reports.rb
300
303
  - lib/quickbooks/service/sales_receipt.rb
301
304
  - lib/quickbooks/service/service_crud.rb
302
305
  - lib/quickbooks/service/tax_code.rb