quickbooks-ruby 0.1.3 → 0.1.4
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 +15 -14
- data/lib/quickbooks/model/base_model.rb +16 -0
- data/lib/quickbooks/model/bill.rb +1 -1
- data/lib/quickbooks/model/bill_line_item.rb +6 -0
- data/lib/quickbooks/model/bill_payment.rb +1 -1
- data/lib/quickbooks/model/credit_memo.rb +7 -3
- data/lib/quickbooks/model/customer.rb +3 -1
- data/lib/quickbooks/model/entity.rb +16 -0
- data/lib/quickbooks/model/estimate.rb +1 -1
- data/lib/quickbooks/model/invoice.rb +2 -3
- data/lib/quickbooks/model/item_based_expense_line_detail.rb +2 -0
- data/lib/quickbooks/model/journal_entry.rb +30 -0
- data/lib/quickbooks/model/journal_entry_line_detail.rb +27 -0
- data/lib/quickbooks/model/line.rb +2 -0
- data/lib/quickbooks/model/preferences.rb +49 -0
- data/lib/quickbooks/model/refund_receipt.rb +59 -0
- data/lib/quickbooks/model/sales_receipt.rb +2 -2
- data/lib/quickbooks/model/telephone_number.rb +6 -0
- data/lib/quickbooks/model/validator.rb +6 -0
- data/lib/quickbooks/service/base_service.rb +3 -1
- data/lib/quickbooks/service/credit_memo.rb +5 -1
- data/lib/quickbooks/service/journal_entry.rb +16 -0
- data/lib/quickbooks/service/preferences.rb +12 -0
- data/lib/quickbooks/service/purchase_order.rb +6 -2
- data/lib/quickbooks/service/refund_receipt.rb +12 -0
- data/lib/quickbooks/service/service_crud.rb +11 -1
- data/lib/quickbooks/util/collection.rb +16 -0
- data/lib/quickbooks/util/name_entity.rb +32 -0
- data/lib/quickbooks/version.rb +1 -1
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e0e5a4d254a49ea8f633ba0b70a4b20c11a7a29
|
4
|
+
data.tar.gz: bb4b11ecdaf0d0b98b9074102b175a0954c3b386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78b84c571e4b68904be22000788b7240ad9ca6154cd49cd30af99e30b31a953a4250a7cd74a9ad30a770b943707b643a4b5dc82ce46b0e1d59c8120f51b9c994
|
7
|
+
data.tar.gz: b759d252cffacd0466c4d9d98adecf900e262814fd3ec697423e899291fd0685a4ba1f5f7f4c8077b7cf570cee551e778636b5edfe48f367fcb4d1939e560492
|
data/lib/quickbooks-ruby.rb
CHANGED
@@ -7,12 +7,14 @@ require 'uri'
|
|
7
7
|
require 'date'
|
8
8
|
require 'forwardable'
|
9
9
|
require 'oauth'
|
10
|
+
require 'quickbooks/util/collection'
|
10
11
|
require 'quickbooks/util/logging'
|
11
12
|
require 'quickbooks/util/http_encoding_helper'
|
12
13
|
require 'quickbooks/util/name_entity'
|
13
14
|
require 'quickbooks/util/query_builder'
|
14
15
|
|
15
16
|
#== Models
|
17
|
+
require 'quickbooks/model/validator'
|
16
18
|
require 'quickbooks/model/base_model'
|
17
19
|
require 'quickbooks/model/base_reference'
|
18
20
|
require 'quickbooks/model/document_numbering'
|
@@ -27,8 +29,15 @@ require 'quickbooks/model/discount_line_detail'
|
|
27
29
|
require 'quickbooks/model/discount_override'
|
28
30
|
require 'quickbooks/model/payment_line_detail'
|
29
31
|
require 'quickbooks/model/account_based_expense_line_detail'
|
32
|
+
require 'quickbooks/model/item_based_expense_line_detail'
|
30
33
|
require 'quickbooks/model/linked_transaction'
|
34
|
+
require 'quickbooks/model/tax_line_detail'
|
35
|
+
require 'quickbooks/model/tax_line'
|
36
|
+
require 'quickbooks/model/transaction_tax_detail'
|
37
|
+
require 'quickbooks/model/entity'
|
38
|
+
require 'quickbooks/model/journal_entry_line_detail'
|
31
39
|
require 'quickbooks/model/line'
|
40
|
+
require 'quickbooks/model/journal_entry'
|
32
41
|
require 'quickbooks/model/item'
|
33
42
|
require 'quickbooks/model/account'
|
34
43
|
require 'quickbooks/model/check_payment'
|
@@ -57,10 +66,7 @@ require 'quickbooks/model/term'
|
|
57
66
|
require 'quickbooks/model/markup_info'
|
58
67
|
require 'quickbooks/model/group_line_detail'
|
59
68
|
require 'quickbooks/model/item_based_expense_line_detail'
|
60
|
-
require 'quickbooks/model/tax_line_detail'
|
61
|
-
require 'quickbooks/model/tax_line'
|
62
69
|
require 'quickbooks/model/time_activity'
|
63
|
-
require 'quickbooks/model/transaction_tax_detail'
|
64
70
|
require 'quickbooks/model/purchase_line_item'
|
65
71
|
require 'quickbooks/model/purchase'
|
66
72
|
require 'quickbooks/model/purchase_order'
|
@@ -74,6 +80,8 @@ require 'quickbooks/model/tax_code'
|
|
74
80
|
require 'quickbooks/model/fault'
|
75
81
|
require 'quickbooks/model/batch_request'
|
76
82
|
require 'quickbooks/model/batch_response'
|
83
|
+
require 'quickbooks/model/preferences'
|
84
|
+
require 'quickbooks/model/refund_receipt'
|
77
85
|
|
78
86
|
#== Services
|
79
87
|
require 'quickbooks/service/service_crud'
|
@@ -85,6 +93,7 @@ require 'quickbooks/service/customer'
|
|
85
93
|
require 'quickbooks/service/department'
|
86
94
|
require 'quickbooks/service/invoice'
|
87
95
|
require 'quickbooks/service/item'
|
96
|
+
require 'quickbooks/service/journal_entry'
|
88
97
|
require 'quickbooks/service/sales_receipt'
|
89
98
|
require 'quickbooks/service/account'
|
90
99
|
require 'quickbooks/service/payment_method'
|
@@ -103,6 +112,8 @@ require 'quickbooks/service/estimate'
|
|
103
112
|
require 'quickbooks/service/tax_rate'
|
104
113
|
require 'quickbooks/service/tax_code'
|
105
114
|
require 'quickbooks/service/batch'
|
115
|
+
require 'quickbooks/service/preferences'
|
116
|
+
require 'quickbooks/service/refund_receipt'
|
106
117
|
|
107
118
|
module Quickbooks
|
108
119
|
@@logger = nil
|
@@ -142,6 +153,7 @@ module Quickbooks
|
|
142
153
|
class AuthorizationFailure < StandardError; end
|
143
154
|
|
144
155
|
class ServiceUnavailable < StandardError; end
|
156
|
+
class MissingRealmError < StandardError; end
|
145
157
|
|
146
158
|
class IntuitRequestException < StandardError
|
147
159
|
attr_accessor :message, :code, :detail, :type, :request_xml
|
@@ -151,15 +163,4 @@ module Quickbooks
|
|
151
163
|
end
|
152
164
|
end
|
153
165
|
|
154
|
-
|
155
|
-
class Collection
|
156
|
-
attr_accessor :entries
|
157
|
-
|
158
|
-
# Legacy Attributes (v2)
|
159
|
-
attr_accessor :count, :current_page
|
160
|
-
|
161
|
-
# v3 Attributes
|
162
|
-
attr_accessor :start_position, :max_results, :total_count
|
163
|
-
end
|
164
|
-
|
165
166
|
end
|
@@ -2,6 +2,7 @@ module Quickbooks
|
|
2
2
|
module Model
|
3
3
|
class BaseModel
|
4
4
|
include ActiveModel::Validations
|
5
|
+
include Validator
|
5
6
|
include ROXML
|
6
7
|
|
7
8
|
xml_convention :camelcase
|
@@ -45,6 +46,12 @@ module Quickbooks
|
|
45
46
|
self.line_items ||= []
|
46
47
|
end
|
47
48
|
|
49
|
+
def inspect
|
50
|
+
# it would be nice if we could inspect all the children,
|
51
|
+
# but it's likely to blow the stack in some cases
|
52
|
+
"#<#{self.class} " +
|
53
|
+
"#{attributes.map{|k,v| "#{k}: #{v.nil? ? 'nil' : v.to_s }"}.join ", "}>"
|
54
|
+
end
|
48
55
|
class << self
|
49
56
|
def to_xml_big_decimal
|
50
57
|
Proc.new { |val| val.nil? ? nil : val.to_f }
|
@@ -84,6 +91,15 @@ module Quickbooks
|
|
84
91
|
end
|
85
92
|
end
|
86
93
|
|
94
|
+
def inspect
|
95
|
+
"#{super}(#{attrs_with_types.join " "})"
|
96
|
+
end
|
97
|
+
def attrs_with_types
|
98
|
+
roxml_attrs.map do |attr|
|
99
|
+
"#{attr.accessor}:" +
|
100
|
+
"#{attr.class.block_shorthands.invert[attr.blocks.last]}:#{attr.sought_type}"
|
101
|
+
end
|
102
|
+
end
|
87
103
|
end
|
88
104
|
end
|
89
105
|
end
|
@@ -29,7 +29,7 @@ module Quickbooks
|
|
29
29
|
xml_accessor :reply_email, :from => 'ReplyEmail', :as => EmailAddress
|
30
30
|
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
31
31
|
|
32
|
-
|
32
|
+
validate :line_item_size
|
33
33
|
|
34
34
|
reference_setters :department_ref, :vendor_ref, :payer_ref, :sales_term_ref
|
35
35
|
end
|
@@ -4,6 +4,7 @@ module Quickbooks
|
|
4
4
|
|
5
5
|
#== Constants
|
6
6
|
ACCOUNT_BASED_EXPENSE_LINE_DETAIL = 'AccountBasedExpenseLineDetail'
|
7
|
+
ITEM_BASED_EXPENSE_LINE_DETAIL = 'ItemBasedExpenseLineDetail'
|
7
8
|
|
8
9
|
xml_accessor :id, :from => 'Id', :as => Integer
|
9
10
|
xml_accessor :line_num, :from => 'LineNum', :as => Integer
|
@@ -13,11 +14,16 @@ module Quickbooks
|
|
13
14
|
|
14
15
|
#== Various detail types
|
15
16
|
xml_accessor :account_based_expense_line_detail, :from => 'AccountBasedExpenseLineDetail', :as => AccountBasedExpenseLineDetail
|
17
|
+
xml_accessor :item_based_expense_line_detail, :from => 'ItemBasedExpenseLineDetail', :as => ItemBasedExpenseLineDetail
|
16
18
|
|
17
19
|
def account_based_expense_item?
|
18
20
|
detail_type.to_s == ACCOUNT_BASED_EXPENSE_LINE_DETAIL
|
19
21
|
end
|
20
22
|
|
23
|
+
def item_based_expense_item?
|
24
|
+
detail_type.to_s == ITEM_BASED_EXPENSE_LINE_DETAIL
|
25
|
+
end
|
26
|
+
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Quickbooks
|
2
2
|
module Model
|
3
3
|
class CreditMemo < BaseModel
|
4
|
+
include DocumentNumbering
|
4
5
|
XML_COLLECTION_NODE = "CreditMemo"
|
5
6
|
XML_NODE = "CreditMemo"
|
6
7
|
REST_RESOURCE = 'creditmemo'
|
@@ -8,13 +9,15 @@ module Quickbooks
|
|
8
9
|
xml_accessor :id, :from => 'Id', :as => Integer
|
9
10
|
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
10
11
|
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
12
|
+
xml_accessor :auto_doc_number, :from => 'AutoDocNumber' # See auto_doc_number! method below for usage
|
11
13
|
xml_accessor :doc_number, :from => 'DocNumber'
|
12
14
|
#xml_accessor :txn_date, :from => 'TxnDate', :as => Date
|
13
15
|
# TODO: Next major version 'placed_on' should be replaced by 'txn_date'
|
14
16
|
xml_accessor :placed_on, :from => 'TxnDate', :as => Date
|
17
|
+
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
15
18
|
|
16
19
|
xml_accessor :line_items, :from => 'Line', :as => [Line]
|
17
|
-
|
20
|
+
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
18
21
|
xml_accessor :private_note, :from => 'PrivateNote'
|
19
22
|
|
20
23
|
xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
|
@@ -28,9 +31,10 @@ module Quickbooks
|
|
28
31
|
# readonly
|
29
32
|
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
30
33
|
|
31
|
-
|
34
|
+
validate :line_item_size
|
35
|
+
validate :document_numbering
|
32
36
|
|
33
|
-
reference_setters :customer_ref, :sales_term_ref, :deposit_to_account_ref, :payment_method_ref
|
37
|
+
reference_setters :department_ref, :customer_ref, :sales_term_ref, :deposit_to_account_ref, :payment_method_ref
|
34
38
|
|
35
39
|
def initialize(*args)
|
36
40
|
ensure_line_items_initialization
|
@@ -50,13 +50,15 @@ module Quickbooks
|
|
50
50
|
xml_accessor :suffix, :from => 'Suffix'
|
51
51
|
xml_accessor :fully_qualified_name, :from => 'FullyQualifiedName'
|
52
52
|
xml_accessor :taxable, :from => 'Taxable'
|
53
|
+
xml_accessor :default_tax_code_ref, :from => 'DefaultTaxCodeRef', :as => BaseReference
|
53
54
|
xml_accessor :notes, :from => 'Notes'
|
55
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
54
56
|
|
55
57
|
#== Validations
|
56
58
|
validate :names_cannot_contain_invalid_characters
|
57
59
|
validate :email_address_is_valid
|
58
60
|
|
59
|
-
reference_setters :parent_ref, :sales_term_ref, :payment_method_ref
|
61
|
+
reference_setters :parent_ref, :sales_term_ref, :payment_method_ref, :default_tax_code_ref, :currency_ref
|
60
62
|
|
61
63
|
def job?
|
62
64
|
job.to_s == 'true'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class Entity < BaseModel
|
4
|
+
include NameEntity::Quality
|
5
|
+
|
6
|
+
xml_accessor :type, :from => 'Type'
|
7
|
+
xml_accessor :entity_ref, :from => 'EntityRef'
|
8
|
+
|
9
|
+
reference_setters :entity_ref
|
10
|
+
|
11
|
+
#== Validations
|
12
|
+
validate :entity_type_is_valid
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -49,7 +49,7 @@ module Quickbooks
|
|
49
49
|
reference_setters :department_ref, :customer_ref, :class_ref, :sales_term_ref, :ship_method_ref
|
50
50
|
|
51
51
|
#== Validations
|
52
|
-
|
52
|
+
validate :line_item_size
|
53
53
|
validate :existence_of_customer_ref
|
54
54
|
|
55
55
|
def initialize(*args)
|
@@ -8,7 +8,7 @@
|
|
8
8
|
module Quickbooks
|
9
9
|
module Model
|
10
10
|
class Invoice < BaseModel
|
11
|
-
|
11
|
+
include DocumentNumbering
|
12
12
|
#== Constants
|
13
13
|
REST_RESOURCE = 'invoice'
|
14
14
|
XML_COLLECTION_NODE = "Invoice"
|
@@ -51,12 +51,11 @@ module Quickbooks
|
|
51
51
|
xml_accessor :allow_online_credit_card_payment?, :from => 'AllowOnlineCreditCardPayment'
|
52
52
|
xml_accessor :allow_online_ach_payment?, :from => 'AllowOnlineACHPayment'
|
53
53
|
|
54
|
-
include DocumentNumbering
|
55
54
|
reference_setters :customer_ref, :class_ref, :sales_term_ref, :ship_method_ref
|
56
55
|
reference_setters :ar_account_ref, :department_ref, :ar_account_ref, :currency_ref
|
57
56
|
|
58
57
|
#== Validations
|
59
|
-
|
58
|
+
validate :line_item_size
|
60
59
|
validate :existence_of_customer_ref
|
61
60
|
validate :required_bill_email_if_email_delivery
|
62
61
|
validate :document_numbering
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class JournalEntry < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "JournalEntry"
|
5
|
+
XML_NODE = "JournalEntry"
|
6
|
+
REST_RESOURCE = 'journalentry'
|
7
|
+
|
8
|
+
xml_accessor :id, :from => 'Id', :as => Integer
|
9
|
+
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
11
|
+
xml_accessor :doc_number, :from => 'DocNumber'
|
12
|
+
xml_accessor :txn_date, :from => 'TxnDate', :as => Date
|
13
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
14
|
+
xml_accessor :private_note, :from => 'PrivateNote'
|
15
|
+
xml_accessor :line_items, :from => 'Line', :as => [Line]
|
16
|
+
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
17
|
+
|
18
|
+
# Readonly
|
19
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
20
|
+
xml_accessor :total_amount, :from => 'TotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
21
|
+
xml_accessor :home_total, :from => 'HomeTotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
22
|
+
|
23
|
+
xml_accessor :adjustment?, :from => 'Adjustment'
|
24
|
+
|
25
|
+
reference_setters :currency_ref
|
26
|
+
|
27
|
+
validates_length_of :private_note, :maximum => 4000
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class JournalEntryLineDetail < BaseModel
|
4
|
+
include NameEntity::Quality
|
5
|
+
|
6
|
+
xml_accessor :posting_type, :from => 'PostingType'
|
7
|
+
xml_accessor :entity, :from => 'Entity', :as => Entity
|
8
|
+
xml_accessor :account_ref, :from => 'AccountRef', :as => BaseReference
|
9
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
10
|
+
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
11
|
+
|
12
|
+
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
|
13
|
+
xml_accessor :tax_applicable_on, :from => 'TaxApplicableOn'
|
14
|
+
xml_accessor :tax_amount, :from => 'TaxAmount', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
15
|
+
|
16
|
+
xml_accessor :billable_status, :from => 'BillableStatus'
|
17
|
+
|
18
|
+
reference_setters :account_ref, :class_ref, :department_ref, :tax_code_ref
|
19
|
+
|
20
|
+
validates_length_of :description, :maximum => 4000
|
21
|
+
validates_numericality_of :tax_amount, allow_nil: true, greater_than_or_equal_to:0.0, less_than_or_equal_to:999999999.0
|
22
|
+
validate :posting_type_is_valid
|
23
|
+
validate :billable_status_is_valid
|
24
|
+
validate :journal_line_entry_tax
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -6,6 +6,7 @@ module Quickbooks
|
|
6
6
|
SUB_TOTAL_LINE_DETAIL = 'SubTotalLineDetail'
|
7
7
|
PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
|
8
8
|
DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'
|
9
|
+
JOURNAL_ENTRY_LINE_DETAIL = 'JournalEntryLineDetail'
|
9
10
|
|
10
11
|
xml_accessor :id, :from => 'Id', :as => Integer
|
11
12
|
xml_accessor :line_num, :from => 'LineNum', :as => Integer
|
@@ -19,6 +20,7 @@ module Quickbooks
|
|
19
20
|
xml_accessor :sub_total_line_detail, :from => 'SubTotalLineDetail', :as => SubTotalLineDetail
|
20
21
|
xml_accessor :payment_line_detail, :from => 'PaymentLineDetail', :as => PaymentLineDetail
|
21
22
|
xml_accessor :discount_line_detail, :from => 'DiscountLineDetail', :as => DiscountOverride
|
23
|
+
xml_accessor :journal_entry_line_detail, :from => 'JournalEntryLineDetail', :as => JournalEntryLineDetail
|
22
24
|
xml_accessor :linked_transaction, :from => 'LinkedTxn', :as => LinkedTransaction
|
23
25
|
|
24
26
|
def invoice_id=(invoice_id)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class Preferences < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "Preferences"
|
5
|
+
XML_NODE = "Preferences"
|
6
|
+
REST_RESOURCE = 'preferences'
|
7
|
+
|
8
|
+
xml_name XML_NODE
|
9
|
+
|
10
|
+
def self.create_preference_class(*attrs, &block)
|
11
|
+
::Class.new(BaseModel) do
|
12
|
+
attrs.each do |a|
|
13
|
+
xml_reader(a.underscore, :from => a.gsub("?", ""))
|
14
|
+
end
|
15
|
+
instance_eval(&block) if block_given?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
PREFERENCE_SECTIONS = {
|
20
|
+
:accounting_info => %w(TrackDepartments DepartmentTerminology ClassTrackingPerTxnLine? ClassTrackingPerTxn? CustomerTerminology),
|
21
|
+
:product_and_services => %w(ForSales? ForPurchase? QuantityWithPriceAndRate? QuantityOnHand?),
|
22
|
+
:sales_forms => %w(CustomTxnNumbers? AllowDeposit? AllowDiscount? DefaultDiscountAccount? AllowEstimates? EstimateMessage?
|
23
|
+
ETransactionEnabledStatus? ETransactionAttachPDF? ETransactionPaymentEnabled? IPNSupportEnabled?
|
24
|
+
AllowServiceDate? AllowShipping? DefaultShippingAccount? DefaultTerms DefaultCustomerMessage),
|
25
|
+
:vendor_and_purchase => %w(TrackingByCustomer? BillableExpenseTracking? DefaultTerms? DefaultMarkup? POCustomField),
|
26
|
+
:time_tracking => %w(UseServices? BillCustomers? ShowBillRateToAll WorkWeekStartDate MarkTimeEntiresBillable?),
|
27
|
+
:tax => %w(UsingSalesTax?),
|
28
|
+
:currency => %w(MultiCurrencyEnabled? HomeCurrency),
|
29
|
+
:report => %w(ReportBasis)
|
30
|
+
}
|
31
|
+
|
32
|
+
PREFERENCE_SECTIONS.each do |section_name, fields|
|
33
|
+
xml_reader section_name, :from => "#{section_name}_prefs".camelize, :as => create_preference_class(*fields)
|
34
|
+
end
|
35
|
+
|
36
|
+
EmailMessage = create_preference_class("Subject", "Message")
|
37
|
+
EmailMessageContainer = create_preference_class do
|
38
|
+
%w(InvoiceMessage EstimateMessage SalesReceiptMessage StatementMessage).each do |msg|
|
39
|
+
xml_reader msg.underscore, :from => msg, :as => EmailMessage
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
xml_reader :email_messages, :from => "EmailMessagesPrefs", as: EmailMessageContainer
|
44
|
+
|
45
|
+
xml_reader :other_prefs, :from => "OtherPrefs/NameValue", :as => { :key => "Name", :value => "Value" }
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class RefundReceipt < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "RefundReceipt"
|
5
|
+
XML_NODE = "RefundReceipt"
|
6
|
+
REST_RESOURCE = 'refundreceipt'
|
7
|
+
|
8
|
+
xml_accessor :id, :from => 'Id', :as => Integer
|
9
|
+
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
11
|
+
xml_accessor :auto_doc_number, :from => 'AutoDocNumber' # See auto_doc_number! method below for usage
|
12
|
+
xml_accessor :doc_number, :from => 'DocNumber'
|
13
|
+
xml_accessor :placed_on, :from => 'TxnDate', :as => Time
|
14
|
+
xml_accessor :line_items, :from => 'Line', :as => [Line]
|
15
|
+
xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
|
16
|
+
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
17
|
+
xml_accessor :bill_email, :from => 'BillEmail', :as => EmailAddress
|
18
|
+
xml_accessor :bill_address, :from => 'BillAddr', :as => PhysicalAddress
|
19
|
+
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
20
|
+
xml_accessor :po_number, :from => 'PONumber'
|
21
|
+
xml_accessor :ship_method_ref, :from => 'ShipMethodRef'
|
22
|
+
xml_accessor :ship_date, :from => 'ShipDate', :as => Time
|
23
|
+
xml_accessor :tracking_num, :from => 'TrackingNum'
|
24
|
+
xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
|
25
|
+
xml_accessor :payment_ref_number, :from => 'PaymentRefNum'
|
26
|
+
xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
|
27
|
+
xml_accessor :customer_memo, :from => 'CustomerMemo'
|
28
|
+
xml_accessor :private_note, :from => 'PrivateNote'
|
29
|
+
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
30
|
+
xml_accessor :txn_date, :from => 'TxnDate', :as => Date
|
31
|
+
xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
|
32
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
33
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
34
|
+
xml_accessor :apply_tax_after_discount?, :from => 'ApplyTaxAfterDiscount'
|
35
|
+
xml_accessor :print_status, :from => 'PrintStatus'
|
36
|
+
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
37
|
+
|
38
|
+
# readonly
|
39
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
40
|
+
xml_accessor :home_total, :from => 'HomeTotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
41
|
+
|
42
|
+
include DocumentNumbering
|
43
|
+
reference_setters :customer_ref, :payment_method_ref, :deposit_to_account_ref, :department_ref, :currency_ref, :class_ref
|
44
|
+
|
45
|
+
validate :line_item_size
|
46
|
+
validate :document_numbering
|
47
|
+
|
48
|
+
def initialize(*args)
|
49
|
+
ensure_line_items_initialization
|
50
|
+
super
|
51
|
+
end
|
52
|
+
|
53
|
+
def email=(email)
|
54
|
+
self.bill_email = EmailAddress.new(email)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Quickbooks
|
2
2
|
module Model
|
3
3
|
class SalesReceipt < BaseModel
|
4
|
+
include DocumentNumbering
|
4
5
|
XML_COLLECTION_NODE = "SalesReceipt"
|
5
6
|
XML_NODE = "SalesReceipt"
|
6
7
|
REST_RESOURCE = 'salesreceipt'
|
@@ -29,10 +30,9 @@ module Quickbooks
|
|
29
30
|
# readonly
|
30
31
|
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
31
32
|
|
32
|
-
include DocumentNumbering
|
33
33
|
reference_setters :customer_ref, :payment_method_ref, :deposit_to_account_ref
|
34
34
|
|
35
|
-
|
35
|
+
validate :line_item_size
|
36
36
|
validate :document_numbering
|
37
37
|
|
38
38
|
def initialize(*args)
|
@@ -14,9 +14,10 @@ module Quickbooks
|
|
14
14
|
HTTP_CONTENT_TYPE = 'application/xml'
|
15
15
|
HTTP_ACCEPT = 'application/xml'
|
16
16
|
HTTP_ACCEPT_ENCODING = 'gzip, deflate'
|
17
|
+
BASE_DOMAIN = 'quickbooks.api.intuit.com'
|
17
18
|
|
18
19
|
def initialize(attributes = {})
|
19
|
-
@base_uri =
|
20
|
+
@base_uri = "https://#{BASE_DOMAIN}/v3/company"
|
20
21
|
attributes.each {|key, value| public_send("#{key}=", value) }
|
21
22
|
end
|
22
23
|
|
@@ -38,6 +39,7 @@ module Quickbooks
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def url_for_base
|
42
|
+
raise MissingRealmError.new unless @company_id
|
41
43
|
"#{@base_uri}/#{@company_id}"
|
42
44
|
end
|
43
45
|
|
@@ -6,6 +6,16 @@ module Quickbooks
|
|
6
6
|
fetch_collection(object_query, model, options)
|
7
7
|
end
|
8
8
|
|
9
|
+
def query_in_batches(object_query=nil, options={})
|
10
|
+
page = 0
|
11
|
+
per_page = options.delete(:per_page) || 1_000
|
12
|
+
begin
|
13
|
+
page += 1
|
14
|
+
results = query(object_query, page: page, per_page: per_page)
|
15
|
+
yield results if results.count > 0
|
16
|
+
end until results.count < per_page
|
17
|
+
end
|
18
|
+
|
9
19
|
def fetch_by_id(id, options = {})
|
10
20
|
url = "#{url_for_resource(model.resource_for_singular)}/#{id}"
|
11
21
|
fetch_object(model, url, options)
|
@@ -24,7 +34,7 @@ module Quickbooks
|
|
24
34
|
alias :update :create
|
25
35
|
|
26
36
|
def delete(entity)
|
27
|
-
raise
|
37
|
+
raise NotImplementedError
|
28
38
|
end
|
29
39
|
|
30
40
|
def delete_by_query_string(entity, options = {})
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
class Collection
|
3
|
+
include Enumerable
|
4
|
+
attr_accessor :entries
|
5
|
+
|
6
|
+
# Legacy Attributes (v2)
|
7
|
+
attr_accessor :count, :current_page
|
8
|
+
|
9
|
+
# v3 Attributes
|
10
|
+
attr_accessor :start_position, :max_results, :total_count
|
11
|
+
|
12
|
+
def each(*args, &block)
|
13
|
+
(entries|| []).each *args, &block
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -27,6 +27,38 @@ module NameEntity
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
def posting_type_is_valid
|
32
|
+
if posting_type
|
33
|
+
unless %w(Debit Credit).include?(posting_type)
|
34
|
+
errors.add(:posting_type, "Posting Type must be either 'Debit' or 'Credit'")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def billable_status_is_valid
|
40
|
+
if billable_status
|
41
|
+
unless %w(Billable NotBillable HasBeenBilled).include?(billable_status)
|
42
|
+
errors.add(:posting_type, "Posting Type must be either 'Debit' or 'Credit'")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def entity_type_is_valid
|
48
|
+
if entity_type
|
49
|
+
unless %w(Customer Vendor).include?(entity_type)
|
50
|
+
errors.add(:entity_type, "Entity Type must be either 'Customer' or 'Vendor'")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def journal_line_entry_tax
|
56
|
+
if tax_code_ref
|
57
|
+
# tax_applicable_on must be set
|
58
|
+
errors.add(:tax_applicable_on, "TaxApplicableOn must be set when TaxCodeRef is set") if tax_applicable_on.nil?
|
59
|
+
errors.add(:tax_amount, "TaxAmount must be set when TaxCodeRef is set") if tax_amount.nil?
|
60
|
+
end
|
61
|
+
end
|
30
62
|
end
|
31
63
|
|
32
64
|
module PermitAlterations
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Caughlan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/quickbooks/model/document_numbering.rb
|
197
197
|
- lib/quickbooks/model/email_address.rb
|
198
198
|
- lib/quickbooks/model/employee.rb
|
199
|
+
- lib/quickbooks/model/entity.rb
|
199
200
|
- lib/quickbooks/model/estimate.rb
|
200
201
|
- lib/quickbooks/model/fault.rb
|
201
202
|
- lib/quickbooks/model/group_line_detail.rb
|
@@ -203,6 +204,8 @@ files:
|
|
203
204
|
- lib/quickbooks/model/invoice_line_item.rb
|
204
205
|
- lib/quickbooks/model/item.rb
|
205
206
|
- lib/quickbooks/model/item_based_expense_line_detail.rb
|
207
|
+
- lib/quickbooks/model/journal_entry.rb
|
208
|
+
- lib/quickbooks/model/journal_entry_line_detail.rb
|
206
209
|
- lib/quickbooks/model/line.rb
|
207
210
|
- lib/quickbooks/model/linked_transaction.rb
|
208
211
|
- lib/quickbooks/model/markup_info.rb
|
@@ -212,9 +215,11 @@ files:
|
|
212
215
|
- lib/quickbooks/model/payment_line_detail.rb
|
213
216
|
- lib/quickbooks/model/payment_method.rb
|
214
217
|
- lib/quickbooks/model/physical_address.rb
|
218
|
+
- lib/quickbooks/model/preferences.rb
|
215
219
|
- lib/quickbooks/model/purchase.rb
|
216
220
|
- lib/quickbooks/model/purchase_line_item.rb
|
217
221
|
- lib/quickbooks/model/purchase_order.rb
|
222
|
+
- lib/quickbooks/model/refund_receipt.rb
|
218
223
|
- lib/quickbooks/model/sales_item_line_detail.rb
|
219
224
|
- lib/quickbooks/model/sales_receipt.rb
|
220
225
|
- lib/quickbooks/model/sales_tax_rate_list.rb
|
@@ -228,6 +233,7 @@ files:
|
|
228
233
|
- lib/quickbooks/model/term.rb
|
229
234
|
- lib/quickbooks/model/time_activity.rb
|
230
235
|
- lib/quickbooks/model/transaction_tax_detail.rb
|
236
|
+
- lib/quickbooks/model/validator.rb
|
231
237
|
- lib/quickbooks/model/vendor.rb
|
232
238
|
- lib/quickbooks/model/vendor_credit.rb
|
233
239
|
- lib/quickbooks/model/web_site_address.rb
|
@@ -246,10 +252,13 @@ files:
|
|
246
252
|
- lib/quickbooks/service/estimate.rb
|
247
253
|
- lib/quickbooks/service/invoice.rb
|
248
254
|
- lib/quickbooks/service/item.rb
|
255
|
+
- lib/quickbooks/service/journal_entry.rb
|
249
256
|
- lib/quickbooks/service/payment.rb
|
250
257
|
- lib/quickbooks/service/payment_method.rb
|
258
|
+
- lib/quickbooks/service/preferences.rb
|
251
259
|
- lib/quickbooks/service/purchase.rb
|
252
260
|
- lib/quickbooks/service/purchase_order.rb
|
261
|
+
- lib/quickbooks/service/refund_receipt.rb
|
253
262
|
- lib/quickbooks/service/sales_receipt.rb
|
254
263
|
- lib/quickbooks/service/service_crud.rb
|
255
264
|
- lib/quickbooks/service/tax_code.rb
|
@@ -258,6 +267,7 @@ files:
|
|
258
267
|
- lib/quickbooks/service/time_activity.rb
|
259
268
|
- lib/quickbooks/service/vendor.rb
|
260
269
|
- lib/quickbooks/service/vendor_credit.rb
|
270
|
+
- lib/quickbooks/util/collection.rb
|
261
271
|
- lib/quickbooks/util/http_encoding_helper.rb
|
262
272
|
- lib/quickbooks/util/logging.rb
|
263
273
|
- lib/quickbooks/util/name_entity.rb
|