quickbooks-ruby 0.1.7 → 0.1.8
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 +10 -0
- data/lib/quickbooks/model/account.rb +1 -0
- data/lib/quickbooks/model/base_model.rb +8 -5
- data/lib/quickbooks/model/bill.rb +7 -1
- data/lib/quickbooks/model/bill_line_item.rb +13 -0
- data/lib/quickbooks/model/bill_payment.rb +6 -1
- data/lib/quickbooks/model/bill_payment_credit_card.rb +2 -2
- data/lib/quickbooks/model/company_info.rb +41 -0
- data/lib/quickbooks/model/credit_memo.rb +13 -6
- data/lib/quickbooks/model/customer_change.rb +12 -0
- data/lib/quickbooks/model/estimate.rb +12 -7
- data/lib/quickbooks/model/global_tax_calculation.rb +2 -2
- data/lib/quickbooks/model/has_line_items.rb +14 -0
- data/lib/quickbooks/model/invoice.rb +11 -9
- data/lib/quickbooks/model/invoice_change.rb +12 -0
- data/lib/quickbooks/model/journal_entry.rb +7 -1
- data/lib/quickbooks/model/journal_entry_line_detail.rb +1 -1
- data/lib/quickbooks/model/line.rb +29 -2
- data/lib/quickbooks/model/name_value.rb +8 -0
- data/lib/quickbooks/model/payment.rb +2 -5
- data/lib/quickbooks/model/payment_method.rb +11 -0
- data/lib/quickbooks/model/purchase.rb +11 -2
- data/lib/quickbooks/model/purchase_line_item.rb +24 -2
- data/lib/quickbooks/model/purchase_order.rb +10 -2
- data/lib/quickbooks/model/purchase_tax_rate_list.rb +11 -0
- data/lib/quickbooks/model/refund_receipt.rb +5 -6
- data/lib/quickbooks/model/sales_receipt.rb +15 -6
- data/lib/quickbooks/model/tax_code.rb +1 -0
- data/lib/quickbooks/model/term.rb +3 -0
- data/lib/quickbooks/model/time_activity.rb +26 -4
- data/lib/quickbooks/model/validator.rb +7 -3
- data/lib/quickbooks/model/vendor.rb +2 -1
- data/lib/quickbooks/model/vendor_change.rb +12 -0
- data/lib/quickbooks/model/vendor_credit.rb +9 -2
- data/lib/quickbooks/service/bill.rb +1 -1
- data/lib/quickbooks/service/bill_payment.rb +4 -0
- data/lib/quickbooks/service/credit_memo.rb +1 -1
- data/lib/quickbooks/service/customer_change.rb +23 -0
- data/lib/quickbooks/service/estimate.rb +1 -1
- data/lib/quickbooks/service/invoice.rb +1 -1
- data/lib/quickbooks/service/invoice_change.rb +23 -0
- data/lib/quickbooks/service/journal_entry.rb +1 -1
- data/lib/quickbooks/service/payment_method.rb +10 -0
- data/lib/quickbooks/service/purchase.rb +4 -0
- data/lib/quickbooks/service/purchase_order.rb +1 -1
- data/lib/quickbooks/service/refund_receipt.rb +4 -0
- data/lib/quickbooks/service/sales_receipt.rb +4 -0
- data/lib/quickbooks/service/time_activity.rb +1 -2
- data/lib/quickbooks/service/vendor_change.rb +23 -0
- data/lib/quickbooks/service/vendor_credit.rb +4 -0
- data/lib/quickbooks/version.rb +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 126cd8c2502ef5e347fc370519e4cac6a14f3d41
|
4
|
+
data.tar.gz: 6db2de33787e10842076dd81e83eb5dee722bf37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f29c1ec30a4d11e695d0679ba19d67d827a3d8c08a217b54887e268956f5a31438062a26de7186285310648443f68c8890ec195becbcf0f4e46d9b24eb8820a
|
7
|
+
data.tar.gz: f7e8fbad8b49727faafc70465d25dac6ecb01d8c2861ae31f60338fef0b73b5247cee5d7f1ff2ddd5c3f1987910b9b553afd6424de21d09055c1b657780fb3f4
|
data/lib/quickbooks-ruby.rb
CHANGED
@@ -19,6 +19,7 @@ require 'quickbooks/model/base_model'
|
|
19
19
|
require 'quickbooks/model/base_reference'
|
20
20
|
require 'quickbooks/model/document_numbering'
|
21
21
|
require 'quickbooks/model/global_tax_calculation'
|
22
|
+
require 'quickbooks/model/has_line_items'
|
22
23
|
require 'quickbooks/model/access_token_response'
|
23
24
|
require 'quickbooks/model/meta_data'
|
24
25
|
require 'quickbooks/model/class'
|
@@ -49,6 +50,7 @@ require 'quickbooks/model/email_address'
|
|
49
50
|
require 'quickbooks/model/web_site_address'
|
50
51
|
require 'quickbooks/model/physical_address'
|
51
52
|
require 'quickbooks/model/invoice_line_item'
|
53
|
+
require 'quickbooks/model/name_value'
|
52
54
|
require 'quickbooks/model/company_info'
|
53
55
|
require 'quickbooks/model/customer'
|
54
56
|
require 'quickbooks/model/sales_receipt'
|
@@ -77,12 +79,17 @@ require 'quickbooks/model/invoice'
|
|
77
79
|
require 'quickbooks/model/tax_rate'
|
78
80
|
require 'quickbooks/model/tax_rate_detail'
|
79
81
|
require 'quickbooks/model/sales_tax_rate_list'
|
82
|
+
require 'quickbooks/model/purchase_tax_rate_list'
|
80
83
|
require 'quickbooks/model/tax_code'
|
81
84
|
require 'quickbooks/model/fault'
|
82
85
|
require 'quickbooks/model/batch_request'
|
83
86
|
require 'quickbooks/model/batch_response'
|
84
87
|
require 'quickbooks/model/preferences'
|
85
88
|
require 'quickbooks/model/refund_receipt'
|
89
|
+
require 'quickbooks/model/invoice_change'
|
90
|
+
require 'quickbooks/model/customer_change'
|
91
|
+
require 'quickbooks/model/vendor_change'
|
92
|
+
|
86
93
|
|
87
94
|
#== Services
|
88
95
|
require 'quickbooks/service/service_crud'
|
@@ -115,6 +122,9 @@ require 'quickbooks/service/tax_code'
|
|
115
122
|
require 'quickbooks/service/batch'
|
116
123
|
require 'quickbooks/service/preferences'
|
117
124
|
require 'quickbooks/service/refund_receipt'
|
125
|
+
require 'quickbooks/service/invoice_change'
|
126
|
+
require 'quickbooks/service/customer_change'
|
127
|
+
require 'quickbooks/service/vendor_change'
|
118
128
|
|
119
129
|
module Quickbooks
|
120
130
|
@@sandbox_mode = false
|
@@ -21,6 +21,7 @@ module Quickbooks
|
|
21
21
|
xml_accessor :has_attachment?, :from => 'HasAttachment'
|
22
22
|
xml_accessor :name, :from => 'Name'
|
23
23
|
xml_accessor :description, :from => 'Description'
|
24
|
+
xml_accessor :fully_qualified_name, :from => 'FullyQualifiedName' # ReadOnly
|
24
25
|
|
25
26
|
xml_accessor :sub_account?, :from => 'SubAccount'
|
26
27
|
xml_accessor :parent_ref, :from => 'ParentRef', :as => BaseReference
|
@@ -42,10 +42,6 @@ module Quickbooks
|
|
42
42
|
HashWithIndifferentAccess[attributes]
|
43
43
|
end
|
44
44
|
|
45
|
-
def ensure_line_items_initialization
|
46
|
-
self.line_items ||= []
|
47
|
-
end
|
48
|
-
|
49
45
|
def inspect
|
50
46
|
# it would be nice if we could inspect all the children,
|
51
47
|
# but it's likely to blow the stack in some cases
|
@@ -78,7 +74,9 @@ module Quickbooks
|
|
78
74
|
# self.discount_ref = BaseReference.new(id)
|
79
75
|
# end
|
80
76
|
def reference_setters(*args)
|
81
|
-
args.
|
77
|
+
references = args.empty? ? reference_attrs : args
|
78
|
+
|
79
|
+
references.each do |attribute|
|
82
80
|
method_name = "#{attribute.to_s.gsub('_ref', '_id')}=".to_sym
|
83
81
|
unless instance_methods(false).include?(method_name)
|
84
82
|
method_definition = <<-METH
|
@@ -91,9 +89,14 @@ module Quickbooks
|
|
91
89
|
end
|
92
90
|
end
|
93
91
|
|
92
|
+
def reference_attrs
|
93
|
+
matches = roxml_attrs.select{|attr| attr.sought_type == Quickbooks::Model::BaseReference}.map{|attr| attr.accessor}
|
94
|
+
end
|
95
|
+
|
94
96
|
def inspect
|
95
97
|
"#{super}(#{attrs_with_types.join " "})"
|
96
98
|
end
|
99
|
+
|
97
100
|
def attrs_with_types
|
98
101
|
roxml_attrs.map do |attr|
|
99
102
|
"#{attr.accessor}:" +
|
@@ -2,6 +2,7 @@ module Quickbooks
|
|
2
2
|
module Model
|
3
3
|
class Bill < BaseModel
|
4
4
|
include GlobalTaxCalculation
|
5
|
+
include HasLineItems
|
5
6
|
|
6
7
|
XML_COLLECTION_NODE = "Bill"
|
7
8
|
XML_NODE = "Bill"
|
@@ -21,19 +22,24 @@ module Quickbooks
|
|
21
22
|
xml_accessor :vendor_ref, :from => 'VendorRef', :as => BaseReference
|
22
23
|
xml_accessor :payer_ref, :from => 'PayerRef', :as => BaseReference
|
23
24
|
xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
|
25
|
+
xml_accessor :attachable_ref, :from => 'AttachableRef', :as => BaseReference
|
26
|
+
xml_accessor :ap_account_ref, :from => 'APAccountRef', :as => BaseReference
|
24
27
|
|
25
28
|
xml_accessor :due_date, :from => 'DueDate', :as => Date
|
26
29
|
xml_accessor :remit_to_address, :from => 'RemitToAddr', :as => PhysicalAddress
|
27
30
|
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
31
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
32
|
+
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
28
33
|
|
29
34
|
# readonly
|
30
35
|
xml_accessor :bill_email, :from => 'BillEmail', :as => EmailAddress
|
31
36
|
xml_accessor :reply_email, :from => 'ReplyEmail', :as => EmailAddress
|
32
37
|
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
38
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
33
39
|
|
34
40
|
validate :line_item_size
|
35
41
|
|
36
|
-
reference_setters :department_ref, :vendor_ref, :payer_ref, :sales_term_ref
|
42
|
+
reference_setters :department_ref, :vendor_ref, :payer_ref, :sales_term_ref, :currency_ref, :attachable_ref, :ap_account_ref
|
37
43
|
end
|
38
44
|
end
|
39
45
|
end
|
@@ -24,6 +24,19 @@ module Quickbooks
|
|
24
24
|
detail_type.to_s == ITEM_BASED_EXPENSE_LINE_DETAIL
|
25
25
|
end
|
26
26
|
|
27
|
+
def account_based_expense_item!
|
28
|
+
self.detail_type = ACCOUNT_BASED_EXPENSE_LINE_DETAIL
|
29
|
+
self.account_based_expense_line_detail = AccountBasedExpenseLineDetail.new
|
30
|
+
|
31
|
+
yield self.account_based_expense_line_detail if block_given?
|
32
|
+
end
|
33
|
+
|
34
|
+
def item_based_expense_item!
|
35
|
+
self.detail_type = ITEM_BASED_EXPENSE_LINE_DETAIL
|
36
|
+
self.item_based_expense_line_detail = ItemBasedExpenseLineDetail.new
|
37
|
+
|
38
|
+
yield self.item_based_expense_line_detail if block_given?
|
39
|
+
end
|
27
40
|
end
|
28
41
|
end
|
29
42
|
end
|
@@ -16,7 +16,12 @@ module Quickbooks
|
|
16
16
|
xml_accessor :private_note, :from => 'PrivateNote'
|
17
17
|
|
18
18
|
xml_accessor :vendor_ref, :from => 'VendorRef', :as => BaseReference
|
19
|
+
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
20
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
21
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
22
|
+
xml_accessor :ap_account_ref, :from => 'APAccountRef', :as => BaseReference
|
19
23
|
xml_accessor :pay_type, :from => 'PayType'
|
24
|
+
xml_accessor :process_bill_payment?, :from => 'ProcessBillPayment'
|
20
25
|
|
21
26
|
## Required if PayType is Check.
|
22
27
|
xml_accessor :check_payment, :from => 'CheckPayment', :as => BillPaymentCheck
|
@@ -27,7 +32,7 @@ module Quickbooks
|
|
27
32
|
|
28
33
|
validate :line_item_size
|
29
34
|
|
30
|
-
reference_setters
|
35
|
+
reference_setters
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
@@ -22,6 +22,47 @@ module Quickbooks
|
|
22
22
|
xml_accessor :email, :from => 'Email', :as => EmailAddress
|
23
23
|
xml_accessor :web_site, :from => 'WebAddr', :as => WebSiteAddress
|
24
24
|
xml_accessor :supported_languages, :from => 'SupportedLanguages'
|
25
|
+
xml_accessor :name_values, :from => 'NameValue', :as => [NameValue]
|
26
|
+
|
27
|
+
def find_name_value(name)
|
28
|
+
name_values.select { |nv| nv.name == name }.first.value
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_boolean_name_value(name)
|
32
|
+
find_name_value(name) == "true"
|
33
|
+
end
|
34
|
+
|
35
|
+
def industry_type
|
36
|
+
find_name_value("IndustryType")
|
37
|
+
end
|
38
|
+
|
39
|
+
def industry_code
|
40
|
+
find_name_value("IndustryCode")
|
41
|
+
end
|
42
|
+
|
43
|
+
def company_type
|
44
|
+
find_name_value("CompanyType")
|
45
|
+
end
|
46
|
+
|
47
|
+
def subscription_status
|
48
|
+
find_name_value("SubscriptionStatus")
|
49
|
+
end
|
50
|
+
|
51
|
+
def offering_sku
|
52
|
+
find_name_value("OfferingSku")
|
53
|
+
end
|
54
|
+
|
55
|
+
def neo_enabled
|
56
|
+
find_boolean_name_value("NeoEnabled")
|
57
|
+
end
|
58
|
+
|
59
|
+
def payroll_feature
|
60
|
+
find_boolean_name_value("PayrollFeature")
|
61
|
+
end
|
62
|
+
|
63
|
+
def accountant_feature
|
64
|
+
find_boolean_name_value("AccountantFeature")
|
65
|
+
end
|
25
66
|
end
|
26
67
|
end
|
27
68
|
end
|
@@ -3,6 +3,7 @@ module Quickbooks
|
|
3
3
|
class CreditMemo < BaseModel
|
4
4
|
include DocumentNumbering
|
5
5
|
include GlobalTaxCalculation
|
6
|
+
include HasLineItems
|
6
7
|
|
7
8
|
XML_COLLECTION_NODE = "CreditMemo"
|
8
9
|
XML_NODE = "CreditMemo"
|
@@ -19,6 +20,7 @@ module Quickbooks
|
|
19
20
|
xml_accessor :line_items, :from => 'Line', :as => [Line]
|
20
21
|
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
21
22
|
xml_accessor :private_note, :from => 'PrivateNote'
|
23
|
+
xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
|
22
24
|
|
23
25
|
xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
|
24
26
|
xml_accessor :customer_memo, :from => 'CustomerMemo'
|
@@ -27,6 +29,16 @@ module Quickbooks
|
|
27
29
|
xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
|
28
30
|
xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
|
29
31
|
xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
|
32
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
33
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
34
|
+
xml_accessor :shipping_address, :from => 'ShipAddr', :as => PhysicalAddress
|
35
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
36
|
+
xml_accessor :home_total, :from => 'HomeTotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
37
|
+
xml_accessor :apply_tax_after_discount?, :from => 'ApplyTaxAfterDiscount'
|
38
|
+
xml_accessor :print_status, :from => 'PrintStatus'
|
39
|
+
xml_accessor :email_status, :from => 'EmailStatus'
|
40
|
+
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
41
|
+
xml_accessor :remaining_credit, :from => 'RemainingCredit', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
30
42
|
|
31
43
|
# readonly
|
32
44
|
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
@@ -37,12 +49,7 @@ module Quickbooks
|
|
37
49
|
validate :line_item_size
|
38
50
|
validate :document_numbering
|
39
51
|
|
40
|
-
reference_setters
|
41
|
-
|
42
|
-
def initialize(*args)
|
43
|
-
ensure_line_items_initialization
|
44
|
-
super
|
45
|
-
end
|
52
|
+
reference_setters
|
46
53
|
|
47
54
|
def email=(email)
|
48
55
|
self.bill_email = EmailAddress.new(email)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
# Refer to: https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/change_data_capture
|
4
|
+
class CustomerChange < BaseModel
|
5
|
+
XML_NODE = "Customer"
|
6
|
+
|
7
|
+
xml_accessor :id, :from => 'Id', :as => Integer
|
8
|
+
xml_accessor :status, :from => '@status'
|
9
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -9,6 +9,7 @@ module Quickbooks
|
|
9
9
|
module Model
|
10
10
|
class Estimate < BaseModel
|
11
11
|
include GlobalTaxCalculation
|
12
|
+
include HasLineItems
|
12
13
|
|
13
14
|
#== Constants
|
14
15
|
REST_RESOURCE = 'estimate'
|
@@ -35,10 +36,15 @@ module Quickbooks
|
|
35
36
|
xml_accessor :shipping_address, :from => 'ShipAddr', :as => PhysicalAddress
|
36
37
|
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
37
38
|
xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
|
38
|
-
xml_accessor :
|
39
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
39
40
|
xml_accessor :ship_method_ref, :from => 'ShipMethodRef', :as => BaseReference
|
40
41
|
xml_accessor :ship_date, :from => 'ShipDate', :as => Date
|
41
42
|
|
43
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
44
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
45
|
+
xml_accessor :due_date, :from => 'DueDate', :as => Date
|
46
|
+
xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
|
47
|
+
|
42
48
|
xml_accessor :apply_tax_after_discount?, :from => 'ApplyTaxAfterDiscount'
|
43
49
|
xml_accessor :print_status, :from => 'PrintStatus'
|
44
50
|
xml_accessor :email_status, :from => 'EmailStatus'
|
@@ -47,17 +53,16 @@ module Quickbooks
|
|
47
53
|
xml_accessor :accepted_by, :from => 'AcceptedBy'
|
48
54
|
xml_accessor :accepted_date, :from => 'AcceptedDate', :as => Date
|
49
55
|
|
50
|
-
reference_setters
|
56
|
+
reference_setters
|
57
|
+
|
58
|
+
#== This adds aliases for backwards compatability to old attributes names
|
59
|
+
alias_method :total_amount, :total
|
60
|
+
alias_method :total_amount=, :total=
|
51
61
|
|
52
62
|
#== Validations
|
53
63
|
validate :line_item_size
|
54
64
|
validate :existence_of_customer_ref
|
55
65
|
|
56
|
-
def initialize(*args)
|
57
|
-
ensure_line_items_initialization
|
58
|
-
super
|
59
|
-
end
|
60
|
-
|
61
66
|
private
|
62
67
|
|
63
68
|
def existence_of_customer_ref
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module GlobalTaxCalculation
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
-
|
4
|
+
TAX_INCLUSIVE = "TaxInclusive"
|
5
5
|
TAX_EXCLUDED = "TaxExcluded"
|
6
6
|
NOT_APPLICABLE = "NotApplicable"
|
7
|
-
GLOBAL_TAX_CALCULATION = [
|
7
|
+
GLOBAL_TAX_CALCULATION = [TAX_INCLUSIVE, TAX_EXCLUDED, NOT_APPLICABLE]
|
8
8
|
|
9
9
|
included do
|
10
10
|
xml_accessor :global_tax_calculation, :from => 'GlobalTaxCalculation'
|
@@ -10,6 +10,7 @@ module Quickbooks
|
|
10
10
|
class Invoice < BaseModel
|
11
11
|
include DocumentNumbering
|
12
12
|
include GlobalTaxCalculation
|
13
|
+
include HasLineItems
|
13
14
|
|
14
15
|
#== Constants
|
15
16
|
REST_RESOURCE = 'invoice'
|
@@ -41,8 +42,8 @@ module Quickbooks
|
|
41
42
|
xml_accessor :ship_date, :from => 'ShipDate', :as => Date
|
42
43
|
xml_accessor :tracking_num, :from => 'TrackingNum'
|
43
44
|
xml_accessor :ar_account_ref, :from => 'ARAccountRef', :as => BaseReference
|
44
|
-
xml_accessor :
|
45
|
-
xml_accessor :
|
45
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
46
|
+
xml_accessor :home_total, :from => 'HomeTotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
46
47
|
xml_accessor :apply_tax_after_discount?, :from => 'ApplyTaxAfterDiscount'
|
47
48
|
xml_accessor :print_status, :from => 'PrintStatus'
|
48
49
|
xml_accessor :email_status, :from => 'EmailStatus'
|
@@ -54,9 +55,15 @@ module Quickbooks
|
|
54
55
|
xml_accessor :allow_online_payment?, :from => 'AllowOnlinePayment'
|
55
56
|
xml_accessor :allow_online_credit_card_payment?, :from => 'AllowOnlineCreditCardPayment'
|
56
57
|
xml_accessor :allow_online_ach_payment?, :from => 'AllowOnlineACHPayment'
|
58
|
+
xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
|
57
59
|
|
58
|
-
reference_setters
|
59
|
-
|
60
|
+
reference_setters
|
61
|
+
|
62
|
+
#== This adds aliases for backwards compatability to old attributes names
|
63
|
+
alias_method :total_amount, :total
|
64
|
+
alias_method :total_amount=, :total=
|
65
|
+
alias_method :home_total_amount, :home_total
|
66
|
+
alias_method :home_total_amount=, :home_total=
|
60
67
|
|
61
68
|
#== Validations
|
62
69
|
validate :line_item_size
|
@@ -64,11 +71,6 @@ module Quickbooks
|
|
64
71
|
validate :required_bill_email_if_email_delivery
|
65
72
|
validate :document_numbering
|
66
73
|
|
67
|
-
def initialize(*args)
|
68
|
-
ensure_line_items_initialization
|
69
|
-
super
|
70
|
-
end
|
71
|
-
|
72
74
|
def required_bill_email_if_email_delivery
|
73
75
|
return unless email_status_for_delivery?
|
74
76
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
# Refer to: https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/change_data_capture
|
4
|
+
class InvoiceChange < BaseModel
|
5
|
+
XML_NODE = "Invoice"
|
6
|
+
|
7
|
+
xml_accessor :id, :from => 'Id', :as => Integer
|
8
|
+
xml_accessor :status, :from => '@status'
|
9
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Quickbooks
|
2
2
|
module Model
|
3
3
|
class JournalEntry < BaseModel
|
4
|
+
include HasLineItems
|
5
|
+
|
4
6
|
XML_COLLECTION_NODE = "JournalEntry"
|
5
7
|
XML_NODE = "JournalEntry"
|
6
8
|
REST_RESOURCE = 'journalentry'
|
@@ -17,9 +19,13 @@ module Quickbooks
|
|
17
19
|
|
18
20
|
# Readonly
|
19
21
|
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
20
|
-
xml_accessor :
|
22
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
21
23
|
xml_accessor :home_total, :from => 'HomeTotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
22
24
|
|
25
|
+
#== This adds aliases for backwards compatability to old attributes names
|
26
|
+
alias_method :total_amount, :total
|
27
|
+
alias_method :total_amount=, :total=
|
28
|
+
|
23
29
|
xml_accessor :adjustment?, :from => 'Adjustment'
|
24
30
|
|
25
31
|
reference_setters :currency_ref
|
@@ -10,7 +10,7 @@ module Quickbooks
|
|
10
10
|
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
11
11
|
|
12
12
|
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
|
13
|
-
xml_accessor :tax_applicable_on, :from => 'TaxApplicableOn'
|
13
|
+
xml_accessor :tax_applicable_on, :from => 'TaxApplicableOn', :as => :text
|
14
14
|
xml_accessor :tax_amount, :from => 'TaxAmount', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
15
15
|
|
16
16
|
xml_accessor :billable_status, :from => 'BillableStatus'
|
@@ -2,7 +2,7 @@ module Quickbooks
|
|
2
2
|
module Model
|
3
3
|
class Line < BaseModel
|
4
4
|
#== Constants
|
5
|
-
|
5
|
+
SALES_ITEM_LINE_DETAIL = 'SalesItemLineDetail'
|
6
6
|
SUB_TOTAL_LINE_DETAIL = 'SubTotalLineDetail'
|
7
7
|
PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
|
8
8
|
DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'
|
@@ -38,12 +38,39 @@ module Quickbooks
|
|
38
38
|
alias_method :credit_memo_ids=, :credit_memo_id=
|
39
39
|
|
40
40
|
def sales_item!
|
41
|
-
self.detail_type =
|
41
|
+
self.detail_type = SALES_ITEM_LINE_DETAIL
|
42
42
|
self.sales_item_line_detail = SalesItemLineDetail.new
|
43
43
|
|
44
44
|
yield self.sales_item_line_detail if block_given?
|
45
45
|
end
|
46
46
|
|
47
|
+
def sub_total!
|
48
|
+
self.detail_type = SUB_TOTAL_LINE_DETAIL
|
49
|
+
self.sub_total_line_detail = SubTotalLineDetail.new
|
50
|
+
|
51
|
+
yield self.sub_total_line_detail if block_given?
|
52
|
+
end
|
53
|
+
|
54
|
+
def payment!
|
55
|
+
self.detail_type = PAYMENT_LINE_DETAIL
|
56
|
+
self.payment_line_detail = PaymentLineDetail.new
|
57
|
+
|
58
|
+
yield self.payment_line_detail if block_given?
|
59
|
+
end
|
60
|
+
|
61
|
+
def discount!
|
62
|
+
self.detail_type = DISCOUNT_LINE_DETAIL
|
63
|
+
self.discount_line_detail = DiscountLineDetail.new
|
64
|
+
|
65
|
+
yield self.discount_line_detail if block_given?
|
66
|
+
end
|
67
|
+
|
68
|
+
def journal_entry!
|
69
|
+
self.detail_type = JOURNAL_ENTRY_LINE_DETAIL
|
70
|
+
self.journal_entry_line_detail = JournalEntryLineDetail.new
|
71
|
+
|
72
|
+
yield self.journal_entry_line_detail if block_given?
|
73
|
+
end
|
47
74
|
|
48
75
|
private
|
49
76
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Quickbooks
|
2
2
|
module Model
|
3
3
|
class Payment < BaseModel
|
4
|
+
include HasLineItems
|
5
|
+
|
4
6
|
XML_COLLECTION_NODE = "Payment"
|
5
7
|
XML_NODE = "Payment"
|
6
8
|
REST_RESOURCE = 'payment'
|
@@ -29,11 +31,6 @@ module Quickbooks
|
|
29
31
|
|
30
32
|
validate :existence_of_customer_ref
|
31
33
|
|
32
|
-
def initialize(*args)
|
33
|
-
ensure_line_items_initialization
|
34
|
-
super
|
35
|
-
end
|
36
|
-
|
37
34
|
private
|
38
35
|
|
39
36
|
def existence_of_customer_ref
|
@@ -4,11 +4,22 @@ module Quickbooks
|
|
4
4
|
REST_RESOURCE = 'paymentmethod'
|
5
5
|
XML_COLLECTION_NODE = "PaymentMethod"
|
6
6
|
XML_NODE = "PaymentMethod"
|
7
|
+
include NameEntity::PermitAlterations
|
8
|
+
|
9
|
+
CREDIT_CARD = "CREDIT_CARD"
|
10
|
+
NON_CREDIT_CARD = "NON_CREDIT_CARD"
|
11
|
+
|
12
|
+
PAYMENT_METHOD_TYPES = [CREDIT_CARD, NON_CREDIT_CARD]
|
7
13
|
|
8
14
|
xml_accessor :id, :from => 'Id', :as => Integer
|
15
|
+
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
16
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
9
17
|
xml_accessor :name, :from => 'Name'
|
18
|
+
xml_accessor :type, :from => 'Type'
|
10
19
|
xml_accessor :active?, :from => 'Active'
|
11
20
|
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
21
|
+
|
22
|
+
validates_inclusion_of :type, :in => PAYMENT_METHOD_TYPES, :allow_nil => true
|
12
23
|
end
|
13
24
|
end
|
14
25
|
end
|
@@ -33,11 +33,20 @@ module Quickbooks
|
|
33
33
|
xml_accessor :payment_type, :from => 'PaymentType'
|
34
34
|
xml_accessor :entity_ref, :from => 'EntityRef', :as => BaseReference
|
35
35
|
xml_accessor :remit_to_address, :from => 'RemitToAddr', :as => PhysicalAddress
|
36
|
-
xml_accessor :
|
36
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
37
37
|
xml_accessor :print_status, :from => 'PrintStatus'
|
38
38
|
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
39
39
|
|
40
|
-
|
40
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
41
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
42
|
+
xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
|
43
|
+
xml_accessor :credit?, :from => 'Credit'
|
44
|
+
|
45
|
+
reference_setters
|
46
|
+
|
47
|
+
#== This adds aliases for backwards compatability to old attributes names
|
48
|
+
alias_method :total_amount, :total
|
49
|
+
alias_method :total_amount=, :total=
|
41
50
|
|
42
51
|
end
|
43
52
|
end
|
@@ -4,6 +4,7 @@ module Quickbooks
|
|
4
4
|
|
5
5
|
#== Constants
|
6
6
|
ITEM_BASED_EXPENSE_LINE_DETAIL = 'ItemBasedExpenseLineDetail'
|
7
|
+
ACCOUNT_BASED_EXPENSE_LINE_DETAIL = 'AccountBasedExpenseLineDetail'
|
7
8
|
GROUP_LINE_DETAIL = 'GroupLineDetail'
|
8
9
|
|
9
10
|
xml_accessor :id, :from => 'Id', :as => Integer
|
@@ -13,10 +14,31 @@ module Quickbooks
|
|
13
14
|
xml_accessor :detail_type, :from => 'DetailType'
|
14
15
|
|
15
16
|
#== Various detail types
|
16
|
-
xml_accessor :account_based_expense_line_detail, :from =>
|
17
|
+
xml_accessor :account_based_expense_line_detail, :from => ACCOUNT_BASED_EXPENSE_LINE_DETAIL, :as => AccountBasedExpenseLineDetail
|
17
18
|
xml_accessor :item_based_expense_line_detail, :from => ITEM_BASED_EXPENSE_LINE_DETAIL, :as => ItemBasedExpenseLineDetail
|
18
19
|
xml_accessor :group_line_detail, :from => GROUP_LINE_DETAIL, :as => GroupLineDetail
|
19
20
|
|
21
|
+
def account_based?
|
22
|
+
detail_type.to_s == ACCOUNT_BASED_EXPENSE_LINE_DETAIL
|
23
|
+
end
|
24
|
+
|
25
|
+
def item_based?
|
26
|
+
detail_type.to_s == ITEM_BASED_EXPENSE_LINE_DETAIL
|
27
|
+
end
|
28
|
+
|
29
|
+
def account_based_expense!
|
30
|
+
self.detail_type = ACCOUNT_BASED_EXPENSE_LINE_DETAIL
|
31
|
+
self.account_based_expense_line_detail = AccountBasedExpenseLineDetail.new
|
32
|
+
|
33
|
+
yield self.account_based_expense_line_detail if block_given?
|
34
|
+
end
|
35
|
+
|
36
|
+
def item_based_expense!
|
37
|
+
self.detail_type = ITEM_BASED_EXPENSE_LINE_DETAIL
|
38
|
+
self.item_based_expense_line_detail = ItemBasedExpenseLineDetail.new
|
39
|
+
|
40
|
+
yield self.item_based_expense_line_detail if block_given?
|
41
|
+
end
|
20
42
|
end
|
21
43
|
end
|
22
|
-
end
|
44
|
+
end
|
@@ -25,7 +25,7 @@ module Quickbooks
|
|
25
25
|
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
26
26
|
xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
|
27
27
|
|
28
|
-
xml_accessor :
|
28
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
29
29
|
xml_accessor :due_date, :from => 'DueDate', :as => Date
|
30
30
|
xml_accessor :vendor_address, :from => 'VendorAddr', :as => PhysicalAddress
|
31
31
|
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
@@ -33,7 +33,15 @@ module Quickbooks
|
|
33
33
|
xml_accessor :po_status, :from => 'POStatus'
|
34
34
|
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
35
35
|
|
36
|
-
|
36
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
37
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
38
|
+
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
|
39
|
+
|
40
|
+
reference_setters
|
41
|
+
|
42
|
+
#== This adds aliases for backwards compatability to old attributes names
|
43
|
+
alias_method :total_amount, :total
|
44
|
+
alias_method :total_amount=, :total=
|
37
45
|
|
38
46
|
end
|
39
47
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class PurchaseTaxRateList < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "PurchaseTaxRateList"
|
5
|
+
XML_NODE = "PurchaseTaxRateList"
|
6
|
+
REST_RESOURCE = "purchasetaxratelist"
|
7
|
+
|
8
|
+
xml_accessor :tax_rate_detail, :from => "TaxRateDetail", :as => [TaxRateDetail]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -2,6 +2,7 @@ module Quickbooks
|
|
2
2
|
module Model
|
3
3
|
class RefundReceipt < BaseModel
|
4
4
|
include GlobalTaxCalculation
|
5
|
+
include HasLineItems
|
5
6
|
|
6
7
|
XML_COLLECTION_NODE = "RefundReceipt"
|
7
8
|
XML_NODE = "RefundReceipt"
|
@@ -36,6 +37,9 @@ module Quickbooks
|
|
36
37
|
xml_accessor :print_status, :from => 'PrintStatus'
|
37
38
|
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
38
39
|
|
40
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
41
|
+
xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
|
42
|
+
|
39
43
|
# readonly
|
40
44
|
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
41
45
|
xml_accessor :home_total, :from => 'HomeTotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
@@ -44,16 +48,11 @@ module Quickbooks
|
|
44
48
|
alias_attribute :placed_on, :txn_date
|
45
49
|
|
46
50
|
include DocumentNumbering
|
47
|
-
reference_setters
|
51
|
+
reference_setters
|
48
52
|
|
49
53
|
validate :line_item_size
|
50
54
|
validate :document_numbering
|
51
55
|
|
52
|
-
def initialize(*args)
|
53
|
-
ensure_line_items_initialization
|
54
|
-
super
|
55
|
-
end
|
56
|
-
|
57
56
|
def email=(email)
|
58
57
|
self.bill_email = EmailAddress.new(email)
|
59
58
|
end
|
@@ -3,6 +3,7 @@ module Quickbooks
|
|
3
3
|
class SalesReceipt < BaseModel
|
4
4
|
include DocumentNumbering
|
5
5
|
include GlobalTaxCalculation
|
6
|
+
include HasLineItems
|
6
7
|
|
7
8
|
XML_COLLECTION_NODE = "SalesReceipt"
|
8
9
|
XML_NODE = "SalesReceipt"
|
@@ -16,6 +17,7 @@ module Quickbooks
|
|
16
17
|
xml_accessor :txn_date, :from => 'TxnDate', :as => Time
|
17
18
|
xml_accessor :line_items, :from => 'Line', :as => [Line]
|
18
19
|
xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
|
20
|
+
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
19
21
|
xml_accessor :bill_email, :from => 'BillEmail', :as => EmailAddress
|
20
22
|
xml_accessor :bill_address, :from => 'BillAddr', :as => PhysicalAddress
|
21
23
|
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
@@ -28,23 +30,30 @@ module Quickbooks
|
|
28
30
|
xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
|
29
31
|
xml_accessor :customer_memo, :from => 'CustomerMemo'
|
30
32
|
xml_accessor :private_note, :from => 'PrivateNote'
|
33
|
+
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
34
|
+
xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
|
35
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
36
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
37
|
+
xml_accessor :apply_tax_after_discount?, :from => 'ApplyTaxAfterDiscount'
|
38
|
+
xml_accessor :print_status, :from => 'PrintStatus'
|
39
|
+
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
40
|
+
|
41
|
+
xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
|
42
|
+
xml_accessor :email_status, :from => 'EmailStatus'
|
43
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
31
44
|
|
32
45
|
# readonly
|
33
46
|
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
47
|
+
xml_accessor :home_total, :from => 'HomeTotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
34
48
|
|
35
49
|
# backward-compatible alias
|
36
50
|
alias_attribute :placed_on, :txn_date
|
37
51
|
|
38
|
-
reference_setters
|
52
|
+
reference_setters
|
39
53
|
|
40
54
|
validate :line_item_size
|
41
55
|
validate :document_numbering
|
42
56
|
|
43
|
-
def initialize(*args)
|
44
|
-
ensure_line_items_initialization
|
45
|
-
super
|
46
|
-
end
|
47
|
-
|
48
57
|
def email=(email)
|
49
58
|
self.bill_email = EmailAddress.new(email)
|
50
59
|
end
|
@@ -14,6 +14,7 @@ module Quickbooks
|
|
14
14
|
xml_accessor :taxable?, :from => "Taxable"
|
15
15
|
xml_accessor :tax_group?, :from => "TaxGroup"
|
16
16
|
xml_accessor :sales_tax_rate_list, :from => "SalesTaxRateList", :as => SalesTaxRateList
|
17
|
+
xml_accessor :purchase_tax_rate_list, :from => "PurchaseTaxRateList", :as => PurchaseTaxRateList
|
17
18
|
|
18
19
|
end
|
19
20
|
end
|
@@ -17,9 +17,12 @@ module Quickbooks
|
|
17
17
|
xml_accessor :day_of_month_due, :from => 'DayOfMonthDue', :as => Integer
|
18
18
|
xml_accessor :due_next_month_days, :from => 'DueNextMonthDays', :as => Integer
|
19
19
|
xml_accessor :discount_day_of_month, :from => 'DiscountDayOfMonth', :as => Integer
|
20
|
+
xml_accessor :attachable_ref, :from => 'AttachableRef', :as => BaseReference
|
20
21
|
|
21
22
|
validates_presence_of :name
|
22
23
|
|
24
|
+
reference_setters :attachable_ref
|
25
|
+
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -24,15 +24,37 @@ module Quickbooks
|
|
24
24
|
|
25
25
|
xml_accessor :billable_status, :from => 'BillableStatus'
|
26
26
|
xml_accessor :taxable, :from => 'Taxable'
|
27
|
-
xml_accessor :hours, :from => 'Hours', :as => Integer
|
28
27
|
xml_accessor :hourly_rate, :from => 'HourlyRate'
|
29
28
|
xml_accessor :minutes, :from => 'Minutes', :as => Integer
|
29
|
+
xml_accessor :hours, :from => 'Hours', :as => Integer
|
30
|
+
xml_accessor :break_minutes, :from => 'BreakMinutes', :as => Integer
|
31
|
+
xml_accessor :break_hours, :from => 'BreakHours', :as => Integer
|
30
32
|
xml_accessor :description, :from => 'Description'
|
31
33
|
|
32
|
-
|
34
|
+
xml_accessor :attachable_ref, :from => 'AttachableRef', :as => BaseReference
|
35
|
+
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
36
|
+
xml_accessor :start_time, :from => 'StartTime', :as => DateTime
|
37
|
+
xml_accessor :end_time, :from => 'EndTime', :as => DateTime
|
38
|
+
xml_accessor :time_zone, :from => 'TimeZone'
|
39
|
+
|
40
|
+
reference_setters
|
41
|
+
|
42
|
+
# == Validations
|
33
43
|
validates_inclusion_of :name_of, :in => NAMEOF_OPTIONS
|
34
|
-
|
35
|
-
|
44
|
+
validate :existence_of_employee_ref, :if => Proc.new { |ta| ta.name_of == "Employee" }
|
45
|
+
validate :existence_of_vendor_ref, :if => Proc.new { |ta| ta.name_of == "Vendor" }
|
46
|
+
|
47
|
+
def existence_of_employee_ref
|
48
|
+
if employee_ref.nil? || (employee_ref && employee_ref.value == 0)
|
49
|
+
errors.add(:employee_ref, "VendorRef is required and must be a non-zero value.")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def existence_of_vendor_ref
|
54
|
+
if vendor_ref.nil? || (vendor_ref && vendor_ref.value == 0)
|
55
|
+
errors.add(:vendor_ref, "VendorRef is required and must be a non-zero value.")
|
56
|
+
end
|
57
|
+
end
|
36
58
|
|
37
59
|
def valid_for_update?
|
38
60
|
if sync_token.nil?
|
@@ -1,6 +1,10 @@
|
|
1
|
-
module
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
module Validator
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
def line_item_size
|
6
|
+
validates_length_of :line_items, :minimum => 1, :message => 'At least 1 line item is required'
|
7
|
+
end
|
8
|
+
end
|
5
9
|
end
|
6
10
|
end
|
@@ -17,6 +17,7 @@ module Quickbooks
|
|
17
17
|
xml_accessor :id, :from => 'Id', :as => Integer
|
18
18
|
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
19
19
|
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
20
|
+
xml_accessor :attachable_ref, :from => 'AttachableRef', :as => BaseReference
|
20
21
|
xml_accessor :title, :from => 'Title'
|
21
22
|
xml_accessor :given_name, :from => 'GivenName'
|
22
23
|
xml_accessor :middle_name, :from => 'MiddleName'
|
@@ -45,7 +46,7 @@ module Quickbooks
|
|
45
46
|
validate :names_cannot_contain_invalid_characters
|
46
47
|
validate :email_address_is_valid
|
47
48
|
|
48
|
-
reference_setters
|
49
|
+
reference_setters
|
49
50
|
|
50
51
|
end
|
51
52
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
# Refer to: https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/change_data_capture
|
4
|
+
class VendorChange < BaseModel
|
5
|
+
XML_NODE = "Vendor"
|
6
|
+
|
7
|
+
xml_accessor :id, :from => 'Id', :as => Integer
|
8
|
+
xml_accessor :status, :from => '@status'
|
9
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -23,9 +23,16 @@ module Quickbooks
|
|
23
23
|
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
24
24
|
xml_accessor :ap_account_ref, :from => 'APAccountRef', :as => BaseReference
|
25
25
|
xml_accessor :vendor_ref, :from => 'VendorRef', :as => BaseReference
|
26
|
-
xml_accessor :
|
26
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
27
27
|
|
28
|
-
|
28
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
29
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
30
|
+
|
31
|
+
reference_setters
|
32
|
+
|
33
|
+
#== This adds aliases for backwards compatability to old attributes names
|
34
|
+
alias_method :total_amount, :total
|
35
|
+
alias_method :total_amount=, :total=
|
29
36
|
|
30
37
|
end
|
31
38
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Service
|
3
|
+
class CustomerChange < BaseService
|
4
|
+
|
5
|
+
def url_for_query(query = nil, start_position = 1, max_results = 20)
|
6
|
+
q = "Customer"
|
7
|
+
q = "#{q}&#{query}" if query.present?
|
8
|
+
|
9
|
+
"#{url_for_base}/cdc?entities=#{q}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def since(timestamp)
|
13
|
+
query("changedSince=#{URI.encode_www_form_component(timestamp.iso8601)}")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def model
|
19
|
+
Quickbooks::Model::CustomerChange
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Service
|
3
|
+
class InvoiceChange < BaseService
|
4
|
+
|
5
|
+
def url_for_query(query = nil, start_position = 1, max_results = 20)
|
6
|
+
q = "Invoice"
|
7
|
+
q = "#{q}&#{query}" if query.present?
|
8
|
+
|
9
|
+
"#{url_for_base}/cdc?entities=#{q}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def since(timestamp)
|
13
|
+
query("changedSince=#{URI.encode_www_form_component(timestamp.iso8601)}")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def model
|
19
|
+
Quickbooks::Model::InvoiceChange
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -10,6 +10,16 @@ module Quickbooks
|
|
10
10
|
"SELECT * FROM PaymentMethod WHERE Name = '#{name}'"
|
11
11
|
end
|
12
12
|
|
13
|
+
def update(entity, options = {})
|
14
|
+
raise Quickbooks::InvalidModelException.new('Payment Method sparse update is not supported by Intuit at this time') if options[:sparse] && options[:sparse] == true
|
15
|
+
super(entity, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete(department)
|
19
|
+
department.active = false
|
20
|
+
update(department, :sparse => false)
|
21
|
+
end
|
22
|
+
|
13
23
|
private
|
14
24
|
|
15
25
|
def model
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Service
|
3
|
+
class VendorChange < BaseService
|
4
|
+
|
5
|
+
def url_for_query(query = nil, start_position = 1, max_results = 20)
|
6
|
+
q = "Vendor"
|
7
|
+
q = "#{q}&#{query}" if query.present?
|
8
|
+
|
9
|
+
"#{url_for_base}/cdc?entities=#{q}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def since(timestamp)
|
13
|
+
query("changedSince=#{URI.encode_www_form_component(timestamp.iso8601)}")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def model
|
19
|
+
Quickbooks::Model::VendorChange
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Caughlan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/quickbooks/model/credit_memo.rb
|
191
191
|
- lib/quickbooks/model/custom_field.rb
|
192
192
|
- lib/quickbooks/model/customer.rb
|
193
|
+
- lib/quickbooks/model/customer_change.rb
|
193
194
|
- lib/quickbooks/model/department.rb
|
194
195
|
- lib/quickbooks/model/discount_line_detail.rb
|
195
196
|
- lib/quickbooks/model/discount_override.rb
|
@@ -201,7 +202,9 @@ files:
|
|
201
202
|
- lib/quickbooks/model/fault.rb
|
202
203
|
- lib/quickbooks/model/global_tax_calculation.rb
|
203
204
|
- lib/quickbooks/model/group_line_detail.rb
|
205
|
+
- lib/quickbooks/model/has_line_items.rb
|
204
206
|
- lib/quickbooks/model/invoice.rb
|
207
|
+
- lib/quickbooks/model/invoice_change.rb
|
205
208
|
- lib/quickbooks/model/invoice_line_item.rb
|
206
209
|
- lib/quickbooks/model/item.rb
|
207
210
|
- lib/quickbooks/model/item_based_expense_line_detail.rb
|
@@ -211,6 +214,7 @@ files:
|
|
211
214
|
- lib/quickbooks/model/linked_transaction.rb
|
212
215
|
- lib/quickbooks/model/markup_info.rb
|
213
216
|
- lib/quickbooks/model/meta_data.rb
|
217
|
+
- lib/quickbooks/model/name_value.rb
|
214
218
|
- lib/quickbooks/model/other_contact_info.rb
|
215
219
|
- lib/quickbooks/model/payment.rb
|
216
220
|
- lib/quickbooks/model/payment_line_detail.rb
|
@@ -220,6 +224,7 @@ files:
|
|
220
224
|
- lib/quickbooks/model/purchase.rb
|
221
225
|
- lib/quickbooks/model/purchase_line_item.rb
|
222
226
|
- lib/quickbooks/model/purchase_order.rb
|
227
|
+
- lib/quickbooks/model/purchase_tax_rate_list.rb
|
223
228
|
- lib/quickbooks/model/refund_receipt.rb
|
224
229
|
- lib/quickbooks/model/sales_item_line_detail.rb
|
225
230
|
- lib/quickbooks/model/sales_receipt.rb
|
@@ -236,6 +241,7 @@ files:
|
|
236
241
|
- lib/quickbooks/model/transaction_tax_detail.rb
|
237
242
|
- lib/quickbooks/model/validator.rb
|
238
243
|
- lib/quickbooks/model/vendor.rb
|
244
|
+
- lib/quickbooks/model/vendor_change.rb
|
239
245
|
- lib/quickbooks/model/vendor_credit.rb
|
240
246
|
- lib/quickbooks/model/web_site_address.rb
|
241
247
|
- lib/quickbooks/service/access_token.rb
|
@@ -248,10 +254,12 @@ files:
|
|
248
254
|
- lib/quickbooks/service/company_info.rb
|
249
255
|
- lib/quickbooks/service/credit_memo.rb
|
250
256
|
- lib/quickbooks/service/customer.rb
|
257
|
+
- lib/quickbooks/service/customer_change.rb
|
251
258
|
- lib/quickbooks/service/department.rb
|
252
259
|
- lib/quickbooks/service/employee.rb
|
253
260
|
- lib/quickbooks/service/estimate.rb
|
254
261
|
- lib/quickbooks/service/invoice.rb
|
262
|
+
- lib/quickbooks/service/invoice_change.rb
|
255
263
|
- lib/quickbooks/service/item.rb
|
256
264
|
- lib/quickbooks/service/journal_entry.rb
|
257
265
|
- lib/quickbooks/service/payment.rb
|
@@ -267,6 +275,7 @@ files:
|
|
267
275
|
- lib/quickbooks/service/term.rb
|
268
276
|
- lib/quickbooks/service/time_activity.rb
|
269
277
|
- lib/quickbooks/service/vendor.rb
|
278
|
+
- lib/quickbooks/service/vendor_change.rb
|
270
279
|
- lib/quickbooks/service/vendor_credit.rb
|
271
280
|
- lib/quickbooks/util/collection.rb
|
272
281
|
- lib/quickbooks/util/http_encoding_helper.rb
|