From 2ca5ee5daadf2534f44c9ead480347901f056eba Mon Sep 17 00:00:00 2001 From: Brian Kenn Date: Wed, 12 Sep 2018 17:10:37 +1000 Subject: [PATCH 1/4] Add support for Minor Version 1 which adds TaxInclusiveAmt attribute Line.SalesItemLineDetail, Line.ItemBasedExpenseLineDetail, and Line.AccountBasedExpenseLineDetail line types --- lib/quickbooks/model/invoice.rb | 1 + lib/quickbooks/model/sales_item_line_detail.rb | 1 + lib/quickbooks/service/invoice.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/lib/quickbooks/model/invoice.rb b/lib/quickbooks/model/invoice.rb index c044e3bf..1c03dd53 100644 --- a/lib/quickbooks/model/invoice.rb +++ b/lib/quickbooks/model/invoice.rb @@ -14,6 +14,7 @@ class Invoice < BaseModel #== Constants REST_RESOURCE = 'invoice' + MINORVERSION = 1 XML_COLLECTION_NODE = "Invoice" XML_NODE = "Invoice" EMAIL_STATUS_NEED_TO_SEND = 'NeedToSend' diff --git a/lib/quickbooks/model/sales_item_line_detail.rb b/lib/quickbooks/model/sales_item_line_detail.rb index bf683846..37826637 100644 --- a/lib/quickbooks/model/sales_item_line_detail.rb +++ b/lib/quickbooks/model/sales_item_line_detail.rb @@ -9,6 +9,7 @@ class SalesItemLineDetail < BaseModel xml_accessor :quantity, :from => 'Qty', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f } xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference xml_accessor :service_date, :from => 'ServiceDate', :as => Date + xml_accessor :tax_inclusive_amount, :from => 'TaxInclusiveAmt', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f } reference_setters :item_ref, :class_ref, :price_level_ref, :tax_code_ref end diff --git a/lib/quickbooks/service/invoice.rb b/lib/quickbooks/service/invoice.rb index 32416edf..e8d803ba 100644 --- a/lib/quickbooks/service/invoice.rb +++ b/lib/quickbooks/service/invoice.rb @@ -6,6 +6,21 @@ def delete(invoice) delete_by_query_string(invoice) end + def url_for_resource(resource) + url = super(resource) + "#{url}?minorversion=#{Quickbooks::Model::Invoice::MINORVERSION}" + end + + def fetch_by_id(id, params = {}) + url = "#{url_for_base}/invoice/#{id}?minorversion=#{Quickbooks::Model::Invoice::MINORVERSION}" + fetch_object(model, url, params) + end + + def url_for_query(query = nil, start_position = 1, max_results + url = super(query, start_position, max_results, options) + "#{url}&minorversion=#{Quickbooks::Model::Invoice::MINORVERSION}" + end + def send(invoice, email_address=nil) query = email_address.present? ? "?sendTo=#{email_address}" : "" url = "#{url_for_resource(model::REST_RESOURCE)}/#{invoice.id}/send#{query}" From b06baa290decc61cf3e714958f2c4dd5b5662251 Mon Sep 17 00:00:00 2001 From: Brian Kenn Date: Wed, 12 Sep 2018 17:26:39 +1000 Subject: [PATCH 2/4] Update to 0.6.2 --- lib/quickbooks/model/report.rb | 10 +++++++--- lib/quickbooks/service/base_service.rb | 2 +- lib/quickbooks/version.rb | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/quickbooks/model/report.rb b/lib/quickbooks/model/report.rb index a4d55338..27f24e1d 100644 --- a/lib/quickbooks/model/report.rb +++ b/lib/quickbooks/model/report.rb @@ -37,9 +37,13 @@ def parse_row(row_node) row_node.elements.map.with_index do |el, i| value = el.attr('value') - next nil if value.blank? - next value if value.to_s.match(/^\d+$|^\d+.\d+$|^-\d+|^-\d+.\d+$|^.\d+$/).nil? - BigDecimal(value) + if i.zero? # Return the first column as a string, its the label. + value + elsif value.blank? + nil + else + BigDecimal(value) + end end end diff --git a/lib/quickbooks/service/base_service.rb b/lib/quickbooks/service/base_service.rb index ead98d68..0c72601c 100644 --- a/lib/quickbooks/service/base_service.rb +++ b/lib/quickbooks/service/base_service.rb @@ -289,7 +289,7 @@ def check_response(response, options = {}) when 429 message = parse_intuit_error[:message] raise Quickbooks::TooManyRequests, message - when 502, 503, 504 + when 503, 504 raise Quickbooks::ServiceUnavailable else raise "HTTP Error Code: #{status}, Msg: #{response.plain_body}" diff --git a/lib/quickbooks/version.rb b/lib/quickbooks/version.rb index f43c896a..f2a4b1f8 100644 --- a/lib/quickbooks/version.rb +++ b/lib/quickbooks/version.rb @@ -1,5 +1,5 @@ module Quickbooks - VERSION = "0.6.1" + VERSION = "0.6.2" end From 549d8bd0055c2d755d39486abcf972fc865ce074 Mon Sep 17 00:00:00 2001 From: Brian Kenn Date: Wed, 12 Sep 2018 17:32:39 +1000 Subject: [PATCH 3/4] Fix missing code --- lib/quickbooks/service/invoice.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/quickbooks/service/invoice.rb b/lib/quickbooks/service/invoice.rb index e8d803ba..80d8cb1d 100644 --- a/lib/quickbooks/service/invoice.rb +++ b/lib/quickbooks/service/invoice.rb @@ -16,7 +16,7 @@ def fetch_by_id(id, params = {}) fetch_object(model, url, params) end - def url_for_query(query = nil, start_position = 1, max_results + def url_for_query(query = nil, start_position = 1, max_results = 20, options = {}) url = super(query, start_position, max_results, options) "#{url}&minorversion=#{Quickbooks::Model::Invoice::MINORVERSION}" end From d654e9b1f01f23262122f516c39741545f606ae6 Mon Sep 17 00:00:00 2001 From: Brian Kenn Date: Thu, 13 Sep 2018 06:45:14 +1000 Subject: [PATCH 4/4] Revert Update to 0.6.2 --- lib/quickbooks/model/report.rb | 10 +++------- lib/quickbooks/service/base_service.rb | 2 +- lib/quickbooks/version.rb | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/quickbooks/model/report.rb b/lib/quickbooks/model/report.rb index 27f24e1d..a4d55338 100644 --- a/lib/quickbooks/model/report.rb +++ b/lib/quickbooks/model/report.rb @@ -37,13 +37,9 @@ def parse_row(row_node) row_node.elements.map.with_index do |el, i| value = el.attr('value') - if i.zero? # Return the first column as a string, its the label. - value - elsif value.blank? - nil - else - BigDecimal(value) - end + next nil if value.blank? + next value if value.to_s.match(/^\d+$|^\d+.\d+$|^-\d+|^-\d+.\d+$|^.\d+$/).nil? + BigDecimal(value) end end diff --git a/lib/quickbooks/service/base_service.rb b/lib/quickbooks/service/base_service.rb index 0c72601c..ead98d68 100644 --- a/lib/quickbooks/service/base_service.rb +++ b/lib/quickbooks/service/base_service.rb @@ -289,7 +289,7 @@ def check_response(response, options = {}) when 429 message = parse_intuit_error[:message] raise Quickbooks::TooManyRequests, message - when 503, 504 + when 502, 503, 504 raise Quickbooks::ServiceUnavailable else raise "HTTP Error Code: #{status}, Msg: #{response.plain_body}" diff --git a/lib/quickbooks/version.rb b/lib/quickbooks/version.rb index f2a4b1f8..f43c896a 100644 --- a/lib/quickbooks/version.rb +++ b/lib/quickbooks/version.rb @@ -1,5 +1,5 @@ module Quickbooks - VERSION = "0.6.2" + VERSION = "0.6.1" end