quickbooks-ruby 1.0.18 → 1.0.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dda46c200f06a727d9afc9e6fab73b06aff231f1fdf8ad1c2b82f2a47e68725
4
- data.tar.gz: c1339cc89632c1268304df4c731bdfda624ee694a49b384d9c7c227f1547d57a
3
+ metadata.gz: fef9e529bfa1fb897b03273cad08ac6fe1fe45c30667f655a3a44dddaa36d10a
4
+ data.tar.gz: 5dfe60a549caac7c0ecefd10b9ea3396916bccc440e3011ed804d1e02308cbdf
5
5
  SHA512:
6
- metadata.gz: d03e41802dea2444518e37c4f3a001461cb0ef89df68a7d66a27ca31320065b275440585d3dde3921912723b16f275d92c9a1aa8d67a6d66cfae634410767bea
7
- data.tar.gz: d59eaef4588055cd75b9ec44cdb23d4294509425f7cfd5a1ee391acd18d3ad62fa946755de85c890a411b3bb3fe6db154a4cafc6e16fbde9b3ca0271d1871f4f
6
+ metadata.gz: 797e5336baeec1e26e813d9975f1721f187f72cff7abcfd87f01fef579d9669b686af0fd31a3812150365a99388fe69b074d0b6ed8fb5ed3437afc1d4ee49b2e
7
+ data.tar.gz: 15c7ffea9da64f530709637aec045c3b2d235216a08cf197b86a9597820083810525674781e28e2299508a6b58758a487d7c8b42f0eb25f4ae50c0a3034ed373
@@ -7,6 +7,7 @@ module Quickbooks
7
7
  xml_accessor :billable_status, :from => 'BillableStatus'
8
8
  xml_accessor :tax_amount, :from => 'UnitPrice', :as => BigDecimal, :to_xml => to_xml_big_decimal
9
9
  xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
10
+ xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', to_xml: Proc.new { |val| val.to_f }
10
11
 
11
12
  reference_setters :customer_ref, :class_ref, :account_ref, :tax_code_ref
12
13
 
@@ -31,6 +31,7 @@ module Quickbooks
31
31
  xml_accessor :due_date, :from => 'DueDate', :as => Date
32
32
  xml_accessor :remit_to_address, :from => 'RemitToAddr', :as => PhysicalAddress
33
33
  xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
34
+ xml_accessor :mailing_address, :from => 'VendorAddr', :as => PhysicalAddress
34
35
  xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
35
36
  xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
36
37
 
@@ -12,6 +12,8 @@ module Quickbooks
12
12
  xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
13
13
  xml_accessor :detail_type, :from => 'DetailType'
14
14
 
15
+ xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
16
+
15
17
  #== Various detail types
16
18
  xml_accessor :account_based_expense_line_detail, :from => 'AccountBasedExpenseLineDetail', :as => AccountBasedExpenseLineDetail
17
19
  xml_accessor :item_based_expense_line_detail, :from => 'ItemBasedExpenseLineDetail', :as => ItemBasedExpenseLineDetail
@@ -13,6 +13,7 @@ module Quickbooks
13
13
  xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
14
14
  xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
15
15
  xml_accessor :billable_status, :from => 'BillableStatus'
16
+ xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', to_xml: Proc.new { |val| val.to_f }
16
17
 
17
18
  reference_setters :item_ref, :class_ref, :price_level_ref, :customer_ref, :tax_code_ref
18
19
  end
@@ -9,6 +9,7 @@ module Quickbooks
9
9
  xml_accessor :quantity, :from => 'Qty', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
10
10
  xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
11
11
  xml_accessor :service_date, :from => 'ServiceDate', :as => Date
12
+ xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', to_xml: Proc.new { |val| val.to_f }
12
13
 
13
14
  reference_setters :item_ref, :class_ref, :price_level_ref, :tax_code_ref
14
15
  end
@@ -1,9 +1,9 @@
1
1
  module Quickbooks
2
2
  module Model
3
3
  class TransactionTaxDetail < BaseModel
4
-
5
4
  xml_accessor :txn_tax_code_ref, :from => 'TxnTaxCodeRef', :as => BaseReference
6
5
  xml_accessor :total_tax, :from => 'TotalTax', :as => BigDecimal, :to_xml => to_xml_big_decimal
6
+ xml_accessor :total_tax_specified, :from => 'TotalTaxSpecified'
7
7
  xml_accessor :lines, :from => 'TaxLine', :as => [TaxLine]
8
8
 
9
9
  reference_setters :txn_tax_code_ref
@@ -28,6 +28,8 @@ module Quickbooks
28
28
 
29
29
  xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
30
30
  xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
31
+
32
+ xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
31
33
 
32
34
  reference_setters
33
35
 
@@ -248,11 +248,7 @@ module Quickbooks
248
248
  headers['Accept-Encoding'] = HTTP_ACCEPT_ENCODING
249
249
  end
250
250
 
251
- log "------ QUICKBOOKS-RUBY REQUEST ------"
252
- log "METHOD = #{method}"
253
- log "RESOURCE = #{url}"
254
- log_request_body(body)
255
- log "REQUEST HEADERS = #{headers.inspect}"
251
+ log_request(method, url, body, headers)
256
252
 
257
253
  request_info = RequestInfo.new(url, headers, body, method)
258
254
  before_request.call(request_info) if before_request
@@ -273,12 +269,8 @@ module Quickbooks
273
269
  after_request.call(request_info, raw_response.body) if after_request
274
270
 
275
271
  response = Quickbooks::Service::Responses::OAuthHttpResponse.wrap(raw_response)
276
- log "------ QUICKBOOKS-RUBY RESPONSE ------"
277
- log "RESPONSE CODE = #{response.code}"
278
- log_response_body(response)
279
- if response.respond_to?(:headers)
280
- log "RESPONSE HEADERS = #{response.headers}"
281
- end
272
+ log_response(response)
273
+
282
274
  check_response(response, request: body)
283
275
  end
284
276
 
@@ -354,28 +346,29 @@ module Quickbooks
354
346
  end
355
347
  end
356
348
 
357
- def log_response_body(response)
358
- log "RESPONSE BODY:"
359
- if is_json?
360
- log ">>>>#{response.plain_body.inspect}"
361
- elsif is_pdf?
362
- log("BODY is a PDF : not dumping")
363
- else
364
- log(log_xml(response.plain_body))
365
- end
349
+ def log_request(method, url, body, headers)
350
+ messages = []
351
+ messages << "------ QUICKBOOKS-RUBY REQUEST ------"
352
+ messages << "METHOD = #{method}"
353
+ messages << "RESOURCE = #{url}"
354
+ messages.concat(request_body_messages(body))
355
+ messages << "REQUEST HEADERS = #{headers.inspect}"
356
+
357
+ log_multiple(messages)
366
358
  end
367
359
 
368
- def log_request_body(body)
369
- log "REQUEST BODY:"
360
+ def request_body_messages(body)
361
+ messages = []
362
+ messages << "REQUEST BODY:"
370
363
  if is_json?
371
- log(body.inspect)
364
+ messages << body.inspect
372
365
  elsif is_pdf?
373
- log("BODY is a PDF : not dumping")
366
+ messages << "BODY is a PDF : not dumping"
374
367
  else
375
368
  #multipart request for uploads arrive here in a Hash with UploadIO vals
376
369
  if body.is_a?(Hash)
377
370
  body.each do |k,v|
378
- log('BODY PART:')
371
+ messages << 'BODY PART:'
379
372
  val_content = v.inspect
380
373
  if v.is_a?(UploadIO)
381
374
  if v.content_type == 'application/xml'
@@ -384,12 +377,37 @@ module Quickbooks
384
377
  end
385
378
  end
386
379
  end
387
- log("#{k}: #{val_content}")
380
+ messages << "#{k}: #{val_content}"
388
381
  end
389
382
  else
390
- log(log_xml(body))
383
+ messages << log_xml(body)
391
384
  end
392
385
  end
386
+ messages
387
+ end
388
+
389
+ def log_response(response)
390
+ messages = []
391
+ messages << "------ QUICKBOOKS-RUBY RESPONSE ------"
392
+ messages << "RESPONSE CODE = #{response.code}"
393
+ messages.concat(response_body_messages(response))
394
+ messages << "RESPONSE HEADERS = #{response.headers}" if response.respond_to?(:headers)
395
+
396
+ log_multiple(messages)
397
+ end
398
+
399
+ def response_body_messages(response)
400
+ messages = []
401
+ messages << "RESPONSE BODY:"
402
+ if is_json?
403
+ messages << ">>>>#{response.plain_body.inspect}"
404
+ elsif is_pdf?
405
+ messages << "BODY is a PDF : not dumping"
406
+ else
407
+ messages << log_xml(response.plain_body)
408
+ end
409
+
410
+ messages
393
411
  end
394
412
 
395
413
  def parse_and_raise_exception(options = {})
@@ -19,6 +19,12 @@ module Quickbooks
19
19
  end
20
20
  end
21
21
 
22
+ def pdf(payment)
23
+ url = "#{url_for_resource(model::REST_RESOURCE)}/#{payment.id}/pdf"
24
+ response = do_http_raw_get(url, {}, {'Accept' => 'application/pdf'})
25
+ response.plain_body
26
+ end
27
+
22
28
  private
23
29
 
24
30
  def model
@@ -33,7 +33,10 @@ module Quickbooks
33
33
  if field.class == Symbol
34
34
  field = field.to_s.camelcase
35
35
  end
36
- q = "select * from %s where %s = '%s'" % [model.resource_for_singular, field, selector]
36
+
37
+ clause = Quickbooks::Util::QueryBuilder.new.clause(field, '=', selector)
38
+ q = "select * from %s where %s" % [model.resource_for_singular, clause]
39
+
37
40
  self.query(q, options)
38
41
  end
39
42
 
@@ -5,10 +5,22 @@ module Quickbooks
5
5
  ::Quickbooks.log(msg)
6
6
  end
7
7
 
8
+ def log_multiple(messages)
9
+ if condense_logs?
10
+ log(messages.join("\n"))
11
+ else
12
+ messages.each(&method(:log))
13
+ end
14
+ end
15
+
8
16
  def log?
9
17
  ::Quickbooks.log?
10
18
  end
11
19
 
20
+ def condense_logs?
21
+ ::Quickbooks.condense_logs?
22
+ end
23
+
12
24
  def log_xml(str)
13
25
  if ::Quickbooks.log_xml_pretty_print? && !(str and str.empty?)
14
26
  Nokogiri::XML(str).to_xml
@@ -20,6 +20,8 @@ module Quickbooks
20
20
  value.strftime('%Y-%m-%d')
21
21
  when Array
22
22
  value = value.map(&escape_single_quotes)
23
+ when true, false
24
+ value
23
25
  else
24
26
  value = escape_single_quotes.call(value)
25
27
  end
@@ -27,6 +29,8 @@ module Quickbooks
27
29
  if operator.downcase == 'in' && value.is_a?(Array)
28
30
  value = value.map { |v| "#{VALUE_QUOTE}#{v}#{VALUE_QUOTE}" }
29
31
  "#{field} #{operator} (#{value.join(', ')})"
32
+ elsif value == true || value == false
33
+ "#{field} #{operator} #{value}"
30
34
  else
31
35
  "#{field} #{operator} #{VALUE_QUOTE}#{value}#{VALUE_QUOTE}"
32
36
  end
@@ -1,5 +1,5 @@
1
1
  module Quickbooks
2
2
 
3
- VERSION = "1.0.18"
3
+ VERSION = "1.0.21"
4
4
 
5
5
  end
@@ -230,13 +230,18 @@ module Quickbooks
230
230
  end
231
231
 
232
232
  # set logging on or off
233
- attr_writer :log, :log_xml_pretty_print
233
+ attr_writer :log, :log_xml_pretty_print, :condense_logs
234
234
 
235
235
  # Returns whether to log. Defaults to 'false'.
236
236
  def log?
237
237
  @log ||= false
238
238
  end
239
239
 
240
+ # Returns whether to limit log lines
241
+ def condense_logs?
242
+ @condense_logs ||= false
243
+ end
244
+
240
245
  # pretty printing the xml in the logs is "on" by default
241
246
  def log_xml_pretty_print?
242
247
  defined?(@log_xml_pretty_print) ? @log_xml_pretty_print : true
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: 1.0.18
4
+ version: 1.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Caughlan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "<"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "<"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -361,7 +375,7 @@ homepage: http://github.com/ruckus/quickbooks-ruby
361
375
  licenses:
362
376
  - MIT
363
377
  metadata: {}
364
- post_install_message:
378
+ post_install_message:
365
379
  rdoc_options: []
366
380
  require_paths:
367
381
  - lib
@@ -376,9 +390,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
390
  - !ruby/object:Gem::Version
377
391
  version: '0'
378
392
  requirements: []
379
- rubyforge_project:
393
+ rubyforge_project:
380
394
  rubygems_version: 2.7.6.2
381
- signing_key:
395
+ signing_key:
382
396
  specification_version: 4
383
397
  summary: REST API to Quickbooks Online
384
398
  test_files: []