quickbooks-ruby-oauth2 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +7 -0
  2. data/lib/quickbooks/faraday/middleware/gzip.rb +72 -0
  3. data/lib/quickbooks/model/access_token_response.rb +29 -0
  4. data/lib/quickbooks/model/account.rb +78 -0
  5. data/lib/quickbooks/model/account_based_expense_line_detail.rb +15 -0
  6. data/lib/quickbooks/model/attachable.rb +33 -0
  7. data/lib/quickbooks/model/attachable_ref.rb +22 -0
  8. data/lib/quickbooks/model/base_model.rb +120 -0
  9. data/lib/quickbooks/model/base_model_json.rb +16 -0
  10. data/lib/quickbooks/model/base_reference.rb +23 -0
  11. data/lib/quickbooks/model/batch_request.rb +45 -0
  12. data/lib/quickbooks/model/batch_response.rb +33 -0
  13. data/lib/quickbooks/model/bill.rb +45 -0
  14. data/lib/quickbooks/model/bill_line_item.rb +42 -0
  15. data/lib/quickbooks/model/bill_payment.rb +40 -0
  16. data/lib/quickbooks/model/bill_payment_check.rb +12 -0
  17. data/lib/quickbooks/model/bill_payment_credit_card.rb +10 -0
  18. data/lib/quickbooks/model/bill_payment_line_item.rb +21 -0
  19. data/lib/quickbooks/model/budget.rb +27 -0
  20. data/lib/quickbooks/model/budget_line_item.rb +15 -0
  21. data/lib/quickbooks/model/change_data_capture.rb +42 -0
  22. data/lib/quickbooks/model/change_model.rb +10 -0
  23. data/lib/quickbooks/model/check_payment.rb +11 -0
  24. data/lib/quickbooks/model/class.rb +31 -0
  25. data/lib/quickbooks/model/company_info.rb +69 -0
  26. data/lib/quickbooks/model/credit_card_payment.rb +17 -0
  27. data/lib/quickbooks/model/credit_memo.rb +59 -0
  28. data/lib/quickbooks/model/credit_memo_change.rb +8 -0
  29. data/lib/quickbooks/model/custom_field.rb +13 -0
  30. data/lib/quickbooks/model/customer.rb +76 -0
  31. data/lib/quickbooks/model/customer_change.rb +8 -0
  32. data/lib/quickbooks/model/definition.rb +46 -0
  33. data/lib/quickbooks/model/delivery_info.rb +8 -0
  34. data/lib/quickbooks/model/department.rb +31 -0
  35. data/lib/quickbooks/model/deposit.rb +44 -0
  36. data/lib/quickbooks/model/deposit_line_detail.rb +17 -0
  37. data/lib/quickbooks/model/deposit_line_item.rb +35 -0
  38. data/lib/quickbooks/model/description_line_detail.rb +7 -0
  39. data/lib/quickbooks/model/discount_line_detail.rb +15 -0
  40. data/lib/quickbooks/model/discount_override.rb +13 -0
  41. data/lib/quickbooks/model/document_numbering.rb +18 -0
  42. data/lib/quickbooks/model/effective_tax_rate.rb +15 -0
  43. data/lib/quickbooks/model/email_address.rb +19 -0
  44. data/lib/quickbooks/model/employee.rb +47 -0
  45. data/lib/quickbooks/model/entity.rb +16 -0
  46. data/lib/quickbooks/model/entity_ref.rb +8 -0
  47. data/lib/quickbooks/model/estimate.rb +76 -0
  48. data/lib/quickbooks/model/exchange_rate.rb +23 -0
  49. data/lib/quickbooks/model/fault.rb +16 -0
  50. data/lib/quickbooks/model/global_tax_calculation.rb +13 -0
  51. data/lib/quickbooks/model/group_line_detail.rb +13 -0
  52. data/lib/quickbooks/model/has_line_items.rb +14 -0
  53. data/lib/quickbooks/model/invoice.rb +107 -0
  54. data/lib/quickbooks/model/invoice_change.rb +9 -0
  55. data/lib/quickbooks/model/invoice_group_line_detail.rb +14 -0
  56. data/lib/quickbooks/model/invoice_line_item.rb +88 -0
  57. data/lib/quickbooks/model/item.rb +87 -0
  58. data/lib/quickbooks/model/item_based_expense_line_detail.rb +20 -0
  59. data/lib/quickbooks/model/item_change.rb +8 -0
  60. data/lib/quickbooks/model/item_group_detail.rb +9 -0
  61. data/lib/quickbooks/model/item_group_line.rb +20 -0
  62. data/lib/quickbooks/model/journal_entry.rb +36 -0
  63. data/lib/quickbooks/model/journal_entry_line_detail.rb +27 -0
  64. data/lib/quickbooks/model/line.rb +95 -0
  65. data/lib/quickbooks/model/line_ex.rb +9 -0
  66. data/lib/quickbooks/model/linked_transaction.rb +9 -0
  67. data/lib/quickbooks/model/markup_info.rb +12 -0
  68. data/lib/quickbooks/model/meta_data.rb +24 -0
  69. data/lib/quickbooks/model/name_value.rb +8 -0
  70. data/lib/quickbooks/model/other_contact_info.rb +8 -0
  71. data/lib/quickbooks/model/payment.rb +43 -0
  72. data/lib/quickbooks/model/payment_change.rb +8 -0
  73. data/lib/quickbooks/model/payment_line_detail.rb +12 -0
  74. data/lib/quickbooks/model/payment_method.rb +25 -0
  75. data/lib/quickbooks/model/physical_address.rb +40 -0
  76. data/lib/quickbooks/model/preferences.rb +49 -0
  77. data/lib/quickbooks/model/purchase.rb +57 -0
  78. data/lib/quickbooks/model/purchase_line_item.rb +44 -0
  79. data/lib/quickbooks/model/purchase_order.rb +50 -0
  80. data/lib/quickbooks/model/purchase_tax_rate_list.rb +11 -0
  81. data/lib/quickbooks/model/refund_receipt.rb +62 -0
  82. data/lib/quickbooks/model/refund_receipt_change.rb +8 -0
  83. data/lib/quickbooks/model/report.rb +52 -0
  84. data/lib/quickbooks/model/sales_item_line_detail.rb +16 -0
  85. data/lib/quickbooks/model/sales_receipt.rb +65 -0
  86. data/lib/quickbooks/model/sales_tax_rate_list.rb +11 -0
  87. data/lib/quickbooks/model/sub_total_line_detail.rb +13 -0
  88. data/lib/quickbooks/model/tax_agency.rb +18 -0
  89. data/lib/quickbooks/model/tax_code.rb +21 -0
  90. data/lib/quickbooks/model/tax_line.rb +15 -0
  91. data/lib/quickbooks/model/tax_line_detail.rb +16 -0
  92. data/lib/quickbooks/model/tax_rate.rb +28 -0
  93. data/lib/quickbooks/model/tax_rate_detail.rb +15 -0
  94. data/lib/quickbooks/model/tax_rate_detail_line.rb +23 -0
  95. data/lib/quickbooks/model/tax_service.rb +52 -0
  96. data/lib/quickbooks/model/telephone_number.rb +13 -0
  97. data/lib/quickbooks/model/term.rb +28 -0
  98. data/lib/quickbooks/model/time_activity.rb +79 -0
  99. data/lib/quickbooks/model/transaction_tax_detail.rb +12 -0
  100. data/lib/quickbooks/model/transfer.rb +21 -0
  101. data/lib/quickbooks/model/upload.rb +35 -0
  102. data/lib/quickbooks/model/validator.rb +10 -0
  103. data/lib/quickbooks/model/vendor.rb +53 -0
  104. data/lib/quickbooks/model/vendor_change.rb +8 -0
  105. data/lib/quickbooks/model/vendor_credit.rb +40 -0
  106. data/lib/quickbooks/model/web_site_address.rb +16 -0
  107. data/lib/quickbooks/service/access_token.rb +38 -0
  108. data/lib/quickbooks/service/account.rb +17 -0
  109. data/lib/quickbooks/service/attachable.rb +12 -0
  110. data/lib/quickbooks/service/base_service.rb +445 -0
  111. data/lib/quickbooks/service/base_service_json.rb +39 -0
  112. data/lib/quickbooks/service/batch.rb +11 -0
  113. data/lib/quickbooks/service/bill.rb +16 -0
  114. data/lib/quickbooks/service/bill_payment.rb +16 -0
  115. data/lib/quickbooks/service/budget.rb +12 -0
  116. data/lib/quickbooks/service/change_data_capture.rb +24 -0
  117. data/lib/quickbooks/service/change_service.rb +28 -0
  118. data/lib/quickbooks/service/class.rb +23 -0
  119. data/lib/quickbooks/service/company_info.rb +12 -0
  120. data/lib/quickbooks/service/credit_memo.rb +16 -0
  121. data/lib/quickbooks/service/credit_memo_change.rb +16 -0
  122. data/lib/quickbooks/service/customer.rb +18 -0
  123. data/lib/quickbooks/service/customer_change.rb +16 -0
  124. data/lib/quickbooks/service/department.rb +23 -0
  125. data/lib/quickbooks/service/deposit.rb +16 -0
  126. data/lib/quickbooks/service/employee.rb +24 -0
  127. data/lib/quickbooks/service/estimate.rb +22 -0
  128. data/lib/quickbooks/service/exchange_rate.rb +25 -0
  129. data/lib/quickbooks/service/invoice.rb +45 -0
  130. data/lib/quickbooks/service/invoice_change.rb +16 -0
  131. data/lib/quickbooks/service/item.rb +32 -0
  132. data/lib/quickbooks/service/item_change.rb +16 -0
  133. data/lib/quickbooks/service/journal_entry.rb +16 -0
  134. data/lib/quickbooks/service/payment.rb +29 -0
  135. data/lib/quickbooks/service/payment_change.rb +16 -0
  136. data/lib/quickbooks/service/payment_method.rb +30 -0
  137. data/lib/quickbooks/service/preferences.rb +12 -0
  138. data/lib/quickbooks/service/purchase.rb +16 -0
  139. data/lib/quickbooks/service/purchase_order.rb +16 -0
  140. data/lib/quickbooks/service/refund_receipt.rb +16 -0
  141. data/lib/quickbooks/service/refund_receipt_change.rb +16 -0
  142. data/lib/quickbooks/service/reports.rb +33 -0
  143. data/lib/quickbooks/service/responses/methods.rb +17 -0
  144. data/lib/quickbooks/service/responses/oauth1_http_response.rb +42 -0
  145. data/lib/quickbooks/service/responses/oauth2_http_response.rb +43 -0
  146. data/lib/quickbooks/service/responses/oauth_http_response.rb +21 -0
  147. data/lib/quickbooks/service/sales_receipt.rb +46 -0
  148. data/lib/quickbooks/service/service_crud.rb +75 -0
  149. data/lib/quickbooks/service/service_crud_json.rb +31 -0
  150. data/lib/quickbooks/service/tax_agency.rb +12 -0
  151. data/lib/quickbooks/service/tax_code.rb +12 -0
  152. data/lib/quickbooks/service/tax_rate.rb +12 -0
  153. data/lib/quickbooks/service/tax_service.rb +11 -0
  154. data/lib/quickbooks/service/term.rb +17 -0
  155. data/lib/quickbooks/service/time_activity.rb +16 -0
  156. data/lib/quickbooks/service/transfer.rb +16 -0
  157. data/lib/quickbooks/service/upload.rb +39 -0
  158. data/lib/quickbooks/service/vendor.rb +24 -0
  159. data/lib/quickbooks/service/vendor_change.rb +16 -0
  160. data/lib/quickbooks/service/vendor_credit.rb +16 -0
  161. data/lib/quickbooks/util/collection.rb +18 -0
  162. data/lib/quickbooks/util/http_encoding_helper.rb +54 -0
  163. data/lib/quickbooks/util/logging.rb +19 -0
  164. data/lib/quickbooks/util/multipart.rb +85 -0
  165. data/lib/quickbooks/util/name_entity.rb +85 -0
  166. data/lib/quickbooks/util/query_builder.rb +35 -0
  167. data/lib/quickbooks/version.rb +5 -0
  168. data/lib/quickbooks-ruby.rb +255 -0
  169. metadata +378 -0
@@ -0,0 +1,21 @@
1
+ module Quickbooks
2
+ module Model
3
+ class BillPaymentLineItem < BaseModel
4
+
5
+ #== Constants
6
+ PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
7
+ DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'
8
+
9
+ xml_accessor :id, :from => 'Id'
10
+ xml_accessor :line_num, :from => 'LineNum', :as => Integer
11
+ xml_accessor :description, :from => 'Description'
12
+ xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
13
+ xml_accessor :detail_type, :from => 'DetailType'
14
+
15
+ xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
16
+
17
+ #== Various detail types
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module Quickbooks
2
+ module Model
3
+ class Budget < BaseModel
4
+ include HasLineItems
5
+
6
+ XML_COLLECTION_NODE = "Budget"
7
+ XML_NODE = "Budget"
8
+ REST_RESOURCE = 'budget'
9
+
10
+ xml_name XML_NODE
11
+
12
+ xml_accessor :id, :from => 'Id'
13
+ xml_accessor :name, :from => 'Name'
14
+ xml_accessor :type, :from => 'BudgetType'
15
+ xml_accessor :entry_type, :from => 'BudgetEntryType'
16
+ xml_accessor :start_date, :from => 'StartDate'
17
+ xml_accessor :end_date, :from => 'EndDate'
18
+ xml_accessor :active?, :from => 'Active'
19
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
20
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
21
+
22
+ xml_accessor :line_items, :from => 'BudgetDetail', :as => [BudgetLineItem]
23
+
24
+ reference_setters
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ module Quickbooks
2
+ module Model
3
+ class BudgetLineItem < BaseModel
4
+
5
+ xml_accessor :date, :from => 'BudgetDate', :as => Date
6
+ xml_accessor :amount, :from => 'Amount'
7
+ xml_accessor :account_ref, :from => 'AccountRef', :as => BaseReference
8
+ xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
9
+ xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
10
+ xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
11
+
12
+ reference_setters
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ module Quickbooks
2
+ module Model
3
+ class ChangeDataCapture < BaseModel
4
+
5
+ attr_accessor :xml
6
+
7
+ TYPES = ["Bill", "BillPayment", "CreditMemo", "Deposit", "Invoice", "JournalEntry", "Payment",
8
+ "Purchase", "RefundReceipt", "SalesReceipt", "PurchaseOrder", "VendorCredit", "Transfer",
9
+ "Estimate", "Account", "Budget", "Class", "Customer", "Department", "Employee", "Item",
10
+ "PaymentMethod", "Term", "Vendor"]
11
+
12
+ def all_types
13
+ data = {}
14
+ TYPES.each do |entity|
15
+ if xml.css(entity).first != nil
16
+ data[entity] = all_of_type(entity)
17
+ end
18
+ end
19
+ data
20
+ end
21
+
22
+ private
23
+
24
+ def all_of_type(entity)
25
+ parse_block(xml.css(entity).first.parent, entity)
26
+ end
27
+
28
+ def parse_block(node, entity)
29
+ model = "Quickbooks::Model::#{entity}".constantize
30
+ models = []
31
+ all_items = node.css(entity).map do |item|
32
+ if item.attribute("status").try(:value) == "Deleted"
33
+ Quickbooks::Model::ChangeModel.from_xml(item)
34
+ else
35
+ model.from_xml(item)
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ module Quickbooks
2
+ module Model
3
+ # Refer to: https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/change_data_capture
4
+ class ChangeModel < BaseModel
5
+ xml_accessor :id, :from => 'Id'
6
+ xml_accessor :status, :from => '@status'
7
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ module Quickbooks
2
+ module Model
3
+ class CheckPayment < BaseModel
4
+ xml_accessor :check_number, :from => 'CheckNum'
5
+ xml_accessor :status, :from => 'Status'
6
+ xml_accessor :name_on_account, :from => 'NameOnAcct'
7
+ xml_accessor :account_number, :from => 'AcctNum'
8
+ xml_accessor :bank_name, :from => 'BankName'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ module Quickbooks
2
+ module Model
3
+ class Class < BaseModel
4
+ XML_COLLECTION_NODE = "Class"
5
+ XML_NODE = "Class"
6
+ REST_RESOURCE = 'class'
7
+ include NameEntity::Quality
8
+ include NameEntity::PermitAlterations
9
+
10
+ xml_name XML_NODE
11
+ xml_accessor :id, :from => 'Id'
12
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
13
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
14
+ xml_accessor :name, :from => 'Name'
15
+ xml_accessor :sub_class, :from => 'SubClass'
16
+ xml_accessor :parent_ref, :from => 'ParentRef', :as => BaseReference
17
+ xml_accessor :fully_qualified_name, :from => 'FullyQualifiedName' # ReadOnly
18
+ xml_accessor :active?, :from => 'Active'
19
+
20
+ reference_setters :parent_ref
21
+
22
+ #== Validations
23
+ validate :names_cannot_contain_invalid_characters
24
+
25
+ def sub_class?
26
+ sub_class.to_s == 'true'
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,69 @@
1
+ module Quickbooks
2
+ module Model
3
+ class CompanyInfo < BaseModel
4
+ XML_COLLECTION_NODE = "CompanyInfo"
5
+ XML_NODE = "CompanyInfo"
6
+ REST_RESOURCE = 'companyinfo'
7
+
8
+ xml_name XML_NODE
9
+ xml_accessor :id, :from => 'Id'
10
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
11
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
12
+ xml_accessor :company_name, :from => 'CompanyName'
13
+ xml_accessor :legal_name, :from => 'LegalName'
14
+ xml_accessor :company_address, :from => 'CompanyAddr', :as => PhysicalAddress
15
+ xml_accessor :customer_communication_address, :from => 'CustomerCommunicationAddr', :as => PhysicalAddress
16
+ xml_accessor :legal_address, :from => 'LegalAddr', :as => PhysicalAddress
17
+ xml_accessor :primary_phone, :from => 'PrimaryPhone', :as => TelephoneNumber
18
+ xml_accessor :company_start_date, :from => 'CompanyStartDate', :as => DateTime
19
+ xml_accessor :employer_id, :from => 'EmployerId'
20
+ xml_accessor :fiscal_year_start_month, :from => 'FiscalYearStartMonth'
21
+ xml_accessor :country, :from => 'Country'
22
+ xml_accessor :email, :from => 'Email', :as => EmailAddress
23
+ xml_accessor :web_site, :from => 'WebAddr', :as => WebSiteAddress
24
+ xml_accessor :supported_languages, :from => 'SupportedLanguages'
25
+ xml_accessor :name_values, :from => 'NameValue', :as => [NameValue]
26
+
27
+ def find_name_value(name)
28
+ nv = name_values.find { |nv| nv.name == name }
29
+ nv ? nv.value : nil
30
+ end
31
+
32
+ def find_boolean_name_value(name)
33
+ find_name_value(name) == "true"
34
+ end
35
+
36
+ def industry_type
37
+ find_name_value("IndustryType")
38
+ end
39
+
40
+ def industry_code
41
+ find_name_value("IndustryCode")
42
+ end
43
+
44
+ def company_type
45
+ find_name_value("CompanyType")
46
+ end
47
+
48
+ def subscription_status
49
+ find_name_value("SubscriptionStatus")
50
+ end
51
+
52
+ def offering_sku
53
+ find_name_value("OfferingSku")
54
+ end
55
+
56
+ def neo_enabled
57
+ find_boolean_name_value("NeoEnabled")
58
+ end
59
+
60
+ def payroll_feature
61
+ find_boolean_name_value("PayrollFeature")
62
+ end
63
+
64
+ def accountant_feature
65
+ find_boolean_name_value("AccountantFeature")
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,17 @@
1
+ module Quickbooks
2
+ module Model
3
+ class CreditCardPayment < BaseModel
4
+ xml_accessor :number, :from => 'Number'
5
+ xml_accessor :type, :from => 'Type'
6
+ xml_accessor :name_on_account, :from => 'NameOnAcct'
7
+ xml_accessor :expiry_month, :from => 'CcExpiryMonth', :as => Integer
8
+ xml_accessor :expiry_year, :from => 'CcExpiryYear', :as => Integer
9
+ xml_accessor :bill_address, :from => 'BillAddrStreet'
10
+ xml_accessor :postal_code, :from => 'PostalCode'
11
+ xml_accessor :commercial_card_code, :from => 'CommercialCardCode'
12
+ xml_accessor :txn_mode, :from => 'CCTxnMode'
13
+ xml_accessor :txn_type, :from => 'CCTxnType'
14
+ xml_accessor :previous_txn_id, :from => 'PrevCCTransId'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,59 @@
1
+ module Quickbooks
2
+ module Model
3
+ class CreditMemo < BaseModel
4
+ include DocumentNumbering
5
+ include GlobalTaxCalculation
6
+ include HasLineItems
7
+
8
+ XML_COLLECTION_NODE = "CreditMemo"
9
+ XML_NODE = "CreditMemo"
10
+ REST_RESOURCE = 'creditmemo'
11
+
12
+ xml_accessor :id, :from => 'Id'
13
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
14
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
15
+ xml_accessor :auto_doc_number, :from => 'AutoDocNumber' # See auto_doc_number! method below for usage
16
+ xml_accessor :doc_number, :from => 'DocNumber'
17
+ xml_accessor :txn_date, :from => 'TxnDate', :as => Date
18
+ xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
19
+
20
+ xml_accessor :line_items, :from => 'Line', :as => [Line]
21
+ xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
22
+ xml_accessor :private_note, :from => 'PrivateNote'
23
+ xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
24
+
25
+ xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
26
+ xml_accessor :customer_memo, :from => 'CustomerMemo'
27
+ xml_accessor :bill_email, :from => 'BillEmail', :as => EmailAddress
28
+ xml_accessor :bill_address, :from => 'BillAddr', :as => PhysicalAddress
29
+ xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
30
+ xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
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
42
+
43
+ # readonly
44
+ xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
45
+
46
+ # backward-compatible alias
47
+ alias_attribute :placed_on, :txn_date
48
+
49
+ validate :line_item_size
50
+ validate :document_numbering
51
+
52
+ reference_setters
53
+
54
+ def email=(email)
55
+ self.bill_email = EmailAddress.new(email)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,8 @@
1
+ module Quickbooks
2
+ module Model
3
+ # Refer to: https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/change_data_capture
4
+ class CreditMemoChange < ChangeModel
5
+ XML_NODE = "CreditMemo"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module Quickbooks
2
+ module Model
3
+ class CustomField < BaseModel
4
+ xml_accessor :id, :from => 'DefinitionId', :as => Integer
5
+ xml_accessor :name, :from => 'Name'
6
+ xml_accessor :type, :from => 'Type'
7
+ xml_accessor :string_value, :from => 'StringValue'
8
+ xml_accessor :boolean_value, :from => 'BooleanValue'
9
+ xml_accessor :date_value, :from => 'DateValue', :as => Date
10
+ xml_accessor :number_value, :from => 'NumberValue', :as => Integer
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,76 @@
1
+ # == Business Rules
2
+ # * The DisplayName, GivenName, MiddleName, FamilyName, and PrintOnCheckName attributes must not contain a colon,":".
3
+ # * The DisplayName attribute must be unique across all other customers, employees, vendors, and other names.
4
+ # * The PrimaryEmailAddress attribute must contain an at sign, "@," and dot, ".".
5
+ # * Nested customer objects can be used to define sub-customers, jobs, or a combination of both, under a parent.
6
+ # * Up to four levels of nesting can be defined under a top-level customer object.
7
+ # * The Job attribute defines whether the object is a top-level customer or nested sub-customer/job.
8
+ # * Either the DisplayName attribute or at least one of Title, GivenName, MiddleName, FamilyName, Suffix, or FullyQualifiedName attributes are required during create.
9
+
10
+ module Quickbooks
11
+ module Model
12
+ class Customer < BaseModel
13
+ XML_COLLECTION_NODE = "Customer"
14
+ XML_NODE = "Customer"
15
+ REST_RESOURCE = 'customer'
16
+ include NameEntity::Quality
17
+ include NameEntity::PermitAlterations
18
+
19
+ xml_name XML_NODE
20
+ xml_accessor :id, :from => 'Id'
21
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
22
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
23
+ xml_accessor :title, :from => 'Title'
24
+ xml_accessor :given_name, :from => 'GivenName'
25
+ xml_accessor :middle_name, :from => 'MiddleName'
26
+ xml_accessor :family_name, :from => 'FamilyName'
27
+ xml_accessor :company_name, :from => 'CompanyName'
28
+ xml_accessor :display_name, :from => 'DisplayName'
29
+ xml_accessor :print_on_check_name, :from => 'PrintOnCheckName'
30
+ xml_accessor :active?, :from => 'Active'
31
+ xml_accessor :primary_phone, :from => 'PrimaryPhone', :as => TelephoneNumber
32
+ xml_accessor :alternate_phone, :from => 'AlternatePhone', :as => TelephoneNumber
33
+ xml_accessor :mobile_phone, :from => 'Mobile', :as => TelephoneNumber
34
+ xml_accessor :fax_phone, :from => 'Fax', :as => TelephoneNumber
35
+ xml_accessor :primary_email_address, :from => 'PrimaryEmailAddr', :as => EmailAddress
36
+ xml_accessor :web_site, :from => 'WebAddr', :as => WebSiteAddress
37
+ xml_accessor :billing_address, :from => 'BillAddr', :as => PhysicalAddress
38
+ xml_accessor :shipping_address, :from => 'ShipAddr', :as => PhysicalAddress
39
+ xml_accessor :job, :from => 'Job'
40
+ xml_accessor :bill_with_parent, :from => 'BillWithParent'
41
+ xml_accessor :parent_ref, :from => 'ParentRef', :as => BaseReference
42
+ xml_accessor :level, :from => 'Level'
43
+ xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
44
+ xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
45
+ xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
46
+ xml_accessor :open_balance_date, :from => 'OpenBalanceDate', :as => Date
47
+ xml_accessor :balance_with_jobs, :from => 'BalanceWithJobs', :as => BigDecimal, :to_xml => to_xml_big_decimal
48
+ xml_accessor :preferred_delivery_method, :from => 'PreferredDeliveryMethod'
49
+ xml_accessor :resale_num, :from => 'ResaleNum'
50
+ xml_accessor :suffix, :from => 'Suffix'
51
+ xml_accessor :fully_qualified_name, :from => 'FullyQualifiedName'
52
+ xml_accessor :taxable, :from => 'Taxable'
53
+ xml_accessor :default_tax_code_ref, :from => 'DefaultTaxCodeRef', :as => BaseReference
54
+ xml_accessor :notes, :from => 'Notes'
55
+ xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
56
+
57
+ #== Validations
58
+ validate :names_cannot_contain_invalid_characters
59
+ validate :email_address_is_valid
60
+
61
+ reference_setters :parent_ref, :sales_term_ref, :payment_method_ref, :default_tax_code_ref, :currency_ref
62
+
63
+ def job?
64
+ job.to_s == 'true'
65
+ end
66
+
67
+ def bill_with_parent?
68
+ bill_with_parent.to_s == 'true'
69
+ end
70
+
71
+ def taxable?
72
+ taxable.to_s == 'true'
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,8 @@
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 < ChangeModel
5
+ XML_NODE = "Customer"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,46 @@
1
+ module Quickbooks
2
+ module Model
3
+ module Definition
4
+
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+ # https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services
11
+ TRANSACTION_ENTITIES = %w{
12
+ Bill
13
+ BillPayment
14
+ CreditMemo
15
+ Estimate
16
+ Invoice
17
+ JournalEntry
18
+ Payment
19
+ Purchase
20
+ PurchaseOrder
21
+ RefundReceipt
22
+ SalesReceipt
23
+ TimeActivity
24
+ VendorCredit
25
+ }
26
+
27
+ def is_transaction_entity?
28
+ TRANSACTION_ENTITIES.include?(self.name.demodulize)
29
+ end
30
+
31
+ def is_name_list_entity?
32
+ !self.is_transaction_entity?
33
+ end
34
+ end
35
+
36
+ def is_transaction_entity?
37
+ self.class.is_transaction_entity?
38
+ end
39
+
40
+ def is_name_list_entity?
41
+ self.class.is_name_list_entity?
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,8 @@
1
+ module Quickbooks
2
+ module Model
3
+ class DeliveryInfo < BaseModel
4
+ xml_accessor :delivery_type, :from => 'DeliveryType'
5
+ xml_accessor :delivery_time, :from => 'DeliveryTime', :as => DateTime
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,31 @@
1
+ module Quickbooks
2
+ module Model
3
+ class Department < BaseModel
4
+ XML_COLLECTION_NODE = "Department"
5
+ XML_NODE = "Department"
6
+ REST_RESOURCE = 'department'
7
+ include NameEntity::Quality
8
+ include NameEntity::PermitAlterations
9
+
10
+ xml_name XML_NODE
11
+ xml_accessor :id, :from => 'Id'
12
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
13
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
14
+ xml_accessor :name, :from => 'Name'
15
+ xml_accessor :sub_department, :from => 'SubDepartment'
16
+ xml_accessor :parent_ref, :from => 'ParentRef', :as => BaseReference
17
+ xml_accessor :fully_qualified_name, :from => 'FullyQualifiedName' # ReadOnly
18
+ xml_accessor :active?, :from => 'Active'
19
+
20
+ reference_setters :parent_ref
21
+
22
+ #== Validations
23
+ validate :names_cannot_contain_invalid_characters
24
+
25
+ def sub_department?
26
+ sub_department.to_s == 'true'
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,44 @@
1
+ # == Business Rules
2
+ # * There must be at least one line item included in a create request
3
+ # * Any transaction that funds the Undeposited Funds account can be linked to a Deposit object with Deposit.Line.LinkedTxn
4
+
5
+ module Quickbooks
6
+ module Model
7
+ class Deposit < BaseModel
8
+ include DocumentNumbering
9
+ include HasLineItems
10
+
11
+ #== Constants
12
+ XML_COLLECTION_MODE = "Deposit"
13
+ XML_NODE = "Deposit"
14
+ REST_RESOURCE = "deposit"
15
+
16
+ xml_accessor :id, :from => "Id", :as => Integer
17
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
18
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
19
+ xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
20
+ xml_accessor :auto_doc_number, :from => 'AutoDocNumber' # See auto_doc_number! method below for usage
21
+ xml_accessor :doc_number, :from => 'DocNumber'
22
+ xml_accessor :txn_date, :from => 'TxnDate', :as => Date
23
+ xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
24
+ xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
25
+ xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
26
+ xml_accessor :private_note, :from => 'PrivateNote'
27
+ xml_accessor :txn_status, :from => 'TxnStatus'
28
+ xml_accessor :line_items, :from => 'Line', :as => [DepositLineItem]
29
+ xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
30
+ xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
31
+ xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
32
+
33
+
34
+ reference_setters :department_ref, :currency_ref, :deposit_to_account_ref
35
+
36
+ #== Validations
37
+ validate :line_item_size
38
+ validate :document_numbering
39
+
40
+ private
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ module Quickbooks
2
+ module Model
3
+ class DepositLineDetail < BaseModel
4
+
5
+ xml_accessor :entity_ref, :from => 'Entity', :as => BaseReference
6
+ xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
7
+ xml_accessor :account_ref, :from => 'AccountRef', :as => BaseReference
8
+ xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
9
+ xml_accessor :check_num, :from => 'CheckNum'
10
+ xml_accessor :txn_type, :from => 'TxnType'
11
+ xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
12
+
13
+ reference_setters :class_ref, :account_ref, :payment_method_ref, :entity_ref
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,35 @@
1
+ module Quickbooks
2
+ module Model
3
+ class DepositLineItem < BaseModel
4
+
5
+ #== Constants
6
+ DEPOSIT_LINE_DETAIL = 'DepositLineDetail'
7
+
8
+ xml_accessor :id, :from => 'Id'
9
+ xml_accessor :line_num, :from => 'LineNum', :as => Integer
10
+ xml_accessor :description, :from => 'Description'
11
+ xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
12
+ xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
13
+
14
+ xml_accessor :detail_type, :from => 'DetailType'
15
+
16
+ #== Various detail types
17
+ xml_accessor :deposit_line_detail, :from => 'DepositLineDetail', :as => DepositLineDetail
18
+
19
+ xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
20
+
21
+
22
+ def deposit_line_detail?
23
+ detail_type.to_s == DEPOSIT_LINE_DETAIL
24
+ end
25
+
26
+ def deposit_line_detail!
27
+ self.detail_type = DEPOSIT_LINE_DETAIL
28
+ self.deposit_line_detail = DepositLineDetail.new
29
+
30
+ yield self.deposit_line_detail if block_given?
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module Quickbooks
2
+ module Model
3
+ class DescriptionLineDetail < BaseModel
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/invoice#DiscountLineDetail
2
+ module Quickbooks
3
+ module Model
4
+ class DiscountLineDetail < BaseModel
5
+ xml_accessor :discount_ref, :from => 'DiscountRef', :as => BaseReference
6
+ xml_accessor :percent_based?, :from => 'PercentBased'
7
+ xml_accessor :discount_percent, :from => 'DiscountPercent', :as => BigDecimal, :to_xml => to_xml_big_decimal
8
+ xml_accessor :discount_account_ref, :from => 'DiscountAccountRef', :as => BaseReference
9
+ xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
10
+ xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
11
+
12
+ reference_setters :tax_code_ref, :class_ref, :discount_ref, :discount_account_ref
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module Quickbooks
2
+ module Model
3
+ class DiscountOverride < BaseModel
4
+ xml_accessor :discount_ref, :from => 'DiscountRef', :as => BaseReference
5
+ xml_accessor :percent_based?, :from => 'PercentBased'
6
+ xml_accessor :discount_percent, :from => 'DiscountPercent', :as => BigDecimal, :to_xml => to_xml_big_decimal
7
+ xml_accessor :discount_account_ref, :from => 'DiscountAccountRef', :as => BaseReference
8
+
9
+ reference_setters :discount_ref, :discount_account_ref
10
+
11
+ end
12
+ end
13
+ end