quickbooks-ruby 0.4.4 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/quickbooks-ruby.rb +12 -3
- data/lib/quickbooks/model/batch_request.rb +1 -0
- data/lib/quickbooks/model/batch_response.rb +1 -0
- data/lib/quickbooks/model/exchange_rate.rb +23 -0
- data/lib/quickbooks/model/invoice.rb +1 -0
- data/lib/quickbooks/model/invoice_change.rb +2 -1
- data/lib/quickbooks/model/invoice_group_line_detail.rb +14 -0
- data/lib/quickbooks/model/invoice_line_item.rb +14 -1
- data/lib/quickbooks/model/item.rb +4 -1
- data/lib/quickbooks/model/item_group_detail.rb +9 -0
- data/lib/quickbooks/model/item_group_line.rb +20 -0
- data/lib/quickbooks/model/refund_receipt_change.rb +8 -0
- data/lib/quickbooks/service/base_service.rb +8 -1
- data/lib/quickbooks/service/batch.rb +1 -1
- data/lib/quickbooks/service/exchange_rate.rb +25 -0
- data/lib/quickbooks/service/refund_receipt_change.rb +16 -0
- data/lib/quickbooks/version.rb +1 -1
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd6ad957a89437617f1bcff71acf5d6a35ca2230
|
4
|
+
data.tar.gz: ff0d3df6b00727db3babf0066dd091f9cbf35b95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4344907b9f25e64fedfdbf8e4ca9f8522fd9a46579f4438973c931aed7837571f58137b6a4492cf389761c6eb901205bbc3eaec62e8734fc0994d9cfdba4331b
|
7
|
+
data.tar.gz: f5ad837bc5dfa26b4c5c5607cf5073efe1323e93430daebfcc3d625088e13cda980870f88da2fa36471323d33c1d6a815e2042cc22249e8d7aa96551ed6b34b1
|
data/lib/quickbooks-ruby.rb
CHANGED
@@ -46,6 +46,8 @@ require 'quickbooks/model/entity'
|
|
46
46
|
require 'quickbooks/model/journal_entry_line_detail'
|
47
47
|
require 'quickbooks/model/line'
|
48
48
|
require 'quickbooks/model/journal_entry'
|
49
|
+
require 'quickbooks/model/item_group_line'
|
50
|
+
require 'quickbooks/model/item_group_detail'
|
49
51
|
require 'quickbooks/model/item'
|
50
52
|
require 'quickbooks/model/budget_line_item'
|
51
53
|
require 'quickbooks/model/budget'
|
@@ -61,6 +63,7 @@ require 'quickbooks/model/email_address'
|
|
61
63
|
require 'quickbooks/model/web_site_address'
|
62
64
|
require 'quickbooks/model/physical_address'
|
63
65
|
require 'quickbooks/model/invoice_line_item'
|
66
|
+
require 'quickbooks/model/invoice_group_line_detail'
|
64
67
|
require 'quickbooks/model/name_value'
|
65
68
|
require 'quickbooks/model/company_info'
|
66
69
|
require 'quickbooks/model/customer'
|
@@ -76,6 +79,7 @@ require 'quickbooks/model/bill_payment_credit_card'
|
|
76
79
|
require 'quickbooks/model/bill_payment'
|
77
80
|
require 'quickbooks/model/vendor'
|
78
81
|
require 'quickbooks/model/employee'
|
82
|
+
require 'quickbooks/model/exchange_rate'
|
79
83
|
require 'quickbooks/model/term'
|
80
84
|
require 'quickbooks/model/markup_info'
|
81
85
|
require 'quickbooks/model/group_line_detail'
|
@@ -97,10 +101,10 @@ require 'quickbooks/model/tax_agency'
|
|
97
101
|
require 'quickbooks/model/tax_service'
|
98
102
|
require 'quickbooks/model/tax_code'
|
99
103
|
require 'quickbooks/model/fault'
|
104
|
+
require 'quickbooks/model/refund_receipt'
|
100
105
|
require 'quickbooks/model/batch_request'
|
101
106
|
require 'quickbooks/model/batch_response'
|
102
107
|
require 'quickbooks/model/preferences'
|
103
|
-
require 'quickbooks/model/refund_receipt'
|
104
108
|
require 'quickbooks/model/change_model'
|
105
109
|
require 'quickbooks/model/invoice_change'
|
106
110
|
require 'quickbooks/model/customer_change'
|
@@ -111,6 +115,7 @@ require 'quickbooks/model/credit_memo_change'
|
|
111
115
|
require 'quickbooks/model/payment_change'
|
112
116
|
require 'quickbooks/model/transfer'
|
113
117
|
require 'quickbooks/model/change_data_capture'
|
118
|
+
require 'quickbooks/model/refund_receipt_change'
|
114
119
|
|
115
120
|
#== Services
|
116
121
|
require 'quickbooks/service/service_crud'
|
@@ -125,6 +130,7 @@ require 'quickbooks/service/customer'
|
|
125
130
|
require 'quickbooks/service/department'
|
126
131
|
require 'quickbooks/service/invoice'
|
127
132
|
require 'quickbooks/service/deposit'
|
133
|
+
|
128
134
|
require 'quickbooks/service/item'
|
129
135
|
require 'quickbooks/service/budget'
|
130
136
|
require 'quickbooks/service/journal_entry'
|
@@ -136,6 +142,7 @@ require 'quickbooks/service/bill'
|
|
136
142
|
require 'quickbooks/service/bill_payment'
|
137
143
|
require 'quickbooks/service/vendor'
|
138
144
|
require 'quickbooks/service/employee'
|
145
|
+
require 'quickbooks/service/exchange_rate'
|
139
146
|
require 'quickbooks/service/payment'
|
140
147
|
require 'quickbooks/service/term'
|
141
148
|
require 'quickbooks/service/time_activity'
|
@@ -162,6 +169,7 @@ require 'quickbooks/service/credit_memo_change'
|
|
162
169
|
require 'quickbooks/service/payment_change'
|
163
170
|
require 'quickbooks/service/transfer'
|
164
171
|
require 'quickbooks/service/change_data_capture'
|
172
|
+
require 'quickbooks/service/refund_receipt_change'
|
165
173
|
|
166
174
|
module Quickbooks
|
167
175
|
@@sandbox_mode = false
|
@@ -207,15 +215,16 @@ module Quickbooks
|
|
207
215
|
end # << self
|
208
216
|
|
209
217
|
class InvalidModelException < StandardError; end
|
210
|
-
|
211
218
|
class AuthorizationFailure < StandardError; end
|
212
219
|
class Forbidden < StandardError; end
|
213
|
-
|
220
|
+
class ThrottleExceeded < Forbidden; end
|
221
|
+
class TooManyRequests < StandardError; end
|
214
222
|
class ServiceUnavailable < StandardError; end
|
215
223
|
class MissingRealmError < StandardError; end
|
216
224
|
|
217
225
|
class IntuitRequestException < StandardError
|
218
226
|
attr_accessor :message, :code, :detail, :type, :request_xml, :request_json
|
227
|
+
|
219
228
|
def initialize(msg)
|
220
229
|
self.message = msg
|
221
230
|
super(msg)
|
@@ -19,6 +19,7 @@ class Quickbooks::Model::BatchRequest < Quickbooks::Model::BaseModel
|
|
19
19
|
xml_accessor :credit_memo, from: "CreditMemo", as: Quickbooks::Model::CreditMemo
|
20
20
|
xml_accessor :payment, from: "Payment", as: Quickbooks::Model::Payment
|
21
21
|
xml_accessor :time_activity, from: "TimeActivity", as: Quickbooks::Model::TimeActivity
|
22
|
+
xml_accessor :refund_receipt, from: "RefundReceipt", as: Quickbooks::Model::RefundReceipt
|
22
23
|
end
|
23
24
|
|
24
25
|
XML_COLLECTION_NODE = "IntuitBatchRequest"
|
@@ -18,6 +18,7 @@ class Quickbooks::Model::BatchResponse < Quickbooks::Model::BaseModel
|
|
18
18
|
xml_accessor :credit_memo, from: "CreditMemo", as: Quickbooks::Model::CreditMemo
|
19
19
|
xml_accessor :payment, from: "Payment", as: Quickbooks::Model::Payment
|
20
20
|
xml_accessor :time_activity, from: "TimeActivity", as: Quickbooks::Model::TimeActivity
|
21
|
+
xml_accessor :refund_receipt, from: "RefundReceipt", as: Quickbooks::Model::RefundReceipt
|
21
22
|
|
22
23
|
def fault?
|
23
24
|
fault
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class ExchangeRate < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "ExchangeRate"
|
5
|
+
XML_NODE = "ExchangeRate"
|
6
|
+
REST_RESOURCE = "exchangerate"
|
7
|
+
|
8
|
+
xml_accessor :id, :from => "Id"
|
9
|
+
xml_accessor :sync_token, :from => "SyncToken", :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => "MetaData", :as => MetaData
|
11
|
+
|
12
|
+
xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
|
13
|
+
xml_accessor :source_currency_code, :from => 'SourceCurrencyCode'
|
14
|
+
xml_accessor :target_currency_code, :from => 'TargetCurrencyCode'
|
15
|
+
xml_accessor :rate, :from => 'Rate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
16
|
+
xml_accessor :as_of_date, :from => 'AsOfDate', :as => Date
|
17
|
+
|
18
|
+
validates_presence_of :source_currency_code, :rate, :as_of_date
|
19
|
+
validates_length_of :source_currency_code, :is => 3
|
20
|
+
validates_length_of :target_currency_code, :is => 3
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -48,6 +48,7 @@ module Quickbooks
|
|
48
48
|
xml_accessor :print_status, :from => 'PrintStatus'
|
49
49
|
xml_accessor :email_status, :from => 'EmailStatus'
|
50
50
|
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
51
|
+
xml_accessor :home_balance, :from => 'HomeBalance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
51
52
|
xml_accessor :deposit, :from => 'Deposit', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
52
53
|
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
53
54
|
xml_accessor :allow_ipn_payment?, :from => 'AllowIPNPayment'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Quickbooks
|
2
2
|
module Model
|
3
|
-
# Refer to:
|
3
|
+
# Refer to:
|
4
|
+
# - https://developer.intuit.com/docs/0100_quickbooks_online/0200_dev_guides/accounting/change_data_capture
|
4
5
|
class InvoiceChange < ChangeModel
|
5
6
|
XML_NODE = "Invoice"
|
6
7
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class InvoiceGroupLineDetail < InvoiceLineItem
|
4
|
+
include HasLineItems
|
5
|
+
|
6
|
+
xml_accessor :id, :from => 'Id'
|
7
|
+
xml_accessor :group_item_ref, :from => 'GroupItemRef', :as => BaseReference
|
8
|
+
xml_accessor :quantity, :from => 'Quantity', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
9
|
+
xml_accessor :line_items, :from => 'Line', :as => [InvoiceLineItem]
|
10
|
+
|
11
|
+
reference_setters :group_item_ref
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module Quickbooks
|
2
2
|
module Model
|
3
3
|
class InvoiceLineItem < BaseModel
|
4
|
+
require 'quickbooks/model/invoice_group_line_detail'
|
4
5
|
|
5
6
|
#== Constants
|
6
7
|
SALES_LINE_ITEM_DETAIL = 'SalesItemLineDetail'
|
7
8
|
SUB_TOTAL_LINE_DETAIL = 'SubTotalLineDetail'
|
8
9
|
PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
|
9
10
|
DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'
|
11
|
+
INVOICE_GROUP_LINE_DETAIL = 'GroupLineDetail'
|
10
12
|
|
11
13
|
xml_accessor :id, :from => 'Id'
|
12
14
|
xml_accessor :line_num, :from => 'LineNum', :as => Integer
|
@@ -19,6 +21,11 @@ module Quickbooks
|
|
19
21
|
xml_accessor :sub_total_line_detail, :from => 'SubTotalLineDetail', :as => SubTotalLineDetail
|
20
22
|
xml_accessor :payment_line_detail, :from => 'PaymentLineDetail', :as => PaymentLineDetail
|
21
23
|
xml_accessor :discount_line_detail, :from => 'DiscountLineDetail', :as => DiscountLineDetail
|
24
|
+
xml_accessor :group_line_detail, :from => INVOICE_GROUP_LINE_DETAIL, :as => InvoiceGroupLineDetail
|
25
|
+
|
26
|
+
def group_line_detail?
|
27
|
+
detail_type.to_s == INVOICE_GROUP_LINE_DETAIL
|
28
|
+
end
|
22
29
|
|
23
30
|
def sales_item?
|
24
31
|
detail_type.to_s == SALES_LINE_ITEM_DETAIL
|
@@ -39,6 +46,13 @@ module Quickbooks
|
|
39
46
|
yield self.sales_line_item_detail if block_given?
|
40
47
|
end
|
41
48
|
|
49
|
+
def group_line_detail!
|
50
|
+
self.detail_type = INVOICE_GROUP_LINE_DETAIL
|
51
|
+
self.group_line_detail = InvoiceGroupLineDetail.new
|
52
|
+
|
53
|
+
yield self.group_line_detail if block_given?
|
54
|
+
end
|
55
|
+
|
42
56
|
def payment_item!
|
43
57
|
self.detail_type = PAYMENT_LINE_DETAIL
|
44
58
|
self.payment_line_detail = PaymentLineDetail.new
|
@@ -52,7 +66,6 @@ module Quickbooks
|
|
52
66
|
|
53
67
|
yield self.discount_line_detail if block_given?
|
54
68
|
end
|
55
|
-
|
56
69
|
end
|
57
70
|
end
|
58
71
|
end
|
@@ -49,6 +49,10 @@ module Quickbooks
|
|
49
49
|
xml_accessor :purchase_tax_code_ref, :from => 'PurchaseTaxCodeRef', :as => BaseReference
|
50
50
|
xml_accessor :inv_start_date, :from => 'InvStartDate', :as => Date
|
51
51
|
|
52
|
+
xml_accessor :print_grouped_items?, :from => 'PrintGroupedItems'
|
53
|
+
|
54
|
+
xml_accessor :item_group_details, :from => 'ItemGroupDetail', :as => ItemGroupDetail
|
55
|
+
|
52
56
|
reference_setters :parent_ref, :income_account_ref, :expense_account_ref
|
53
57
|
reference_setters :asset_account_ref, :sales_tax_code_ref, :purchase_tax_code_ref
|
54
58
|
|
@@ -78,7 +82,6 @@ module Quickbooks
|
|
78
82
|
end
|
79
83
|
errors.empty?
|
80
84
|
end
|
81
|
-
|
82
85
|
end
|
83
86
|
end
|
84
87
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class ItemGroupLine < BaseModel
|
4
|
+
xml_accessor :item_ref, :from => 'ItemRef', :as => BaseReference
|
5
|
+
xml_accessor :quantity, :from => 'Qty'
|
6
|
+
|
7
|
+
def id
|
8
|
+
item_ref.value.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
item_ref.name
|
13
|
+
end
|
14
|
+
|
15
|
+
def type
|
16
|
+
item_ref.type
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -268,9 +268,16 @@ module Quickbooks
|
|
268
268
|
when 401
|
269
269
|
raise Quickbooks::AuthorizationFailure
|
270
270
|
when 403
|
271
|
-
|
271
|
+
message = parse_intuit_error[:message]
|
272
|
+
if message.include?('ThrottleExceeded')
|
273
|
+
raise Quickbooks::ThrottleExceeded, message
|
274
|
+
end
|
275
|
+
raise Quickbooks::Forbidden, message
|
272
276
|
when 400, 500
|
273
277
|
parse_and_raise_exception(options)
|
278
|
+
when 429
|
279
|
+
message = parse_intuit_error[:message]
|
280
|
+
raise Quickbooks::TooManyRequests, message
|
274
281
|
when 503, 504
|
275
282
|
raise Quickbooks::ServiceUnavailable
|
276
283
|
else
|
@@ -3,7 +3,7 @@ module Quickbooks
|
|
3
3
|
class Batch < BaseService
|
4
4
|
|
5
5
|
def make_request(entity, options = {})
|
6
|
-
response = do_http_post(url_for_resource('batch'), valid_xml_document(entity.to_xml_ns))
|
6
|
+
response = do_http_post(url_for_resource('batch'), valid_xml_document(entity.to_xml_ns), options[:query])
|
7
7
|
Quickbooks::Model::BatchResponse.from_xml(response.plain_body)
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Service
|
3
|
+
class ExchangeRate < BaseService
|
4
|
+
|
5
|
+
def fetch_by_currency(source_currency_code, as_of_date = nil)
|
6
|
+
url = url_for_resource(model::REST_RESOURCE)
|
7
|
+
params = { sourcecurrencycode: source_currency_code }
|
8
|
+
params[:asofdate] = as_of_date unless as_of_date.nil?
|
9
|
+
|
10
|
+
response = do_http_get(url, params)
|
11
|
+
if response.code.to_i == 200
|
12
|
+
model.from_xml(parse_singular_entity_response(model, response.plain_body))
|
13
|
+
else
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def model
|
21
|
+
Quickbooks::Model::ExchangeRate
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
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.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Caughlan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: activemodel
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - <
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 5.0.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
|
-
version:
|
68
|
+
version: 5.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: multipart-post
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,16 +199,20 @@ files:
|
|
199
199
|
- lib/quickbooks/model/entity.rb
|
200
200
|
- lib/quickbooks/model/entity_ref.rb
|
201
201
|
- lib/quickbooks/model/estimate.rb
|
202
|
+
- lib/quickbooks/model/exchange_rate.rb
|
202
203
|
- lib/quickbooks/model/fault.rb
|
203
204
|
- lib/quickbooks/model/global_tax_calculation.rb
|
204
205
|
- lib/quickbooks/model/group_line_detail.rb
|
205
206
|
- lib/quickbooks/model/has_line_items.rb
|
206
207
|
- lib/quickbooks/model/invoice.rb
|
207
208
|
- lib/quickbooks/model/invoice_change.rb
|
209
|
+
- lib/quickbooks/model/invoice_group_line_detail.rb
|
208
210
|
- lib/quickbooks/model/invoice_line_item.rb
|
209
211
|
- lib/quickbooks/model/item.rb
|
210
212
|
- lib/quickbooks/model/item_based_expense_line_detail.rb
|
211
213
|
- lib/quickbooks/model/item_change.rb
|
214
|
+
- lib/quickbooks/model/item_group_detail.rb
|
215
|
+
- lib/quickbooks/model/item_group_line.rb
|
212
216
|
- lib/quickbooks/model/journal_entry.rb
|
213
217
|
- lib/quickbooks/model/journal_entry_line_detail.rb
|
214
218
|
- lib/quickbooks/model/line.rb
|
@@ -228,6 +232,7 @@ files:
|
|
228
232
|
- lib/quickbooks/model/purchase_order.rb
|
229
233
|
- lib/quickbooks/model/purchase_tax_rate_list.rb
|
230
234
|
- lib/quickbooks/model/refund_receipt.rb
|
235
|
+
- lib/quickbooks/model/refund_receipt_change.rb
|
231
236
|
- lib/quickbooks/model/report.rb
|
232
237
|
- lib/quickbooks/model/sales_item_line_detail.rb
|
233
238
|
- lib/quickbooks/model/sales_receipt.rb
|
@@ -273,6 +278,7 @@ files:
|
|
273
278
|
- lib/quickbooks/service/deposit.rb
|
274
279
|
- lib/quickbooks/service/employee.rb
|
275
280
|
- lib/quickbooks/service/estimate.rb
|
281
|
+
- lib/quickbooks/service/exchange_rate.rb
|
276
282
|
- lib/quickbooks/service/invoice.rb
|
277
283
|
- lib/quickbooks/service/invoice_change.rb
|
278
284
|
- lib/quickbooks/service/item.rb
|
@@ -285,6 +291,7 @@ files:
|
|
285
291
|
- lib/quickbooks/service/purchase.rb
|
286
292
|
- lib/quickbooks/service/purchase_order.rb
|
287
293
|
- lib/quickbooks/service/refund_receipt.rb
|
294
|
+
- lib/quickbooks/service/refund_receipt_change.rb
|
288
295
|
- lib/quickbooks/service/reports.rb
|
289
296
|
- lib/quickbooks/service/sales_receipt.rb
|
290
297
|
- lib/quickbooks/service/service_crud.rb
|