quickbooks-ruby-oauth2 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/quickbooks/faraday/middleware/gzip.rb +72 -0
- data/lib/quickbooks/model/access_token_response.rb +29 -0
- data/lib/quickbooks/model/account.rb +78 -0
- data/lib/quickbooks/model/account_based_expense_line_detail.rb +15 -0
- data/lib/quickbooks/model/attachable.rb +33 -0
- data/lib/quickbooks/model/attachable_ref.rb +22 -0
- data/lib/quickbooks/model/base_model.rb +120 -0
- data/lib/quickbooks/model/base_model_json.rb +16 -0
- data/lib/quickbooks/model/base_reference.rb +23 -0
- data/lib/quickbooks/model/batch_request.rb +45 -0
- data/lib/quickbooks/model/batch_response.rb +33 -0
- data/lib/quickbooks/model/bill.rb +45 -0
- data/lib/quickbooks/model/bill_line_item.rb +42 -0
- data/lib/quickbooks/model/bill_payment.rb +40 -0
- data/lib/quickbooks/model/bill_payment_check.rb +12 -0
- data/lib/quickbooks/model/bill_payment_credit_card.rb +10 -0
- data/lib/quickbooks/model/bill_payment_line_item.rb +21 -0
- data/lib/quickbooks/model/budget.rb +27 -0
- data/lib/quickbooks/model/budget_line_item.rb +15 -0
- data/lib/quickbooks/model/change_data_capture.rb +42 -0
- data/lib/quickbooks/model/change_model.rb +10 -0
- data/lib/quickbooks/model/check_payment.rb +11 -0
- data/lib/quickbooks/model/class.rb +31 -0
- data/lib/quickbooks/model/company_info.rb +69 -0
- data/lib/quickbooks/model/credit_card_payment.rb +17 -0
- data/lib/quickbooks/model/credit_memo.rb +59 -0
- data/lib/quickbooks/model/credit_memo_change.rb +8 -0
- data/lib/quickbooks/model/custom_field.rb +13 -0
- data/lib/quickbooks/model/customer.rb +76 -0
- data/lib/quickbooks/model/customer_change.rb +8 -0
- data/lib/quickbooks/model/definition.rb +46 -0
- data/lib/quickbooks/model/delivery_info.rb +8 -0
- data/lib/quickbooks/model/department.rb +31 -0
- data/lib/quickbooks/model/deposit.rb +44 -0
- data/lib/quickbooks/model/deposit_line_detail.rb +17 -0
- data/lib/quickbooks/model/deposit_line_item.rb +35 -0
- data/lib/quickbooks/model/description_line_detail.rb +7 -0
- data/lib/quickbooks/model/discount_line_detail.rb +15 -0
- data/lib/quickbooks/model/discount_override.rb +13 -0
- data/lib/quickbooks/model/document_numbering.rb +18 -0
- data/lib/quickbooks/model/effective_tax_rate.rb +15 -0
- data/lib/quickbooks/model/email_address.rb +19 -0
- data/lib/quickbooks/model/employee.rb +47 -0
- data/lib/quickbooks/model/entity.rb +16 -0
- data/lib/quickbooks/model/entity_ref.rb +8 -0
- data/lib/quickbooks/model/estimate.rb +76 -0
- data/lib/quickbooks/model/exchange_rate.rb +23 -0
- data/lib/quickbooks/model/fault.rb +16 -0
- data/lib/quickbooks/model/global_tax_calculation.rb +13 -0
- data/lib/quickbooks/model/group_line_detail.rb +13 -0
- data/lib/quickbooks/model/has_line_items.rb +14 -0
- data/lib/quickbooks/model/invoice.rb +107 -0
- data/lib/quickbooks/model/invoice_change.rb +9 -0
- data/lib/quickbooks/model/invoice_group_line_detail.rb +14 -0
- data/lib/quickbooks/model/invoice_line_item.rb +88 -0
- data/lib/quickbooks/model/item.rb +87 -0
- data/lib/quickbooks/model/item_based_expense_line_detail.rb +20 -0
- data/lib/quickbooks/model/item_change.rb +8 -0
- data/lib/quickbooks/model/item_group_detail.rb +9 -0
- data/lib/quickbooks/model/item_group_line.rb +20 -0
- data/lib/quickbooks/model/journal_entry.rb +36 -0
- data/lib/quickbooks/model/journal_entry_line_detail.rb +27 -0
- data/lib/quickbooks/model/line.rb +95 -0
- data/lib/quickbooks/model/line_ex.rb +9 -0
- data/lib/quickbooks/model/linked_transaction.rb +9 -0
- data/lib/quickbooks/model/markup_info.rb +12 -0
- data/lib/quickbooks/model/meta_data.rb +24 -0
- data/lib/quickbooks/model/name_value.rb +8 -0
- data/lib/quickbooks/model/other_contact_info.rb +8 -0
- data/lib/quickbooks/model/payment.rb +43 -0
- data/lib/quickbooks/model/payment_change.rb +8 -0
- data/lib/quickbooks/model/payment_line_detail.rb +12 -0
- data/lib/quickbooks/model/payment_method.rb +25 -0
- data/lib/quickbooks/model/physical_address.rb +40 -0
- data/lib/quickbooks/model/preferences.rb +49 -0
- data/lib/quickbooks/model/purchase.rb +57 -0
- data/lib/quickbooks/model/purchase_line_item.rb +44 -0
- data/lib/quickbooks/model/purchase_order.rb +50 -0
- data/lib/quickbooks/model/purchase_tax_rate_list.rb +11 -0
- data/lib/quickbooks/model/refund_receipt.rb +62 -0
- data/lib/quickbooks/model/refund_receipt_change.rb +8 -0
- data/lib/quickbooks/model/report.rb +52 -0
- data/lib/quickbooks/model/sales_item_line_detail.rb +16 -0
- data/lib/quickbooks/model/sales_receipt.rb +65 -0
- data/lib/quickbooks/model/sales_tax_rate_list.rb +11 -0
- data/lib/quickbooks/model/sub_total_line_detail.rb +13 -0
- data/lib/quickbooks/model/tax_agency.rb +18 -0
- data/lib/quickbooks/model/tax_code.rb +21 -0
- data/lib/quickbooks/model/tax_line.rb +15 -0
- data/lib/quickbooks/model/tax_line_detail.rb +16 -0
- data/lib/quickbooks/model/tax_rate.rb +28 -0
- data/lib/quickbooks/model/tax_rate_detail.rb +15 -0
- data/lib/quickbooks/model/tax_rate_detail_line.rb +23 -0
- data/lib/quickbooks/model/tax_service.rb +52 -0
- data/lib/quickbooks/model/telephone_number.rb +13 -0
- data/lib/quickbooks/model/term.rb +28 -0
- data/lib/quickbooks/model/time_activity.rb +79 -0
- data/lib/quickbooks/model/transaction_tax_detail.rb +12 -0
- data/lib/quickbooks/model/transfer.rb +21 -0
- data/lib/quickbooks/model/upload.rb +35 -0
- data/lib/quickbooks/model/validator.rb +10 -0
- data/lib/quickbooks/model/vendor.rb +53 -0
- data/lib/quickbooks/model/vendor_change.rb +8 -0
- data/lib/quickbooks/model/vendor_credit.rb +40 -0
- data/lib/quickbooks/model/web_site_address.rb +16 -0
- data/lib/quickbooks/service/access_token.rb +38 -0
- data/lib/quickbooks/service/account.rb +17 -0
- data/lib/quickbooks/service/attachable.rb +12 -0
- data/lib/quickbooks/service/base_service.rb +445 -0
- data/lib/quickbooks/service/base_service_json.rb +39 -0
- data/lib/quickbooks/service/batch.rb +11 -0
- data/lib/quickbooks/service/bill.rb +16 -0
- data/lib/quickbooks/service/bill_payment.rb +16 -0
- data/lib/quickbooks/service/budget.rb +12 -0
- data/lib/quickbooks/service/change_data_capture.rb +24 -0
- data/lib/quickbooks/service/change_service.rb +28 -0
- data/lib/quickbooks/service/class.rb +23 -0
- data/lib/quickbooks/service/company_info.rb +12 -0
- data/lib/quickbooks/service/credit_memo.rb +16 -0
- data/lib/quickbooks/service/credit_memo_change.rb +16 -0
- data/lib/quickbooks/service/customer.rb +18 -0
- data/lib/quickbooks/service/customer_change.rb +16 -0
- data/lib/quickbooks/service/department.rb +23 -0
- data/lib/quickbooks/service/deposit.rb +16 -0
- data/lib/quickbooks/service/employee.rb +24 -0
- data/lib/quickbooks/service/estimate.rb +22 -0
- data/lib/quickbooks/service/exchange_rate.rb +25 -0
- data/lib/quickbooks/service/invoice.rb +45 -0
- data/lib/quickbooks/service/invoice_change.rb +16 -0
- data/lib/quickbooks/service/item.rb +32 -0
- data/lib/quickbooks/service/item_change.rb +16 -0
- data/lib/quickbooks/service/journal_entry.rb +16 -0
- data/lib/quickbooks/service/payment.rb +29 -0
- data/lib/quickbooks/service/payment_change.rb +16 -0
- data/lib/quickbooks/service/payment_method.rb +30 -0
- data/lib/quickbooks/service/preferences.rb +12 -0
- data/lib/quickbooks/service/purchase.rb +16 -0
- data/lib/quickbooks/service/purchase_order.rb +16 -0
- data/lib/quickbooks/service/refund_receipt.rb +16 -0
- data/lib/quickbooks/service/refund_receipt_change.rb +16 -0
- data/lib/quickbooks/service/reports.rb +33 -0
- data/lib/quickbooks/service/responses/methods.rb +17 -0
- data/lib/quickbooks/service/responses/oauth1_http_response.rb +42 -0
- data/lib/quickbooks/service/responses/oauth2_http_response.rb +43 -0
- data/lib/quickbooks/service/responses/oauth_http_response.rb +21 -0
- data/lib/quickbooks/service/sales_receipt.rb +46 -0
- data/lib/quickbooks/service/service_crud.rb +75 -0
- data/lib/quickbooks/service/service_crud_json.rb +31 -0
- data/lib/quickbooks/service/tax_agency.rb +12 -0
- data/lib/quickbooks/service/tax_code.rb +12 -0
- data/lib/quickbooks/service/tax_rate.rb +12 -0
- data/lib/quickbooks/service/tax_service.rb +11 -0
- data/lib/quickbooks/service/term.rb +17 -0
- data/lib/quickbooks/service/time_activity.rb +16 -0
- data/lib/quickbooks/service/transfer.rb +16 -0
- data/lib/quickbooks/service/upload.rb +39 -0
- data/lib/quickbooks/service/vendor.rb +24 -0
- data/lib/quickbooks/service/vendor_change.rb +16 -0
- data/lib/quickbooks/service/vendor_credit.rb +16 -0
- data/lib/quickbooks/util/collection.rb +18 -0
- data/lib/quickbooks/util/http_encoding_helper.rb +54 -0
- data/lib/quickbooks/util/logging.rb +19 -0
- data/lib/quickbooks/util/multipart.rb +85 -0
- data/lib/quickbooks/util/name_entity.rb +85 -0
- data/lib/quickbooks/util/query_builder.rb +35 -0
- data/lib/quickbooks/version.rb +5 -0
- data/lib/quickbooks-ruby.rb +255 -0
- metadata +378 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class Report < BaseModel
|
4
|
+
|
5
|
+
attr_accessor :xml
|
6
|
+
|
7
|
+
def all_rows
|
8
|
+
@all_rows ||= xml.css("ColData:first-child").map {|node| parse_row(node.parent) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def columns
|
12
|
+
@columns ||= begin
|
13
|
+
nodes = xml.css('Column')
|
14
|
+
nodes.map do |node|
|
15
|
+
# There is also a ColType field, but it does not seem valuable to capture
|
16
|
+
node.at('ColTitle').content
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_row(label)
|
22
|
+
all_rows.find {|r| r[0] == label }
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Parses the given row:
|
28
|
+
# <Row type="Data">
|
29
|
+
# <ColData value="Checking" id="35"/>
|
30
|
+
# <ColData value="1201.00"/>
|
31
|
+
# <ColData value="200.50"/>
|
32
|
+
# </Row>
|
33
|
+
#
|
34
|
+
# To:
|
35
|
+
# ['Checking', BigDecimal(1201.00), BigDecimal(200.50)]
|
36
|
+
def parse_row(row_node)
|
37
|
+
row_node.elements.map.with_index do |el, i|
|
38
|
+
value = el.attr('value')
|
39
|
+
|
40
|
+
if i.zero? # Return the first column as a string, its the label.
|
41
|
+
value
|
42
|
+
elsif value.blank?
|
43
|
+
nil
|
44
|
+
else
|
45
|
+
BigDecimal(value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class SalesItemLineDetail < BaseModel
|
4
|
+
xml_accessor :item_ref, :from => 'ItemRef', :as => BaseReference
|
5
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
6
|
+
xml_accessor :unit_price, :from => 'UnitPrice', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
7
|
+
xml_accessor :rate_percent, :from => 'RatePercent', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
8
|
+
xml_accessor :price_level_ref, :from => 'PriceLevelRef', :as => BaseReference
|
9
|
+
xml_accessor :quantity, :from => 'Qty', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
10
|
+
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
|
11
|
+
xml_accessor :service_date, :from => 'ServiceDate', :as => Date
|
12
|
+
|
13
|
+
reference_setters :item_ref, :class_ref, :price_level_ref, :tax_code_ref
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class SalesReceipt < BaseModel
|
4
|
+
include DocumentNumbering
|
5
|
+
include GlobalTaxCalculation
|
6
|
+
include HasLineItems
|
7
|
+
|
8
|
+
XML_COLLECTION_NODE = "SalesReceipt"
|
9
|
+
XML_NODE = "SalesReceipt"
|
10
|
+
REST_RESOURCE = 'salesreceipt'
|
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 => Time
|
18
|
+
xml_accessor :line_items, :from => 'Line', :as => [Line]
|
19
|
+
xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
|
20
|
+
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
21
|
+
xml_accessor :bill_email, :from => 'BillEmail', :as => EmailAddress
|
22
|
+
xml_accessor :bill_address, :from => 'BillAddr', :as => PhysicalAddress
|
23
|
+
xml_accessor :delivery_info, :from => 'DeliveryInfo', :as => DeliveryInfo
|
24
|
+
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
25
|
+
xml_accessor :po_number, :from => 'PONumber'
|
26
|
+
xml_accessor :ship_method_ref, :from => 'ShipMethodRef', :as => BaseReference
|
27
|
+
xml_accessor :ship_date, :from => 'ShipDate', :as => Time
|
28
|
+
xml_accessor :tracking_num, :from => 'TrackingNum'
|
29
|
+
xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
|
30
|
+
xml_accessor :payment_ref_number, :from => 'PaymentRefNum'
|
31
|
+
xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
|
32
|
+
xml_accessor :customer_memo, :from => 'CustomerMemo'
|
33
|
+
xml_accessor :private_note, :from => 'PrivateNote'
|
34
|
+
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
35
|
+
xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
|
36
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
37
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
38
|
+
xml_accessor :apply_tax_after_discount?, :from => 'ApplyTaxAfterDiscount'
|
39
|
+
xml_accessor :print_status, :from => 'PrintStatus'
|
40
|
+
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
41
|
+
|
42
|
+
xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
|
43
|
+
xml_accessor :email_status, :from => 'EmailStatus'
|
44
|
+
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
45
|
+
|
46
|
+
# readonly
|
47
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
|
48
|
+
xml_accessor :home_total, :from => 'HomeTotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
49
|
+
|
50
|
+
# backward-compatible alias
|
51
|
+
alias_attribute :placed_on, :txn_date
|
52
|
+
|
53
|
+
reference_setters
|
54
|
+
|
55
|
+
validate :line_item_size
|
56
|
+
validate :document_numbering
|
57
|
+
|
58
|
+
def billing_email_address=(email_address_string)
|
59
|
+
self.bill_email = EmailAddress.new(email_address_string)
|
60
|
+
end
|
61
|
+
alias_method :email=, :billing_email_address= # backward backward compatibility to v0.4.6
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class SalesTaxRateList < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "SalesTaxRateList"
|
5
|
+
XML_NODE = "SalesTaxRateList"
|
6
|
+
REST_RESOURCE = "salestaxratelist"
|
7
|
+
|
8
|
+
xml_accessor :tax_rate_detail, :from => "TaxRateDetail", :as => [TaxRateDetail]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class SubTotalLineDetail < BaseModel
|
4
|
+
xml_accessor :item_ref, :from => 'ItemRef', :as => BaseReference
|
5
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
6
|
+
xml_accessor :unit_price, :from => 'UnitPrice', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
7
|
+
xml_accessor :quantity, :from => 'Qty', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
8
|
+
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
|
9
|
+
|
10
|
+
reference_setters :item_ref, :class_ref, :tax_code_ref
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TaxAgency < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "TaxAgency"
|
5
|
+
XML_NODE = "TaxAgency"
|
6
|
+
REST_RESOURCE = "taxagency"
|
7
|
+
|
8
|
+
xml_accessor :id, :from => "Id"
|
9
|
+
xml_accessor :sync_token, :from => "SyncToken", :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => "MetaData", :as => MetaData
|
11
|
+
xml_accessor :tax_tracked_on_purchases?, :from => "TaxTrackedOnPurchases"
|
12
|
+
xml_accessor :tax_tracked_on_sales?, :from => "TaxTrackedOnSales"
|
13
|
+
xml_accessor :display_name, :from => "DisplayName"
|
14
|
+
|
15
|
+
validates_presence_of :display_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TaxCode < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "TaxCode"
|
5
|
+
XML_NODE = "TaxCode"
|
6
|
+
REST_RESOURCE = "taxcode"
|
7
|
+
|
8
|
+
xml_accessor :id, :from => "Id"
|
9
|
+
xml_accessor :sync_token, :from => "SyncToken", :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => "MetaData", :as => MetaData
|
11
|
+
xml_accessor :name, :from => "Name"
|
12
|
+
xml_accessor :description, :from => "Description"
|
13
|
+
xml_accessor :active?, :from => "Active"
|
14
|
+
xml_accessor :taxable?, :from => "Taxable"
|
15
|
+
xml_accessor :tax_group?, :from => "TaxGroup"
|
16
|
+
xml_accessor :sales_tax_rate_list, :from => "SalesTaxRateList", :as => SalesTaxRateList
|
17
|
+
xml_accessor :purchase_tax_rate_list, :from => "PurchaseTaxRateList", :as => PurchaseTaxRateList
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TaxLine < BaseModel
|
4
|
+
|
5
|
+
xml_accessor :id, :from => 'Id'
|
6
|
+
xml_accessor :line_num, :from => 'LineNum', :as => Integer
|
7
|
+
xml_accessor :description, :from => 'Description'
|
8
|
+
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
9
|
+
xml_accessor :detail_type, :from => 'DetailType'
|
10
|
+
|
11
|
+
xml_accessor :tax_line_detail, :from => 'TaxLineDetail', :as => TaxLineDetail
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TaxLineDetail < BaseModel
|
4
|
+
|
5
|
+
xml_accessor :percent_based?, :from => 'PercentBased'
|
6
|
+
xml_accessor :net_amount_taxable, :from => 'NetAmountTaxable', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
7
|
+
xml_accessor :tax_inclusive_amount, :from => 'TaxInclusiveAmount', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
8
|
+
xml_accessor :override_delta_amount, :from => 'OverrideDeltaAmount', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
9
|
+
xml_accessor :tax_percent, :from => 'TaxPercent', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
10
|
+
xml_accessor :tax_rate_ref, :from => 'TaxRateRef', :as => BaseReference
|
11
|
+
|
12
|
+
reference_setters :tax_rate_ref
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TaxRate < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "TaxRate"
|
5
|
+
XML_NODE = "TaxRate"
|
6
|
+
REST_RESOURCE = "taxrate"
|
7
|
+
|
8
|
+
xml_accessor :id, :from => "Id"
|
9
|
+
xml_accessor :sync_token, :from => "SyncToken", :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => "MetaData", :as => MetaData
|
11
|
+
xml_accessor :name, :from => "Name"
|
12
|
+
xml_accessor :description, :from => "Description"
|
13
|
+
xml_accessor :active?, :from => "Active"
|
14
|
+
xml_accessor :rate_value, :from => "RateValue", :as => BigDecimal, :to_xml => :to_f.to_proc
|
15
|
+
xml_accessor :agency_ref, :from => "AgencyRef", :as => BaseReference
|
16
|
+
xml_accessor :tax_return_line_ref, :from => "TaxReturnLineRef", :as => BaseReference
|
17
|
+
xml_accessor :special_tax_type, :from => "SpecialTaxType"
|
18
|
+
xml_accessor :display_type, :from => "DisplayType"
|
19
|
+
xml_accessor :effective_tax_rate, :from => "EffectiveTaxRate", :as => [EffectiveTaxRate]
|
20
|
+
|
21
|
+
validates_presence_of :name, :rate_value
|
22
|
+
|
23
|
+
reference_setters :agency_ref
|
24
|
+
reference_setters :tax_return_line_ref
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TaxRateDetail < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "TaxRateDetail"
|
5
|
+
XML_NODE = "TaxRateDetail"
|
6
|
+
REST_RESOURCE = "taxratedetail"
|
7
|
+
|
8
|
+
xml_accessor :tax_rate_ref, :from => "TaxRateRef", :as => BaseReference
|
9
|
+
xml_accessor :tax_type_applicable, :from => "TaxTypeApplicable"
|
10
|
+
xml_accessor :tax_order, :from => "TaxOrder"
|
11
|
+
|
12
|
+
reference_setters :tax_rate_ref
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TaxRateDetailLine < BaseModel
|
4
|
+
|
5
|
+
xml_accessor :tax_rate_id, :from => "TaxRateId"
|
6
|
+
xml_accessor :tax_rate_name, :from => "TaxRateName"
|
7
|
+
xml_accessor :rate_value, :from => "RateValue"
|
8
|
+
xml_accessor :tax_agency_id, :from => "TaxAgencyId"
|
9
|
+
xml_accessor :tax_applicable_on, :from => 'TaxApplicableOn', :as => :text
|
10
|
+
|
11
|
+
validates :tax_rate_name, presence: true, length: { maximum: 100 }, if: Proc.new {|line| line.tax_rate_id.blank?}
|
12
|
+
validates :tax_agency_id, presence: true, numericality: {greater_than: 0}, if: Proc.new {|line| line.tax_rate_id.blank?}
|
13
|
+
validates :rate_value, presence: true, numericality: {less_than_or_equal_to: 100}, if: Proc.new {|line| line.tax_rate_id.blank?}
|
14
|
+
validates :tax_rate_id, numericality: true, if: Proc.new {|line| line.tax_rate_name.blank? && tax_agency_id.blank? && rate_value.blank? }
|
15
|
+
|
16
|
+
validates :tax_applicable_on, inclusion: {in: %w(Sales Purchase)}
|
17
|
+
|
18
|
+
def to_json
|
19
|
+
attributes.inject({}){|mem, item| mem[item.first.camelize] = item.last if item.last.present?; mem}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TaxService < BaseModelJSON
|
4
|
+
REST_RESOURCE = "taxservice/taxcode"
|
5
|
+
|
6
|
+
xml_accessor :tax_code_id, :from => "TaxCodeId"
|
7
|
+
xml_accessor :tax_code, :from => "TaxCode"
|
8
|
+
xml_accessor :tax_rate_details, :from => 'TaxRateDetails', :as => [TaxRateDetailLine]
|
9
|
+
|
10
|
+
validates :tax_code, presence: true, length: { maximum: 100 }
|
11
|
+
|
12
|
+
validate :check_details_item
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
self.tax_rate_details = options['tax_rate_details'] || []
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.from_json(response)
|
20
|
+
result = JSON.parse(response)
|
21
|
+
if result.present?
|
22
|
+
ts = Quickbooks::Model::TaxService.new
|
23
|
+
ts.tax_code = result['TaxCode']
|
24
|
+
ts.tax_code_id = result['TaxCodeId']
|
25
|
+
result['TaxRateDetails'].each do |item|
|
26
|
+
attrs = item.keys.inject({}){|mem, k| mem[k.underscore] = item[k]; mem}
|
27
|
+
ts.tax_rate_details << Quickbooks::Model::TaxRateDetailLine.new(attrs)
|
28
|
+
end
|
29
|
+
return ts
|
30
|
+
else
|
31
|
+
return nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_details_item
|
36
|
+
if tax_rate_details.blank?
|
37
|
+
errors.add(:tax_rate_details, "must have at least one item")
|
38
|
+
else
|
39
|
+
tax_rate_details.each do |line|
|
40
|
+
unless line.valid?
|
41
|
+
errors.add(:base, line.errors.full_messages.join(', '))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
names = tax_rate_details.map(&:tax_rate_name).uniq
|
45
|
+
if names.size < tax_rate_details.size
|
46
|
+
errors.add(:tax_rate_name, "Duplicate Tax Rate Name")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class Term < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "Term"
|
5
|
+
XML_NODE = "Term"
|
6
|
+
REST_RESOURCE = 'term'
|
7
|
+
|
8
|
+
xml_accessor :id, :from => 'Id'
|
9
|
+
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
11
|
+
xml_accessor :name, :from => 'Name'
|
12
|
+
xml_accessor :active?, :from => 'Active'
|
13
|
+
xml_accessor :type, :from => 'Type'
|
14
|
+
xml_accessor :discount_percent, :from => 'DiscountPercent', :as => BigDecimal
|
15
|
+
xml_accessor :due_days, :from => 'DueDays', :as => Integer
|
16
|
+
xml_accessor :discount_days, :from => 'DiscountDays', :as => Integer
|
17
|
+
xml_accessor :day_of_month_due, :from => 'DayOfMonthDue', :as => Integer
|
18
|
+
xml_accessor :due_next_month_days, :from => 'DueNextMonthDays', :as => Integer
|
19
|
+
xml_accessor :discount_day_of_month, :from => 'DiscountDayOfMonth', :as => Integer
|
20
|
+
xml_accessor :attachable_ref, :from => 'AttachableRef', :as => BaseReference
|
21
|
+
|
22
|
+
validates_presence_of :name
|
23
|
+
|
24
|
+
reference_setters :attachable_ref
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TimeActivity < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "TimeActivity"
|
5
|
+
XML_NODE = "TimeActivity"
|
6
|
+
REST_RESOURCE = 'timeactivity'
|
7
|
+
|
8
|
+
NAMEOF_OPTIONS = %w( Employee Vendor )
|
9
|
+
|
10
|
+
xml_name XML_NODE
|
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
|
+
|
16
|
+
xml_accessor :txn_date, :from => 'TxnDate'
|
17
|
+
xml_accessor :name_of, :from => 'NameOf'
|
18
|
+
|
19
|
+
xml_accessor :employee_ref, :from => 'EmployeeRef', :as => BaseReference
|
20
|
+
xml_accessor :vendor_ref, :from => 'VendorRef', :as => BaseReference
|
21
|
+
xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
|
22
|
+
xml_accessor :item_ref, :from => 'ItemRef', :as => BaseReference
|
23
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
24
|
+
|
25
|
+
xml_accessor :billable_status, :from => 'BillableStatus'
|
26
|
+
xml_accessor :taxable, :from => 'Taxable'
|
27
|
+
xml_accessor :hourly_rate, :from => 'HourlyRate'
|
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
|
32
|
+
xml_accessor :description, :from => 'Description'
|
33
|
+
|
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
|
43
|
+
validates_inclusion_of :name_of, :in => NAMEOF_OPTIONS
|
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
|
+
validates :description, length: { maximum: 4000 }
|
47
|
+
|
48
|
+
def existence_of_employee_ref
|
49
|
+
if employee_ref.nil? || (employee_ref && employee_ref.value == 0)
|
50
|
+
errors.add(:employee_ref, "EmployeeRef is required and must be a non-zero value.")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def existence_of_vendor_ref
|
55
|
+
if vendor_ref.nil? || (vendor_ref && vendor_ref.value == 0)
|
56
|
+
errors.add(:vendor_ref, "VendorRef is required and must be a non-zero value.")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def valid_for_update?
|
61
|
+
if sync_token.nil?
|
62
|
+
errors.add(:sync_token, "Missing required attribute SyncToken for update")
|
63
|
+
end
|
64
|
+
errors.empty?
|
65
|
+
end
|
66
|
+
|
67
|
+
def valid_for_create?
|
68
|
+
valid?
|
69
|
+
errors.empty?
|
70
|
+
end
|
71
|
+
|
72
|
+
def valid_for_deletion?
|
73
|
+
return false if(id.nil? || sync_token.nil?)
|
74
|
+
id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class TransactionTaxDetail < BaseModel
|
4
|
+
|
5
|
+
xml_accessor :txn_tax_code_ref, :from => 'TxnTaxCodeRef', :as => BaseReference
|
6
|
+
xml_accessor :total_tax, :from => 'TotalTax', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
7
|
+
xml_accessor :lines, :from => 'TaxLine', :as => [TaxLine]
|
8
|
+
|
9
|
+
reference_setters :txn_tax_code_ref
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class Transfer < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "Transfer"
|
5
|
+
XML_NODE = "Transfer"
|
6
|
+
REST_RESOURCE = 'transfer'
|
7
|
+
|
8
|
+
xml_accessor :id, :from => 'Id'
|
9
|
+
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
11
|
+
xml_accessor :txn_date, :from => 'TxnDate', :as => Date
|
12
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
13
|
+
xml_accessor :private_note, :from => 'PrivateNote'
|
14
|
+
xml_accessor :from_account_ref, :from => 'FromAccountRef', :as => BaseReference
|
15
|
+
xml_accessor :to_account_ref, :from => 'ToAccountRef', :as => BaseReference
|
16
|
+
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
17
|
+
|
18
|
+
reference_setters :currency_ref, :to_account_ref, :from_account_ref
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class Upload < BaseModel
|
4
|
+
xml_convention :camelcase
|
5
|
+
|
6
|
+
#xml_accessor :attache, :as => Attachable
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
=begin
|
13
|
+
|
14
|
+
Response XML:
|
15
|
+
|
16
|
+
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-08-18T09:58:04.583-07:00">
|
17
|
+
<AttachableResponse>
|
18
|
+
<Attachable domain="QBO" sparse="false">
|
19
|
+
<Id>2700000000001439108</Id>
|
20
|
+
<SyncToken>0</SyncToken>
|
21
|
+
<MetaData>
|
22
|
+
<CreateTime>2014-08-18T09:58:06-07:00</CreateTime>
|
23
|
+
<LastUpdatedTime>2014-08-18T09:58:06-07:00</LastUpdatedTime>
|
24
|
+
</MetaData>
|
25
|
+
<FileName>monkey.jpg</FileName>
|
26
|
+
<FileAccessUri>/v3/company/1002341430/download/2700000000001439108</FileAccessUri>
|
27
|
+
<TempDownloadUri>https://intuit-qbo-prod-30.s3.amazonaws.com/1002341430%2Fattachments%2Fmonkey.jpg?Expires=1408381986&AWSAccessKeyId=AKIAJEXDXKNYCBUNCCCQ&Signature=WOVACYm6zi1rM5EGZRq3d3AMSM0%3D</TempDownloadUri>
|
28
|
+
<Size>105840</Size>
|
29
|
+
<ContentType>image/jpeg</ContentType>
|
30
|
+
<ThumbnailFileAccessUri>/v3/company/1002341430/attachable-thumbnail/2700000000001439108</ThumbnailFileAccessUri>
|
31
|
+
</Attachable>
|
32
|
+
</AttachableResponse>
|
33
|
+
</IntuitResponse>
|
34
|
+
|
35
|
+
=end
|
@@ -0,0 +1,53 @@
|
|
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
|
+
# * Either the DisplayName attribute or at least one of Title, GivenName, MiddleName, FamilyName, Suffix, or FullyQualifiedName attributes are required during create.
|
6
|
+
|
7
|
+
module Quickbooks
|
8
|
+
module Model
|
9
|
+
class Vendor < BaseModel
|
10
|
+
XML_COLLECTION_NODE = "Vendor"
|
11
|
+
XML_NODE = "Vendor"
|
12
|
+
REST_RESOURCE = 'vendor'
|
13
|
+
include NameEntity::Quality
|
14
|
+
include NameEntity::PermitAlterations
|
15
|
+
|
16
|
+
xml_name XML_NODE
|
17
|
+
xml_accessor :id, :from => 'Id'
|
18
|
+
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
19
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
20
|
+
xml_accessor :attachable_ref, :from => 'AttachableRef', :as => BaseReference
|
21
|
+
xml_accessor :title, :from => 'Title'
|
22
|
+
xml_accessor :given_name, :from => 'GivenName'
|
23
|
+
xml_accessor :middle_name, :from => 'MiddleName'
|
24
|
+
xml_accessor :family_name, :from => 'FamilyName'
|
25
|
+
xml_accessor :suffix, :from => 'Suffix'
|
26
|
+
xml_accessor :company_name, :from => 'CompanyName'
|
27
|
+
xml_accessor :display_name, :from => 'DisplayName'
|
28
|
+
xml_accessor :print_on_check_name, :from => 'PrintOnCheckName'
|
29
|
+
xml_accessor :active?, :from => 'Active'
|
30
|
+
xml_accessor :primary_phone, :from => 'PrimaryPhone', :as => TelephoneNumber
|
31
|
+
xml_accessor :alternate_phone, :from => 'AlternatePhone', :as => TelephoneNumber
|
32
|
+
xml_accessor :mobile_phone, :from => 'Mobile', :as => TelephoneNumber
|
33
|
+
xml_accessor :fax_phone, :from => 'Fax', :as => TelephoneNumber
|
34
|
+
xml_accessor :primary_email_address, :from => 'PrimaryEmailAddr', :as => EmailAddress
|
35
|
+
xml_accessor :web_site, :from => 'WebAddr', :as => WebSiteAddress
|
36
|
+
xml_accessor :billing_address, :from => 'BillAddr', :as => PhysicalAddress
|
37
|
+
xml_accessor :other_contact_info, :from => 'OtherContactInfo', :as => OtherContactInfo
|
38
|
+
xml_accessor :tax_identifier, :from => 'TaxIdentifier'
|
39
|
+
xml_accessor :term_ref, :from => 'TermRef', :as => BaseReference
|
40
|
+
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
41
|
+
xml_accessor :account_number, :from => 'AcctNum'
|
42
|
+
xml_accessor :is_1099?, :from => 'Vendor1099'
|
43
|
+
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
44
|
+
|
45
|
+
#== Validations
|
46
|
+
validate :names_cannot_contain_invalid_characters
|
47
|
+
validate :email_address_is_valid
|
48
|
+
|
49
|
+
reference_setters
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|