quickbooks-ruby 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9f08f2bfe36efcbc4e438d7772eab4c46bc63f6
4
- data.tar.gz: 1ca22e4d49058187e2181ce1ced6daeddddf7a60
3
+ metadata.gz: ff4b1233ad85484b5c75b299803783ce7db38148
4
+ data.tar.gz: d280d02ad5ad234a969568ba7184412a5dc71b00
5
5
  SHA512:
6
- metadata.gz: ee1e2883870be85a1767f5903a8f3b2e078aa8c394be50efb215af98e839276dd77a3ee3d0fc07bb3be152f03604f0a691003390ffee6303fde804883f5a90c8
7
- data.tar.gz: 043b4a0f98ff875d583c1f5684877ccd4c68e048a7a8803b02052374eff235bf5a7271ca66c537ea0e14ae9f7f81b6a0592b20a209896ab4bfde2846f693512d
6
+ metadata.gz: b3859a045fa2ceed5ef713f7377a9c707738dd3e6430d804a46e12e6a8371eefb14cfb89c6cdb69d6624c93f4f382cdd6078ffb62bbfa2fcbff6a8afbb724550
7
+ data.tar.gz: 3ce96e27454142e80ab5b7debe74d7da070f5f29794c3d8a53d31a82f5a7c00e8823c50651444bb724c7f9ad2bb7c1a5df0755950b3e27f2fb75b9d63042503f
@@ -10,6 +10,7 @@ require 'oauth'
10
10
  require 'quickbooks/util/logging'
11
11
  require 'quickbooks/util/http_encoding_helper'
12
12
  require 'quickbooks/util/name_entity'
13
+ require 'quickbooks/util/query_builder'
13
14
 
14
15
  #== Models
15
16
  require 'quickbooks/model/base_model'
@@ -19,6 +20,7 @@ require 'quickbooks/model/meta_data'
19
20
  require 'quickbooks/model/custom_field'
20
21
  require 'quickbooks/model/sales_item_line_detail'
21
22
  require 'quickbooks/model/sub_total_line_detail'
23
+ require 'quickbooks/model/discount_line_detail'
22
24
  require 'quickbooks/model/discount_override'
23
25
  require 'quickbooks/model/payment_line_detail'
24
26
  require 'quickbooks/model/account_based_expense_line_detail'
@@ -6,9 +6,17 @@ class Quickbooks::Model::BatchRequest < Quickbooks::Model::BaseModel
6
6
 
7
7
  xml_accessor :operation, :from => "@operation"
8
8
  xml_accessor :bId, :from => "@bId"
9
- [:Item, :Account, :Invoice, :Customer, :Bill, :SalesReceipt].each do |model|
10
- xml_accessor model.to_s.underscore, from: model.to_s, as: "Quickbooks::Model::#{model.to_s}".constantize
11
- end
9
+
10
+ # Supported Entities
11
+ xml_accessor :item, from: "Item", as: Quickbooks::Model::Item
12
+ xml_accessor :account, from: "Account", as: Quickbooks::Model::Account
13
+ xml_accessor :invoice, from: "Invoice", as: Quickbooks::Model::Invoice
14
+ xml_accessor :customer, from: "Customer", as: Quickbooks::Model::Customer
15
+ xml_accessor :bill, from: "Bill", as: Quickbooks::Model::Bill
16
+ xml_accessor :sales_receipt, from: "SalesReceipt", as: Quickbooks::Model::SalesReceipt
17
+ xml_accessor :bill_payment, from: "BillPayment", as: Quickbooks::Model::BillPayment
18
+ xml_accessor :purchase, from: "Purchase", as: Quickbooks::Model::Purchase
19
+ xml_accessor :credit_memo, from: "CreditMemo", as: Quickbooks::Model::CreditMemo
12
20
  end
13
21
 
14
22
  XML_COLLECTION_NODE = "IntuitBatchRequest"
@@ -5,9 +5,17 @@ class Quickbooks::Model::BatchResponse < Quickbooks::Model::BaseModel
5
5
 
6
6
  xml_accessor :bId, :from => "@bId"
7
7
  xml_accessor :fault, :from => 'Fault', :as => Quickbooks::Model::Fault
8
- [:Item, :Account, :Invoice, :Customer, :Bill, :SalesReceipt].each do |model|
9
- xml_accessor model.to_s.underscore, from: model.to_s, as: "Quickbooks::Model::#{model.to_s}".constantize
10
- end
8
+
9
+ # Supported Entities
10
+ xml_accessor :item, from: "Item", as: Quickbooks::Model::Item
11
+ xml_accessor :account, from: "Account", as: Quickbooks::Model::Account
12
+ xml_accessor :invoice, from: "Invoice", as: Quickbooks::Model::Invoice
13
+ xml_accessor :customer, from: "Customer", as: Quickbooks::Model::Customer
14
+ xml_accessor :bill, from: "Bill", as: Quickbooks::Model::Bill
15
+ xml_accessor :sales_receipt, from: "SalesReceipt", as: Quickbooks::Model::SalesReceipt
16
+ xml_accessor :bill_payment, from: "BillPayment", as: Quickbooks::Model::BillPayment
17
+ xml_accessor :purchase, from: "Purchase", as: Quickbooks::Model::Purchase
18
+ xml_accessor :credit_memo, from: "CreditMemo", as: Quickbooks::Model::CreditMemo
11
19
 
12
20
  def fault?
13
21
  fault
@@ -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 => Proc.new { |val| val && val.to_f }
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
@@ -50,7 +50,7 @@ module Quickbooks
50
50
  xml_accessor :allow_online_ach_payment?, :from => 'AllowOnlineACHPayment'
51
51
 
52
52
  reference_setters :customer_ref, :class_ref, :sales_term_ref, :ship_method_ref
53
- reference_setters :ar_account_ref, :department_ref
53
+ reference_setters :ar_account_ref, :department_ref, :ar_account_ref
54
54
 
55
55
  #== Validations
56
56
  validates_length_of :line_items, :minimum => 1
@@ -6,6 +6,7 @@ module Quickbooks
6
6
  SALES_LINE_ITEM_DETAIL = 'SalesItemLineDetail'
7
7
  SUB_TOTAL_LINE_DETAIL = 'SubTotalLineDetail'
8
8
  PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
9
+ DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'
9
10
 
10
11
  xml_accessor :id, :from => 'Id', :as => Integer
11
12
  xml_accessor :line_num, :from => 'LineNum', :as => Integer
@@ -17,6 +18,7 @@ module Quickbooks
17
18
  xml_accessor :sales_line_item_detail, :from => 'SalesItemLineDetail', :as => SalesItemLineDetail
18
19
  xml_accessor :sub_total_line_detail, :from => 'SubTotalLineDetail', :as => SubTotalLineDetail
19
20
  xml_accessor :payment_line_detail, :from => 'PaymentLineDetail', :as => PaymentLineDetail
21
+ xml_accessor :discount_line_detail, :from => 'DiscountLineDetail', :as => DiscountLineDetail
20
22
 
21
23
  def sales_item?
22
24
  detail_type.to_s == SALES_LINE_ITEM_DETAIL
@@ -26,6 +28,10 @@ module Quickbooks
26
28
  detail_type.to_s == SUB_TOTAL_LINE_DETAIL
27
29
  end
28
30
 
31
+ def discount_item?
32
+ detail_type.to_s == DISCOUNT_LINE_DETAIL
33
+ end
34
+
29
35
  def sales_item!
30
36
  self.detail_type = SALES_LINE_ITEM_DETAIL
31
37
  self.sales_line_item_detail = SalesItemLineDetail.new
@@ -40,6 +46,13 @@ module Quickbooks
40
46
  yield self.payment_line_detail if block_given?
41
47
  end
42
48
 
49
+ def discount_item!
50
+ self.detail_type = DISCOUNT_LINE_DETAIL
51
+ self.discount_line_detail = DiscountLineDetail.new
52
+
53
+ yield self.discount_line_detail if block_given?
54
+ end
55
+
43
56
  end
44
57
  end
45
58
  end
@@ -12,6 +12,7 @@ module Quickbooks
12
12
  xml_accessor :description, :from => 'Description'
13
13
  xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
14
14
  xml_accessor :detail_type, :from => 'DetailType'
15
+ xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
15
16
 
16
17
  #== Various detail types
17
18
  xml_accessor :sales_item_line_detail, :from => 'SalesItemLineDetail', :as => SalesItemLineDetail
@@ -16,7 +16,7 @@ module Quickbooks
16
16
  xml_accessor :ar_account_ref, :from => 'ARAccountRef', :as => BaseReference
17
17
  xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
18
18
  xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
19
- xml_accessor :payment_method_number, :from => 'PaymentMethodNum'
19
+ xml_accessor :payment_ref_number, :from => 'PaymentRefNum'
20
20
  xml_accessor :credit_card_payment, :from => 'CreditCardPayment', :as => CreditCardPayment
21
21
  xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => :to_f.to_proc
22
22
  xml_accessor :unapplied_amount, :from => 'UnappliedAmt', :as => BigDecimal, :to_xml => :to_f.to_proc
@@ -24,8 +24,8 @@ module Quickbooks
24
24
  xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
25
25
  xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => :to_f.to_proc
26
26
 
27
- reference_setters :customer_ref
28
- reference_setters :payment_method_ref
27
+ reference_setters :customer_ref, :ar_account_ref
28
+ reference_setters :payment_method_ref, :deposit_to_account_ref, :currency_ref
29
29
 
30
30
  validate :existence_of_customer_ref
31
31
 
@@ -0,0 +1,21 @@
1
+ require 'uri'
2
+
3
+ module Quickbooks
4
+ module Util
5
+ class QueryBuilder
6
+
7
+ VALUE_QUOTE = "'"
8
+
9
+ def initialize
10
+ end
11
+
12
+ def clause(field, operator, value)
13
+ # escape single quotes with an escaped backslash
14
+ value = value.gsub("'", "\\\\'")
15
+
16
+ "#{field} #{operator} #{VALUE_QUOTE}#{value}#{VALUE_QUOTE}"
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module Quickbooks
2
2
 
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickbooks-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Caughlan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth
@@ -189,6 +189,7 @@ files:
189
189
  - lib/quickbooks/model/credit_memo.rb
190
190
  - lib/quickbooks/model/custom_field.rb
191
191
  - lib/quickbooks/model/customer.rb
192
+ - lib/quickbooks/model/discount_line_detail.rb
192
193
  - lib/quickbooks/model/discount_override.rb
193
194
  - lib/quickbooks/model/email_address.rb
194
195
  - lib/quickbooks/model/employee.rb
@@ -255,6 +256,7 @@ files:
255
256
  - lib/quickbooks/util/http_encoding_helper.rb
256
257
  - lib/quickbooks/util/logging.rb
257
258
  - lib/quickbooks/util/name_entity.rb
259
+ - lib/quickbooks/util/query_builder.rb
258
260
  - lib/quickbooks/version.rb
259
261
  - lib/quickbooks-ruby.rb
260
262
  homepage: http://github.com/ruckus/quickbooks-ruby