quickbooks-ruby 0.4.0 → 1.0.16

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 (72) hide show
  1. checksums.yaml +5 -5
  2. data/lib/quickbooks-ruby.rb +65 -13
  3. data/lib/quickbooks/faraday/middleware/gzip.rb +74 -0
  4. data/lib/quickbooks/model/base_model.rb +13 -2
  5. data/lib/quickbooks/model/batch_request.rb +11 -6
  6. data/lib/quickbooks/model/batch_response.rb +11 -6
  7. data/lib/quickbooks/model/bill.rb +3 -0
  8. data/lib/quickbooks/model/change_data_capture.rb +50 -0
  9. data/lib/quickbooks/model/company_currency.rb +19 -0
  10. data/lib/quickbooks/model/company_info.rb +2 -1
  11. data/lib/quickbooks/model/custom_field.rb +18 -0
  12. data/lib/quickbooks/model/customer.rb +6 -1
  13. data/lib/quickbooks/model/customer_type.rb +15 -0
  14. data/lib/quickbooks/model/deposit_line_detail.rb +2 -2
  15. data/lib/quickbooks/model/description_line_detail.rb +7 -0
  16. data/lib/quickbooks/model/effective_tax_rate.rb +15 -0
  17. data/lib/quickbooks/model/exchange_rate.rb +23 -0
  18. data/lib/quickbooks/model/group_line_detail.rb +2 -1
  19. data/lib/quickbooks/model/invoice.rb +7 -1
  20. data/lib/quickbooks/model/invoice_change.rb +2 -1
  21. data/lib/quickbooks/model/invoice_group_line_detail.rb +14 -0
  22. data/lib/quickbooks/model/invoice_line_item.rb +34 -4
  23. data/lib/quickbooks/model/item.rb +11 -3
  24. data/lib/quickbooks/model/item_group_detail.rb +9 -0
  25. data/lib/quickbooks/model/item_group_line.rb +20 -0
  26. data/lib/quickbooks/model/line.rb +12 -0
  27. data/lib/quickbooks/model/line_ex.rb +9 -0
  28. data/lib/quickbooks/model/linked_transaction.rb +7 -0
  29. data/lib/quickbooks/model/physical_address.rb +2 -2
  30. data/lib/quickbooks/model/preferences.rb +28 -4
  31. data/lib/quickbooks/model/purchase_change.rb +7 -0
  32. data/lib/quickbooks/model/purchase_line_item.rb +1 -0
  33. data/lib/quickbooks/model/purchase_order.rb +3 -1
  34. data/lib/quickbooks/model/refund_receipt_change.rb +8 -0
  35. data/lib/quickbooks/model/report.rb +9 -7
  36. data/lib/quickbooks/model/sales_receipt.rb +4 -2
  37. data/lib/quickbooks/model/tax_rate.rb +1 -1
  38. data/lib/quickbooks/model/time_activity.rb +2 -1
  39. data/lib/quickbooks/model/transfer.rb +21 -0
  40. data/lib/quickbooks/model/vendor.rb +1 -0
  41. data/lib/quickbooks/service/access_token.rb +12 -11
  42. data/lib/quickbooks/service/base_service.rb +148 -24
  43. data/lib/quickbooks/service/batch.rb +1 -1
  44. data/lib/quickbooks/service/change_data_capture.rb +24 -0
  45. data/lib/quickbooks/service/company_currency.rb +18 -0
  46. data/lib/quickbooks/service/credit_memo.rb +6 -0
  47. data/lib/quickbooks/service/custom_field.rb +20 -0
  48. data/lib/quickbooks/service/customer.rb +5 -0
  49. data/lib/quickbooks/service/customer_type.rb +20 -0
  50. data/lib/quickbooks/service/estimate.rb +6 -0
  51. data/lib/quickbooks/service/exchange_rate.rb +25 -0
  52. data/lib/quickbooks/service/invoice.rb +24 -1
  53. data/lib/quickbooks/service/item.rb +5 -0
  54. data/lib/quickbooks/service/payment.rb +13 -0
  55. data/lib/quickbooks/service/preferences.rb +1 -1
  56. data/lib/quickbooks/service/purchase_change.rb +16 -0
  57. data/lib/quickbooks/service/purchase_order.rb +16 -0
  58. data/lib/quickbooks/service/refund_receipt_change.rb +16 -0
  59. data/lib/quickbooks/service/responses/methods.rb +17 -0
  60. data/lib/quickbooks/service/responses/oauth2_http_response.rb +43 -0
  61. data/lib/quickbooks/service/responses/oauth_http_response.rb +17 -0
  62. data/lib/quickbooks/service/sales_receipt.rb +30 -0
  63. data/lib/quickbooks/service/service_crud.rb +21 -0
  64. data/lib/quickbooks/service/service_crud_json.rb +1 -1
  65. data/lib/quickbooks/service/transfer.rb +16 -0
  66. data/lib/quickbooks/service/upload.rb +5 -1
  67. data/lib/quickbooks/util/logging.rb +4 -0
  68. data/lib/quickbooks/util/multipart.rb +2 -65
  69. data/lib/quickbooks/util/name_entity.rb +2 -1
  70. data/lib/quickbooks/util/query_builder.rb +6 -5
  71. data/lib/quickbooks/version.rb +1 -1
  72. metadata +73 -62
@@ -0,0 +1,19 @@
1
+ module Quickbooks
2
+ module Model
3
+ class CompanyCurrency < BaseModel
4
+ include NameEntity::PermitAlterations
5
+
6
+ XML_COLLECTION_NODE = 'CompanyCurrency'
7
+ XML_NODE = 'CompanyCurrency'
8
+ REST_RESOURCE = 'companycurrency'
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 :code, :from => 'Code'
16
+ xml_accessor :active?, :from => 'Active'
17
+ end
18
+ end
19
+ end
@@ -25,7 +25,8 @@ module Quickbooks
25
25
  xml_accessor :name_values, :from => 'NameValue', :as => [NameValue]
26
26
 
27
27
  def find_name_value(name)
28
- name_values.select { |nv| nv.name == name }.first.value
28
+ nv = name_values.find { |nv| nv.name == name }
29
+ nv ? nv.value : nil
29
30
  end
30
31
 
31
32
  def find_boolean_name_value(name)
@@ -8,6 +8,24 @@ module Quickbooks
8
8
  xml_accessor :boolean_value, :from => 'BooleanValue'
9
9
  xml_accessor :date_value, :from => 'DateValue', :as => Date
10
10
  xml_accessor :number_value, :from => 'NumberValue', :as => Integer
11
+
12
+ def value
13
+ case type
14
+ when 'BooleanType' then boolean_value == 'true'
15
+ when 'StringType' then string_value
16
+ when 'DateType' then date_value
17
+ when 'NumberType' then number_value
18
+ end
19
+ end
20
+
21
+ def value=(value)
22
+ case type
23
+ when 'BooleanType' then self.boolean_value = value ? 'true' : 'false'
24
+ when 'StringType' then self.string_value = value
25
+ when 'DateType' then self.date_value = value
26
+ when 'NumberType' then self.number_value = value
27
+ end
28
+ end
11
29
  end
12
30
  end
13
31
  end
@@ -53,12 +53,17 @@ module Quickbooks
53
53
  xml_accessor :default_tax_code_ref, :from => 'DefaultTaxCodeRef', :as => BaseReference
54
54
  xml_accessor :notes, :from => 'Notes'
55
55
  xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
56
+ xml_accessor :tax_exemption_reason_id, :from => 'TaxExemptionReasonId'
57
+ xml_accessor :primary_tax_identifier, :from => 'PrimaryTaxIdentifier'
58
+ xml_accessor :customer_type_ref, :from => 'CustomerTypeRef', :as => BaseReference
59
+ xml_accessor :isproject?, :from => 'IsProject'
56
60
 
57
61
  #== Validations
58
62
  validate :names_cannot_contain_invalid_characters
59
63
  validate :email_address_is_valid
60
64
 
61
- reference_setters :parent_ref, :sales_term_ref, :payment_method_ref, :default_tax_code_ref, :currency_ref
65
+ reference_setters :parent_ref, :sales_term_ref, :payment_method_ref, :default_tax_code_ref, :currency_ref,
66
+ :customer_type_ref
62
67
 
63
68
  def job?
64
69
  job.to_s == 'true'
@@ -0,0 +1,15 @@
1
+ module Quickbooks
2
+ module Model
3
+ class CustomerType < BaseModel
4
+ XML_COLLECTION_NODE = "CustomerType"
5
+ XML_NODE = "CustomerType"
6
+ REST_RESOURCE = 'customertype'
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
+ end
14
+ end
15
+ end
@@ -2,7 +2,7 @@ module Quickbooks
2
2
  module Model
3
3
  class DepositLineDetail < BaseModel
4
4
 
5
- xml_accessor :entity, :from => 'Entity', :as => Entity
5
+ xml_accessor :entity_ref, :from => 'Entity', :as => BaseReference
6
6
  xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
7
7
  xml_accessor :account_ref, :from => 'AccountRef', :as => BaseReference
8
8
  xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
@@ -10,7 +10,7 @@ module Quickbooks
10
10
  xml_accessor :txn_type, :from => 'TxnType'
11
11
  xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
12
12
 
13
- reference_setters :class_ref, :account_ref, :payment_method_ref
13
+ reference_setters :class_ref, :account_ref, :payment_method_ref, :entity_ref
14
14
 
15
15
  end
16
16
  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
+ require 'time'
2
+
3
+ module Quickbooks
4
+ module Model
5
+ class EffectiveTaxRate < BaseModel
6
+ XML_COLLECTION_NODE = "EffectiveTaxRate"
7
+ XML_NODE = "EffectiveTaxRate"
8
+ REST_RESOURCE = "effectivetaxrate"
9
+
10
+ xml_accessor :rate_value, :from => 'RateValue'
11
+ xml_accessor :effective_date, :from => 'EffectiveDate', :as => Time
12
+ xml_accessor :end_date, :from => 'EndDate', :as => Time
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module Quickbooks
2
+ module Model
3
+ class ExchangeRate < BaseModel
4
+ XML_COLLECTION_NODE = "ExchangeRate"
5
+ XML_NODE = "ExchangeRate"
6
+ REST_RESOURCE = "exchangerate"
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
+
12
+ xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
13
+ xml_accessor :source_currency_code, :from => 'SourceCurrencyCode'
14
+ xml_accessor :target_currency_code, :from => 'TargetCurrencyCode'
15
+ xml_accessor :rate, :from => 'Rate', :as => BigDecimal, :to_xml => to_xml_big_decimal
16
+ xml_accessor :as_of_date, :from => 'AsOfDate', :as => Date
17
+
18
+ validates_presence_of :source_currency_code, :rate, :as_of_date
19
+ validates_length_of :source_currency_code, :is => 3
20
+ validates_length_of :target_currency_code, :is => 3
21
+ end
22
+ end
23
+ end
@@ -3,7 +3,8 @@ module Quickbooks
3
3
  class GroupLineDetail < BaseModel
4
4
  include HasLineItems
5
5
 
6
- xml_accessor :group_item_ref, :from => 'CustomerRef', :as => BaseReference
6
+ xml_accessor :id, :from => 'Id'
7
+ xml_accessor :group_item_ref, :from => 'GroupItemRef', :as => BaseReference
7
8
  xml_accessor :quantity, :from => 'Quantity', :as => BigDecimal, :to_xml => to_xml_big_decimal
8
9
  xml_accessor :line_items, :from => 'Line', :as => [Line]
9
10
 
@@ -24,6 +24,7 @@ module Quickbooks
24
24
  xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
25
25
  xml_accessor :auto_doc_number, :from => 'AutoDocNumber' # See auto_doc_number! method below for usage
26
26
  xml_accessor :doc_number, :from => 'DocNumber'
27
+ xml_accessor :invoice_link, :from => 'InvoiceLink'
27
28
  xml_accessor :txn_date, :from => 'TxnDate', :as => Date
28
29
  xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
29
30
  xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
@@ -35,6 +36,7 @@ module Quickbooks
35
36
  xml_accessor :customer_memo, :from => 'CustomerMemo'
36
37
  xml_accessor :billing_address, :from => 'BillAddr', :as => PhysicalAddress
37
38
  xml_accessor :shipping_address, :from => 'ShipAddr', :as => PhysicalAddress
39
+ xml_accessor :ship_from_address, :from => 'ShipFromAddr', :as => PhysicalAddress
38
40
  xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
39
41
  xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
40
42
  xml_accessor :due_date, :from => 'DueDate', :as => Date
@@ -48,6 +50,7 @@ module Quickbooks
48
50
  xml_accessor :print_status, :from => 'PrintStatus'
49
51
  xml_accessor :email_status, :from => 'EmailStatus'
50
52
  xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
53
+ xml_accessor :home_balance, :from => 'HomeBalance', :as => BigDecimal, :to_xml => to_xml_big_decimal
51
54
  xml_accessor :deposit, :from => 'Deposit', :as => BigDecimal, :to_xml => to_xml_big_decimal
52
55
  xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
53
56
  xml_accessor :allow_ipn_payment?, :from => 'AllowIPNPayment'
@@ -57,6 +60,7 @@ module Quickbooks
57
60
  xml_accessor :allow_online_credit_card_payment?, :from => 'AllowOnlineCreditCardPayment'
58
61
  xml_accessor :allow_online_ach_payment?, :from => 'AllowOnlineACHPayment'
59
62
  xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
63
+ xml_accessor :bill_email_cc, :from => 'BillEmailCc', :as => EmailAddress
60
64
 
61
65
 
62
66
  reference_setters
@@ -85,6 +89,9 @@ module Quickbooks
85
89
  self.bill_email = EmailAddress.new(email_address_string)
86
90
  end
87
91
 
92
+ def billing_email_cc_address=(email_address_string)
93
+ self.bill_email_cc = EmailAddress.new(email_address_string)
94
+ end
88
95
 
89
96
  def wants_billing_email_sent!
90
97
  self.email_status = EMAIL_STATUS_NEED_TO_SEND
@@ -94,7 +101,6 @@ module Quickbooks
94
101
  email_status == EMAIL_STATUS_NEED_TO_SEND
95
102
  end
96
103
 
97
-
98
104
  def existence_of_customer_ref
99
105
  if customer_ref.nil? || (customer_ref && customer_ref.value == 0)
100
106
  errors.add(:customer_ref, "CustomerRef is required and must be a non-zero value.")
@@ -1,6 +1,7 @@
1
1
  module Quickbooks
2
2
  module Model
3
- # Refer to: https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/change_data_capture
3
+ # Refer to:
4
+ # - https://developer.intuit.com/docs/0100_quickbooks_online/0200_dev_guides/accounting/change_data_capture
4
5
  class InvoiceChange < ChangeModel
5
6
  XML_NODE = "Invoice"
6
7
  end
@@ -0,0 +1,14 @@
1
+ module Quickbooks
2
+ module Model
3
+ class InvoiceGroupLineDetail < InvoiceLineItem
4
+ include HasLineItems
5
+
6
+ xml_accessor :id, :from => 'Id'
7
+ xml_accessor :group_item_ref, :from => 'GroupItemRef', :as => BaseReference
8
+ xml_accessor :quantity, :from => 'Quantity', :as => BigDecimal, :to_xml => to_xml_big_decimal
9
+ xml_accessor :line_items, :from => 'Line', :as => [InvoiceLineItem]
10
+
11
+ reference_setters :group_item_ref
12
+ end
13
+ end
14
+ end
@@ -1,12 +1,16 @@
1
1
  module Quickbooks
2
2
  module Model
3
3
  class InvoiceLineItem < BaseModel
4
+ require 'quickbooks/model/invoice_group_line_detail'
4
5
 
5
6
  #== Constants
6
7
  SALES_LINE_ITEM_DETAIL = 'SalesItemLineDetail'
7
8
  SUB_TOTAL_LINE_DETAIL = 'SubTotalLineDetail'
8
9
  PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
9
10
  DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'
11
+ INVOICE_GROUP_LINE_DETAIL = 'GroupLineDetail'
12
+ DESCRIPTION_LINE_DETAIL = 'DescriptionLineDetail'
13
+ DESCRIPTION_DETAIL_TYPE = 'DescriptionOnly'
10
14
 
11
15
  xml_accessor :id, :from => 'Id'
12
16
  xml_accessor :line_num, :from => 'LineNum', :as => Integer
@@ -15,10 +19,16 @@ module Quickbooks
15
19
  xml_accessor :detail_type, :from => 'DetailType'
16
20
 
17
21
  #== Various detail types
18
- xml_accessor :sales_line_item_detail, :from => 'SalesItemLineDetail', :as => SalesItemLineDetail
19
- xml_accessor :sub_total_line_detail, :from => 'SubTotalLineDetail', :as => SubTotalLineDetail
20
- xml_accessor :payment_line_detail, :from => 'PaymentLineDetail', :as => PaymentLineDetail
21
- xml_accessor :discount_line_detail, :from => 'DiscountLineDetail', :as => DiscountLineDetail
22
+ xml_accessor :sales_line_item_detail, :from => SALES_LINE_ITEM_DETAIL, :as => SalesItemLineDetail
23
+ xml_accessor :sub_total_line_detail, :from => SUB_TOTAL_LINE_DETAIL, :as => SubTotalLineDetail
24
+ xml_accessor :payment_line_detail, :from => PAYMENT_LINE_DETAIL, :as => PaymentLineDetail
25
+ xml_accessor :discount_line_detail, :from => DISCOUNT_LINE_DETAIL, :as => DiscountLineDetail
26
+ xml_accessor :group_line_detail, :from => INVOICE_GROUP_LINE_DETAIL, :as => InvoiceGroupLineDetail
27
+ xml_accessor :description_line_detail, :from => DESCRIPTION_LINE_DETAIL, :as => DescriptionLineDetail
28
+
29
+ def group_line_detail?
30
+ detail_type.to_s == INVOICE_GROUP_LINE_DETAIL
31
+ end
22
32
 
23
33
  def sales_item?
24
34
  detail_type.to_s == SALES_LINE_ITEM_DETAIL
@@ -32,6 +42,12 @@ module Quickbooks
32
42
  detail_type.to_s == DISCOUNT_LINE_DETAIL
33
43
  end
34
44
 
45
+ def description_only?
46
+ # The detail type for a description-only line detail differs slightly
47
+ # from the node name (DescriptionOnly vs DescriptionLineDetail)
48
+ detail_type.to_s == DESCRIPTION_DETAIL_TYPE
49
+ end
50
+
35
51
  def sales_item!
36
52
  self.detail_type = SALES_LINE_ITEM_DETAIL
37
53
  self.sales_line_item_detail = SalesItemLineDetail.new
@@ -39,6 +55,13 @@ module Quickbooks
39
55
  yield self.sales_line_item_detail if block_given?
40
56
  end
41
57
 
58
+ def group_line_detail!
59
+ self.detail_type = INVOICE_GROUP_LINE_DETAIL
60
+ self.group_line_detail = InvoiceGroupLineDetail.new
61
+
62
+ yield self.group_line_detail if block_given?
63
+ end
64
+
42
65
  def payment_item!
43
66
  self.detail_type = PAYMENT_LINE_DETAIL
44
67
  self.payment_line_detail = PaymentLineDetail.new
@@ -53,6 +76,13 @@ module Quickbooks
53
76
  yield self.discount_line_detail if block_given?
54
77
  end
55
78
 
79
+ def description_only!
80
+ self.detail_type = DESCRIPTION_DETAIL_TYPE
81
+ self.description_line_detail = DescriptionLineDetail.new
82
+
83
+ yield self.description_line_detail if block_given?
84
+ end
85
+
56
86
  end
57
87
  end
58
88
  end
@@ -12,20 +12,25 @@ module Quickbooks
12
12
  REST_RESOURCE = 'item'
13
13
 
14
14
  INVENTORY_TYPE = 'Inventory'
15
- NON_INVENTORY_TYPE = 'Non Inventory'
15
+ NON_INVENTORY_TYPE = 'NonInventory'
16
16
  SERVICE_TYPE = 'Service'
17
- ITEM_TYPES = [INVENTORY_TYPE, NON_INVENTORY_TYPE, SERVICE_TYPE]
17
+ CATEGORY_TYPE = 'Category'
18
+ ITEM_TYPES = [INVENTORY_TYPE, NON_INVENTORY_TYPE, SERVICE_TYPE, CATEGORY_TYPE]
18
19
 
19
20
  xml_name 'Item'
20
21
  xml_accessor :id, :from => 'Id'
21
22
  xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
22
23
  xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
23
24
  xml_accessor :name, :from => 'Name'
25
+ xml_accessor :sku, :from => 'Sku'
24
26
  xml_accessor :description, :from => 'Description'
25
27
  xml_accessor :active?, :from => 'Active'
26
28
  xml_accessor :sub_item?, :from => 'SubItem'
27
29
  xml_accessor :parent_ref, :from => 'ParentRef', :as => Integer
28
30
  xml_accessor :level, :from => 'Level', :as => Integer
31
+ xml_accessor :pref_vendor_ref, :from => 'PrefVendorRef', :as => BaseReference
32
+ xml_accessor :tax_classification_ref, :from => 'TaxClassificationRef', :as => BaseReference
33
+ xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
29
34
 
30
35
  # read-only
31
36
  xml_accessor :fully_qualified_name, :from => 'FullyQualifiedName'
@@ -45,9 +50,13 @@ module Quickbooks
45
50
  xml_accessor :sales_tax_code_ref, :from => 'SalesTaxCodeRef', :as => BaseReference
46
51
  xml_accessor :purchase_tax_code_ref, :from => 'PurchaseTaxCodeRef', :as => BaseReference
47
52
  xml_accessor :inv_start_date, :from => 'InvStartDate', :as => Date
53
+ xml_accessor :custom_fields, :from => "CustomField", as: [CustomField]
54
+ xml_accessor :print_grouped_items?, :from => 'PrintGroupedItems'
55
+ xml_accessor :item_group_details, :from => 'ItemGroupDetail', :as => ItemGroupDetail
48
56
 
49
57
  reference_setters :parent_ref, :income_account_ref, :expense_account_ref
50
58
  reference_setters :asset_account_ref, :sales_tax_code_ref, :purchase_tax_code_ref
59
+ reference_setters :pref_vendor_ref, :tax_classification_ref, :class_ref
51
60
 
52
61
  #== Validations
53
62
  validates_length_of :name, :minimum => 1
@@ -75,7 +84,6 @@ module Quickbooks
75
84
  end
76
85
  errors.empty?
77
86
  end
78
-
79
87
  end
80
88
  end
81
89
  end
@@ -0,0 +1,9 @@
1
+ module Quickbooks
2
+ module Model
3
+ class ItemGroupDetail < BaseModel
4
+ include HasLineItems
5
+
6
+ xml_accessor :line_items, :from => 'ItemGroupLine', :as => [ItemGroupLine]
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ module Quickbooks
2
+ module Model
3
+ class ItemGroupLine < BaseModel
4
+ xml_accessor :item_ref, :from => 'ItemRef', :as => BaseReference
5
+ xml_accessor :quantity, :from => 'Qty'
6
+
7
+ def id
8
+ item_ref.value.to_i
9
+ end
10
+
11
+ def name
12
+ item_ref.name
13
+ end
14
+
15
+ def type
16
+ item_ref.type
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,12 +1,15 @@
1
1
  module Quickbooks
2
2
  module Model
3
3
  class Line < BaseModel
4
+ require 'quickbooks/model/group_line_detail'
5
+
4
6
  #== Constants
5
7
  SALES_ITEM_LINE_DETAIL = 'SalesItemLineDetail'
6
8
  SUB_TOTAL_LINE_DETAIL = 'SubTotalLineDetail'
7
9
  PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
8
10
  DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'
9
11
  JOURNAL_ENTRY_LINE_DETAIL = 'JournalEntryLineDetail'
12
+ GROUP_LINE_DETAIL = 'GroupLineDetail'
10
13
 
11
14
  xml_accessor :id, :from => 'Id'
12
15
  xml_accessor :line_num, :from => 'LineNum', :as => Integer
@@ -14,6 +17,7 @@ module Quickbooks
14
17
  xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
15
18
  xml_accessor :detail_type, :from => 'DetailType'
16
19
  xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
20
+ xml_accessor :line_extras, :from => 'LineEx', :as => LineEx
17
21
 
18
22
  #== Various detail types
19
23
  xml_accessor :sales_item_line_detail, :from => 'SalesItemLineDetail', :as => SalesItemLineDetail
@@ -21,6 +25,7 @@ module Quickbooks
21
25
  xml_accessor :payment_line_detail, :from => 'PaymentLineDetail', :as => PaymentLineDetail
22
26
  xml_accessor :discount_line_detail, :from => 'DiscountLineDetail', :as => DiscountOverride
23
27
  xml_accessor :journal_entry_line_detail, :from => 'JournalEntryLineDetail', :as => JournalEntryLineDetail
28
+ xml_accessor :group_line_detail, :from => 'GroupLineDetail', :as => GroupLineDetail
24
29
 
25
30
  def initialize(*args)
26
31
  self.linked_transactions ||= []
@@ -72,6 +77,13 @@ module Quickbooks
72
77
  yield self.journal_entry_line_detail if block_given?
73
78
  end
74
79
 
80
+ def group_line!
81
+ self.detail_type = GROUP_LINE_DETAIL
82
+ self.group_line_detail = GroupLineDetail.new
83
+
84
+ yield self.group_line_detail if block_given?
85
+ end
86
+
75
87
  private
76
88
 
77
89
  def update_linked_transactions(txn_ids, txn_type)