quickbooks-ruby 0.0.2 → 0.0.3

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/{quickbooks.rb → quickbooks-ruby.rb} +26 -4
  3. data/lib/quickbooks/model/account.rb +91 -0
  4. data/lib/quickbooks/model/account_based_expense_line_detail.rb +15 -0
  5. data/lib/quickbooks/model/base_model.rb +21 -0
  6. data/lib/quickbooks/model/{customer_ref.rb → base_reference.rb} +1 -1
  7. data/lib/quickbooks/model/bill.rb +36 -0
  8. data/lib/quickbooks/model/bill_line_item.rb +23 -0
  9. data/lib/quickbooks/model/bill_payment.rb +34 -0
  10. data/lib/quickbooks/model/bill_payment_check.rb +12 -0
  11. data/lib/quickbooks/model/bill_payment_credit_card.rb +10 -0
  12. data/lib/quickbooks/model/bill_payment_line_item.rb +21 -0
  13. data/lib/quickbooks/model/check_payment.rb +11 -0
  14. data/lib/quickbooks/model/credit_card_payment.rb +17 -0
  15. data/lib/quickbooks/model/credit_memo.rb +38 -0
  16. data/lib/quickbooks/model/customer.rb +18 -15
  17. data/lib/quickbooks/model/discount_override.rb +5 -3
  18. data/lib/quickbooks/model/invoice.rb +41 -19
  19. data/lib/quickbooks/model/invoice_line_item.rb +6 -6
  20. data/lib/quickbooks/model/item.rb +24 -17
  21. data/lib/quickbooks/model/line.rb +28 -0
  22. data/lib/quickbooks/model/payment_line_detail.rb +6 -4
  23. data/lib/quickbooks/model/payment_method.rb +14 -0
  24. data/lib/quickbooks/model/physical_address.rb +18 -2
  25. data/lib/quickbooks/model/sales_item_line_detail.rb +9 -7
  26. data/lib/quickbooks/model/sales_receipt.rb +44 -0
  27. data/lib/quickbooks/model/sub_total_line_detail.rb +7 -5
  28. data/lib/quickbooks/service/account.rb +22 -0
  29. data/lib/quickbooks/service/base_service.rb +45 -60
  30. data/lib/quickbooks/service/bill.rb +15 -0
  31. data/lib/quickbooks/service/bill_payment.rb +15 -0
  32. data/lib/quickbooks/service/credit_memo.rb +15 -0
  33. data/lib/quickbooks/service/payment_method.rb +23 -0
  34. data/lib/quickbooks/service/sales_receipt.rb +15 -0
  35. data/lib/quickbooks/service/service_crud.rb +4 -8
  36. data/lib/quickbooks/util/class_util.rb +14 -0
  37. data/lib/quickbooks/{http_encoding_helper.rb → util/http_encoding_helper.rb} +16 -11
  38. data/lib/quickbooks/version.rb +1 -1
  39. metadata +26 -6
  40. data/lib/quickbooks/model/invoice_item_ref.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff8e60580cbdc70768e250a4adf0eb56f8a2738b
4
- data.tar.gz: e895d50078ed86a143b9efa9d8607daa2bcb39be
3
+ metadata.gz: 2551f351313de20062141ecefecb34d978593a27
4
+ data.tar.gz: 812f7319325c66eea93175963e5dfcc90a27c10d
5
5
  SHA512:
6
- metadata.gz: ce775c53ea29e7d9b090311b0aa63d4cf110b09d4b87e3e291c99e1494de249e30b79bfd58e3a9d43b0c7ccc3e7ccdd926e6a596e5a2298968fe5d996dda188b
7
- data.tar.gz: 1898cbab1fe4a946d83cf37cc3dd843fd89d95f8af3d5554872ee059fa2b6354aa043bb01ffdd36925c2d5f981f7b75d4e4555d3583f9c626479d0100c6d3d27
6
+ metadata.gz: cee4a16a48605113b8abf11127a6acb09463ce13e0cfa1bd2fa28d8195f658cce2944b534dd0a08cc96584199d45b14408e37c932062e4ff676203e373d50821
7
+ data.tar.gz: c10ccc62ea309b00eb521b459738b51a16834031a13f57021e4b32a4bfb04aca2974b15ea394f556c4642fd448eec91556fce84e807545f71332d75cb044a143
@@ -8,19 +8,24 @@ require 'date'
8
8
  require 'forwardable'
9
9
  require 'oauth'
10
10
  require 'quickbooks/util/logging'
11
+ require 'quickbooks/util/class_util'
12
+ require 'quickbooks/util/http_encoding_helper'
11
13
 
12
14
  #== Models
13
15
  require 'quickbooks/model/base_model'
16
+ require 'quickbooks/model/base_reference'
14
17
  require 'quickbooks/model/meta_data'
15
18
  require 'quickbooks/model/custom_field'
16
- require 'quickbooks/model/invoice_item_ref'
17
19
  require 'quickbooks/model/sales_item_line_detail'
18
20
  require 'quickbooks/model/sub_total_line_detail'
19
- require 'quickbooks/model/customer_ref'
20
21
  require 'quickbooks/model/discount_override'
21
22
  require 'quickbooks/model/payment_line_detail'
23
+ require 'quickbooks/model/account_based_expense_line_detail'
24
+ require 'quickbooks/model/line'
22
25
  require 'quickbooks/model/item'
23
-
26
+ require 'quickbooks/model/account'
27
+ require 'quickbooks/model/check_payment'
28
+ require 'quickbooks/model/credit_card_payment'
24
29
 
25
30
  require 'quickbooks/model/telephone_number'
26
31
  require 'quickbooks/model/email_address'
@@ -30,6 +35,15 @@ require 'quickbooks/model/linked_transaction'
30
35
  require 'quickbooks/model/invoice_line_item'
31
36
  require 'quickbooks/model/invoice'
32
37
  require 'quickbooks/model/customer'
38
+ require 'quickbooks/model/sales_receipt'
39
+ require 'quickbooks/model/payment_method'
40
+ require 'quickbooks/model/credit_memo'
41
+ require 'quickbooks/model/bill_line_item'
42
+ require 'quickbooks/model/bill'
43
+ require 'quickbooks/model/bill_payment_line_item'
44
+ require 'quickbooks/model/bill_payment_check'
45
+ require 'quickbooks/model/bill_payment_credit_card'
46
+ require 'quickbooks/model/bill_payment'
33
47
 
34
48
  #== Services
35
49
  require 'quickbooks/service/base_service'
@@ -37,8 +51,16 @@ require 'quickbooks/service/service_crud'
37
51
  require 'quickbooks/service/customer'
38
52
  require 'quickbooks/service/invoice'
39
53
  require 'quickbooks/service/item'
54
+ require 'quickbooks/service/sales_receipt'
55
+ require 'quickbooks/service/account'
56
+ require 'quickbooks/service/payment_method'
57
+ require 'quickbooks/service/credit_memo'
58
+ require 'quickbooks/service/bill'
59
+ require 'quickbooks/service/bill_payment'
40
60
 
41
- class InvalidModelException < StandardError; end
61
+ unless Quickbooks::Util::ClassUtil.defined?("InvalidModelException")
62
+ class InvalidModelException < StandardError; end
63
+ end
42
64
 
43
65
  module Quickbooks
44
66
  @@logger = nil
@@ -0,0 +1,91 @@
1
+ module Quickbooks
2
+ module Model
3
+ class Account < BaseModel
4
+ XML_COLLECTION_NODE = "Account"
5
+ XML_NODE = "Account"
6
+ REST_RESOURCE = 'account'
7
+
8
+ ASSET = 'Asset'
9
+ EQUITY = 'Equity'
10
+ EXPENSE = 'Expense'
11
+ LIABILITY = 'Liability'
12
+ REVENUE = 'Revenue'
13
+
14
+ ACCOUNT_CLASSIFICATION = [ASSET, EQUITY, EXPENSE, LIABILITY, REVENUE]
15
+
16
+ xml_name XML_NODE
17
+
18
+ xml_accessor :id, :from => 'Id', :as => Integer
19
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
20
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
21
+ xml_accessor :has_attachment, :from => 'HasAttachment'
22
+ xml_accessor :name, :from => 'Name'
23
+ xml_accessor :description, :from => 'Description'
24
+
25
+ xml_accessor :sub_account, :from => 'SubAccount'
26
+ xml_accessor :parent_ref, :from => 'ParentRef', :as => BaseReference
27
+
28
+ xml_accessor :active, :from => 'Active'
29
+
30
+ xml_accessor :classification, :from => 'Classification'
31
+ xml_accessor :account_type, :from => 'AccountType'
32
+ xml_accessor :account_sub_type, :from => 'AccountSubType'
33
+
34
+ xml_accessor :acct_num, :from => 'AcctNum'
35
+ xml_accessor :bank_num, :from => 'BankNum'
36
+
37
+ xml_accessor :opening_balance, :from => 'OpeningBalance', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
38
+ xml_accessor :opening_balance_date, :from => 'OpeningBalanceDate', :as => DateTime
39
+ xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
40
+ xml_accessor :tax_account, :from => 'TaxAccount'
41
+ xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
42
+
43
+ reference_setters :parent_ref, :currency_ref, :tax_code_ref
44
+
45
+ #== Validations
46
+ validates_inclusion_of :classification, :in => ACCOUNT_CLASSIFICATION
47
+ validates_length_of :name, :minimum => 1, :maximum => 100
48
+ validates_length_of :description, :minimum => 1, :maximum => 100
49
+ validate :name_cannot_contain_invalid_characters
50
+
51
+ def name_cannot_contain_invalid_characters
52
+ if name && (name.index(':') || name.index('"'))
53
+ errors.add('name', ":#{name} cannot contain a colon (:) or double quotes (\").")
54
+ end
55
+ end
56
+
57
+ def valid_for_update?
58
+ if sync_token.nil?
59
+ errors.add(:sync_token, "Missing required attribute SyncToken for update")
60
+ end
61
+ errors.empty?
62
+ end
63
+
64
+ def valid_for_create?
65
+ valid?
66
+ errors.empty?
67
+ end
68
+
69
+ def valid_for_deletion?
70
+ return false if(id.nil? || sync_token.nil?)
71
+ id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
72
+ end
73
+
74
+ def has_attachment?
75
+ has_attachment.to_s == 'true'
76
+ end
77
+
78
+ def sub_account?
79
+ sub_account.to_s == 'true'
80
+ end
81
+
82
+ def active?
83
+ active.to_s == 'true'
84
+ end
85
+
86
+ def tax_account?
87
+ tax_account.to_s == 'true'
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,15 @@
1
+ module Quickbooks
2
+ module Model
3
+ class AccountBasedExpenseLineDetail < BaseModel
4
+ xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
5
+ xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
6
+ xml_accessor :account_ref, :from => 'AccountRef', :as => BaseReference
7
+ xml_accessor :billable_status, :from => 'BillableStatus'
8
+ xml_accessor :tax_amount, :from => 'UnitPrice', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
9
+ xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
10
+
11
+ reference_setters :customer_ref, :class_ref, :account_ref, :tax_code_ref
12
+
13
+ end
14
+ end
15
+ end
@@ -35,6 +35,27 @@ module Quickbooks
35
35
  self::REST_RESOURCE
36
36
  end
37
37
 
38
+ # Automatically generate an ID setter.
39
+ # Example:
40
+ # reference_setters :discount_ref
41
+ # Would generate a method like:
42
+ # def discount_id=(id)
43
+ # self.discount_ref = BaseReference.new(id)
44
+ # end
45
+ def reference_setters(*args)
46
+ args.each do |attribute|
47
+ method_name = "#{attribute.to_s.gsub('_ref', '_id')}=".to_sym
48
+ unless instance_methods(false).include?(method_name)
49
+ method_definition = <<-METH
50
+ def #{method_name}(id)
51
+ self.#{attribute} = BaseReference.new(id)
52
+ end
53
+ METH
54
+ class_eval(method_definition)
55
+ end
56
+ end
57
+ end
58
+
38
59
  end
39
60
  end
40
61
  end
@@ -1,6 +1,6 @@
1
1
  module Quickbooks
2
2
  module Model
3
- class CustomerRef < BaseModel
3
+ class BaseReference < BaseModel
4
4
  xml_convention :camelcase
5
5
  xml_accessor :name, :from => '@name' # Attribute with name 'name'
6
6
  xml_accessor :value, :from => :content
@@ -0,0 +1,36 @@
1
+ module Quickbooks
2
+ module Model
3
+ class Bill < BaseModel
4
+ XML_COLLECTION_NODE = "Bill"
5
+ XML_NODE = "Bill"
6
+ REST_RESOURCE = 'bill'
7
+
8
+ xml_accessor :id, :from => 'Id', :as => Integer
9
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
10
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
11
+ xml_accessor :doc_number, :from => 'DocNumber'
12
+ xml_accessor :txn_date, :from => 'TxnDate', :as => Date
13
+
14
+ xml_accessor :line_items, :from => 'Line', :as => [BillLineItem]
15
+
16
+ xml_accessor :private_note, :from => 'PrivateNote'
17
+
18
+ xml_accessor :vendor_ref, :from => 'VendorRef', :as => BaseReference
19
+ xml_accessor :payer_ref, :from => 'PayerRef', :as => BaseReference
20
+ xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
21
+
22
+ xml_accessor :due_date, :from => 'DueDate', :as => Date
23
+ xml_accessor :remit_to_address, :from => 'RemitToAddr', :as => PhysicalAddress
24
+ xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
25
+
26
+ # readonly
27
+ xml_accessor :bill_email, :from => 'BillEmail', :as => EmailAddress
28
+ xml_accessor :reply_email, :from => 'ReplyEmail', :as => EmailAddress
29
+ xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
30
+
31
+ validates_length_of :line_items, :minimum => 1
32
+
33
+ reference_setters :vendor_ref, :payer_ref, :sales_term_ref
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ module Quickbooks
2
+ module Model
3
+ class BillLineItem < BaseModel
4
+
5
+ #== Constants
6
+ ACCOUNT_BASED_EXPENSE_LINE_DETAIL = 'AccountBasedExpenseLineDetail'
7
+
8
+ xml_accessor :id, :from => 'Id', :as => Integer
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 => Proc.new { |val| val.to_f }
12
+ xml_accessor :detail_type, :from => 'DetailType'
13
+
14
+ #== Various detail types
15
+ xml_accessor :account_based_expense_line_detail, :from => 'AccountBasedExpenseLineDetail', :as => AccountBasedExpenseLineDetail
16
+
17
+ def account_based_expense_item?
18
+ detail_type.to_s == ACCOUNT_BASED_EXPENSE_LINE_DETAIL
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,34 @@
1
+ module Quickbooks
2
+ module Model
3
+ class BillPayment < BaseModel
4
+ XML_COLLECTION_NODE = "BillPayment"
5
+ XML_NODE = "BillPayment"
6
+ REST_RESOURCE = 'bill_payment'
7
+
8
+ xml_accessor :id, :from => 'Id', :as => Integer
9
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
10
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
11
+ xml_accessor :doc_number, :from => 'DocNumber'
12
+ xml_accessor :txn_date, :from => 'TxnDate', :as => Date
13
+
14
+ xml_accessor :line_items, :from => 'Line', :as => [BillPaymentLineItem]
15
+
16
+ xml_accessor :private_note, :from => 'PrivateNote'
17
+
18
+ xml_accessor :vendor_ref, :from => 'VendorRef', :as => BaseReference
19
+ xml_accessor :pay_type, :from => 'PayType'
20
+
21
+ ## Required if PayType is Check.
22
+ xml_accessor :check_payment, :from => 'CheckPayment', :as => BillPaymentCheck
23
+ ## Required if PayType is CreditCard.
24
+ xml_accessor :credit_card_payment, :from => 'CreditCardPayment', :as => BillPaymentCreditCard
25
+
26
+ # readonly
27
+ xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
28
+
29
+ validates_length_of :line_items, :minimum => 1
30
+
31
+ reference_setters :vendor_ref
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,12 @@
1
+ module Quickbooks
2
+ module Model
3
+ class BillPaymentCheck < BaseModel
4
+ xml_accessor :bank_account_ref, :from => 'BankAccountRef', :as => BaseReference
5
+ xml_accessor :print_status, :from => 'PrintStatus'
6
+ xml_accessor :check_detail, :from => 'CheckDetail', :as => CheckPayment
7
+ xml_accessor :payee_address, :from => 'PayeeAddr', :as => PhysicalAddress
8
+
9
+ reference_setters :bank_account_ref
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module Quickbooks
2
+ module Model
3
+ class BillPaymentCreditCard < BaseModel
4
+ xml_accessor :cc_account_ref, :from => 'CCAccountRef', :as => BaseReference
5
+ xml_accessor :cc_detail, :from => 'CCDetail', :as => CreditCardPayment
6
+
7
+ reference_setters :cc_account_ref
8
+ end
9
+ end
10
+ end
@@ -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', :as => Integer
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 => Proc.new { |val| val.to_f }
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,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,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,38 @@
1
+ module Quickbooks
2
+ module Model
3
+ class CreditMemo < BaseModel
4
+ XML_COLLECTION_NODE = "CreditMemo"
5
+ XML_NODE = "CreditMemo"
6
+ REST_RESOURCE = 'creditmemo'
7
+
8
+ xml_accessor :id, :from => 'Id', :as => Integer
9
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
10
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
11
+ xml_accessor :doc_number, :from => 'DocNumber'
12
+ xml_accessor :placed_on, :from => 'TxnDate', :as => Time
13
+
14
+ xml_accessor :line_items, :from => 'Line', :as => [Line]
15
+
16
+ xml_accessor :private_note, :from => 'PrivateNote'
17
+
18
+ xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
19
+ xml_accessor :customer_memo, :from => 'CustomerMemo'
20
+ xml_accessor :bill_email, :from => 'BillEmail', :as => EmailAddress
21
+ xml_accessor :bill_address, :from => 'BillAddr', :as => PhysicalAddress
22
+ xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
23
+ xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
24
+ xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
25
+
26
+ # readonly
27
+ xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal
28
+
29
+ validates_length_of :line_items, :minimum => 1
30
+
31
+ reference_setters :customer_ref, :sales_term_ref, :deposit_to_account_ref, :payment_method_ref
32
+
33
+ def email=(email)
34
+ self.bill_email = EmailAddress.new(email)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -17,7 +17,7 @@ module Quickbooks
17
17
  xml_name XML_NODE
18
18
  xml_accessor :id, :from => 'Id', :as => Integer
19
19
  xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
20
- xml_accessor :meta_data, :from => 'MetaData', :as => Quickbooks::Model::MetaData
20
+ xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
21
21
  xml_accessor :title, :from => 'Title'
22
22
  xml_accessor :given_name, :from => 'GivenName'
23
23
  xml_accessor :middle_name, :from => 'MiddleName'
@@ -26,23 +26,23 @@ module Quickbooks
26
26
  xml_accessor :display_name, :from => 'DisplayName'
27
27
  xml_accessor :print_on_check_name, :from => 'PrintOnCheckName'
28
28
  xml_accessor :active, :from => 'Active'
29
- xml_accessor :primary_phone, :from => 'PrimaryPhone', :as => Quickbooks::Model::TelephoneNumber
30
- xml_accessor :alternate_phone, :from => 'AlternatePhone', :as => Quickbooks::Model::TelephoneNumber
31
- xml_accessor :mobile_phone, :from => 'Mobile', :as => Quickbooks::Model::TelephoneNumber
32
- xml_accessor :fax_phone, :from => 'Fax', :as => Quickbooks::Model::TelephoneNumber
33
- xml_accessor :primary_email_address, :from => 'PrimaryEmailAddr', :as => Quickbooks::Model::EmailAddress
34
- xml_accessor :web_site, :from => 'WebAddr', :as => Quickbooks::Model::WebSiteAddress
35
- xml_accessor :billing_address, :from => 'BillAddr', :as => Quickbooks::Model::PhysicalAddress
36
- xml_accessor :shipping_address, :from => 'ShipAddr', :as => Quickbooks::Model::PhysicalAddress
29
+ xml_accessor :primary_phone, :from => 'PrimaryPhone', :as => TelephoneNumber
30
+ xml_accessor :alternate_phone, :from => 'AlternatePhone', :as => TelephoneNumber
31
+ xml_accessor :mobile_phone, :from => 'Mobile', :as => TelephoneNumber
32
+ xml_accessor :fax_phone, :from => 'Fax', :as => TelephoneNumber
33
+ xml_accessor :primary_email_address, :from => 'PrimaryEmailAddr', :as => EmailAddress
34
+ xml_accessor :web_site, :from => 'WebAddr', :as => WebSiteAddress
35
+ xml_accessor :billing_address, :from => 'BillAddr', :as => PhysicalAddress
36
+ xml_accessor :shipping_address, :from => 'ShipAddr', :as => PhysicalAddress
37
37
  xml_accessor :job, :from => 'Job'
38
38
  xml_accessor :bill_with_parent, :from => 'BillWithParent'
39
- xml_accessor :parent_ref, :from => 'ParentRef', :as => Integer
39
+ xml_accessor :parent_ref, :from => 'ParentRef', :as => BaseReference
40
40
  xml_accessor :level, :from => 'Level'
41
- xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => Integer
42
- xml_accessor :payment_method_ref, :from => 'PaymentMethodRef'
43
- xml_accessor :balance, :from => 'Balance', :as => Float
41
+ xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
42
+ xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
43
+ xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
44
44
  xml_accessor :open_balance_date, :from => 'OpenBalanceDate', :as => Date
45
- xml_accessor :balance_with_jobs, :from => 'BalanceWithJobs', :as => Float
45
+ xml_accessor :balance_with_jobs, :from => 'BalanceWithJobs', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
46
46
  xml_accessor :preferred_delivery_method, :from => 'PreferredDeliveryMethod'
47
47
  xml_accessor :resale_num, :from => 'ResaleNum'
48
48
  xml_accessor :suffix, :from => 'Suffix'
@@ -50,9 +50,12 @@ module Quickbooks
50
50
  xml_accessor :taxable, :from => 'Taxable'
51
51
  xml_accessor :notes, :from => 'Notes'
52
52
 
53
+ #== Validations
53
54
  validate :names_cannot_contain_invalid_characters
54
55
  validate :email_address_is_valid
55
56
 
57
+ reference_setters :parent_ref, :sales_term_ref, :payment_method_ref
58
+
56
59
  def active?
57
60
  active.to_s == 'true'
58
61
  end
@@ -82,7 +85,7 @@ module Quickbooks
82
85
  end
83
86
 
84
87
  def email_address=(email_address)
85
- self.primary_email_address = Quickbooks::Model::EmailAddress.new(email_address)
88
+ self.primary_email_address = EmailAddress.new(email_address)
86
89
  end
87
90
 
88
91
  def email_address