quickbooks-ruby-base 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTQ4YTRkMzhlOWMyMGZhNWEzNDVhNTY0ZjM1Zjc5ZGU0NTkyZGY3Yg==
4
+ ZTQ4MzMwYzE2MDZkYzY2N2QyNjVhOTkzZTkyZTRlMTFmZTMwOGFjOQ==
5
5
  data.tar.gz: !binary |-
6
- MjU3N2RjMDgyNzE5ODEzMjMwNTYzODY3ZWM0NzY4N2UxYjAyZDcwZQ==
6
+ MDUxZmZjZmIzMzMyNjA2NzQ5OGYzNmM5ZTU4MDNmNGViYjIwOGE3ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjcxODk1NDAxMzMzMTRlOGJhNzMwZWI4ZDM0NzlkMWM0Yzc4Y2M5YTE2YTdh
10
- OWEwZmFlZTRmNjNhMjkzZjNmYzk1NTBjNDQ0YmJhNTIwODFhMGM1Yzg2NGVj
11
- YmU5Mzk0ZTdjNjhlOWExMTViMmFlNDljMGZkYTBjNTM0NDg1NDI=
9
+ OWM0MWM5OWJhMWY5MTdmMjc0MDIyZjk5NDczYWUyMTEzYWY0M2UwY2JkZDcy
10
+ ZTdiZGEzMDJmN2NjZDJhZmFkNTZhYzBhNjlhMDk4YWJkZjhkYzJlMDg3Mzk0
11
+ MDBjMDRmYjNjNzY3YTYzZGEwNzY3OWYzNTg4YTNjMmI3OTU0ZGE=
12
12
  data.tar.gz: !binary |-
13
- MzllMDg1NGFhOGRkNmE5MjMwZDRjNDE2Mjc4ZjFkMmU4YTY0MGFhMDNjMWVi
14
- M2RmMTJiOGM3ODE2MzY4ZTI4NWRmNDJjMzg1ODI0Zjg2ZjM5ZDcxYWJiNWZl
15
- ZjYyMDdjZWIwOTQwMTgxMWMxZjhhZjRlMjIzM2UxZmQyMWNlNzU=
13
+ NWU3NTVjYmZlODBjOGY4NGUyMDYzYjNjMGQ4ZGFhZjliNWI1YzBmY2VmMWQx
14
+ ODk5OWQ0ZjAyYTgyN2ZiN2QwYmFlZWFjMDVhMTBiNWZjNzNlODc3NjcyM2M3
15
+ ZTBhNDU0NWRmZDI1YWJiM2UzZmMyOWM1ZjJlNjE2ZGRkMTg5NWY=
@@ -32,18 +32,29 @@ module Quickbooks
32
32
 
33
33
  def show(options = {})
34
34
  options = { per_page: 20, page: 1 }.merge(options)
35
- method = describing_method
36
- @service.query(nil, options).entries.collect { |e| "QBID: #{e.id} DESC: #{e.send(method) if method}" }
35
+ @service.query(nil, options).entries.collect do |e|
36
+ "QBID: #{e.id} DESC: #{description(e)}"
37
+ end
38
+ end
39
+
40
+ def description(e)
41
+ desc = (method = describing_method) =~ /(total)/ ? e.send(method).to_f : e.send(method)
42
+ rescue => e
43
+ 'nil'
37
44
  end
38
45
 
39
46
  def describing_method
40
47
  case @service.class.name
41
- when /(Item|TaxCode|PaymentMethod)/
48
+ when /(Item|TaxCode|PaymentMethod|Account)/
42
49
  'name'
43
- when /(Invoice|Payment)/
50
+ when /(Invoice|CreditMemo)/
44
51
  'doc_number'
52
+ when /Payment/
53
+ 'total'
45
54
  when /(Vendor|Customer|Employee)/
46
55
  'display_name'
56
+ else
57
+ 'txn_date'
47
58
  end
48
59
  end
49
60
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'quickbooks-ruby-base'
7
- spec.version = '1.0.0'
7
+ spec.version = '1.0.1'
8
8
  spec.authors = ["Christian"]
9
9
  spec.email = ["christian@minimul.com"]
10
10
  spec.summary = %q{Base class to provide common methods for the quickbooks-ruby gem}
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-04-04T04:52:19.963-07:00">
3
+ <QueryResponse startPosition="1" maxResults="20" totalCount="1">
4
+ <Dummy>
5
+ <Id>1</Id>
6
+ </Dummy>
7
+ <Dummy>
8
+ <Id>2</Id>
9
+ </Dummy>
10
+ </QueryResponse>
11
+ </IntuitResponse>
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-04-04T04:52:19.963-07:00">
3
+ <QueryResponse startPosition="1" maxResults="20" totalCount="20">
4
+ <Payment>
5
+ <Id>33</Id>
6
+ <SyncToken>0</SyncToken>
7
+ <MetaData>
8
+ <CreateTime>2014-04-15T10:21:16-0400</CreateTime>
9
+ <LastUpdatedTime>2014-04-15T10:21:16-0400</LastUpdatedTime>
10
+ </MetaData>
11
+ <TxnDate>2014-04-14</TxnDate>
12
+ <Line>
13
+ <Amount>100.0</Amount>
14
+ <LinkedTxn>
15
+ <TxnId>29</TxnId>
16
+ <TxnType>Invoice</TxnType>
17
+ </LinkedTxn>
18
+ <LinkedTxn>
19
+ <TxnId>29</TxnId>
20
+ <TxnType>Invoice</TxnType>
21
+ </LinkedTxn>
22
+ </Line>
23
+ <CustomerRef>6</CustomerRef>
24
+ <DepositToAccountRef>4</DepositToAccountRef>
25
+ <TotalAmt>100.0</TotalAmt>
26
+ <UnappliedAmt>0.0</UnappliedAmt>
27
+ <ProcessPayment>false</ProcessPayment>
28
+ <ExchangeRate>0.0</ExchangeRate>
29
+ </Payment>
30
+ <Payment>
31
+ <Id>32</Id>
32
+ <SyncToken>0</SyncToken>
33
+ <MetaData>
34
+ <CreateTime>2014-04-15T10:18:27-0400</CreateTime>
35
+ <LastUpdatedTime>2014-04-15T10:18:27-0400</LastUpdatedTime>
36
+ </MetaData>
37
+ <TxnDate>2014-04-14</TxnDate>
38
+ <CustomerRef>6</CustomerRef>
39
+ <DepositToAccountRef>4</DepositToAccountRef>
40
+ <TotalAmt>100.0</TotalAmt>
41
+ <UnappliedAmt>100.0</UnappliedAmt>
42
+ <ProcessPayment>false</ProcessPayment>
43
+ <ExchangeRate>0.0</ExchangeRate>
44
+ </Payment>
45
+ </QueryResponse>
46
+ </IntuitResponse>
@@ -29,7 +29,7 @@ describe Quickbooks::Base do
29
29
  describe ".show" do
30
30
  let(:account) { account = double(settings: double( qb_token: 'tttttttttt', qb_secret: 'ssssssss', qb_company_id: '1234567')) }
31
31
 
32
- it "should display using the name as the given name" do
32
+ it "description should display using the dispay_name for vendor" do
33
33
  xml = File.read(File.join('spec', 'fixtures', 'vendors.xml'))
34
34
  response = Struct.new(:plain_body, :code).new(xml, 200)
35
35
  allow_any_instance_of(OAuth::AccessToken).to receive(:get).and_return(response)
@@ -37,7 +37,7 @@ describe Quickbooks::Base do
37
37
  expect(qr.show.first).to match /Catherines Cupcakes/
38
38
  end
39
39
 
40
- it "should display using the name and not doc_number" do
40
+ it "description should display using the name for tax_code" do
41
41
  xml = File.read(File.join('spec', 'fixtures', 'tax_codes.xml'))
42
42
  response = Struct.new(:plain_body, :code).new(xml, 200)
43
43
  allow_any_instance_of(OAuth::AccessToken).to receive(:get).and_return(response)
@@ -45,13 +45,31 @@ describe Quickbooks::Base do
45
45
  expect(qr.show.last).to match /New York City/
46
46
  end
47
47
 
48
- it "should display using the doc_number and not name" do
48
+ it "description should display using the doc_number for invoice" do
49
49
  xml = File.read(File.join('spec', 'fixtures', 'invoices.xml'))
50
50
  response = Struct.new(:plain_body, :code).new(xml, 200)
51
51
  allow_any_instance_of(OAuth::AccessToken).to receive(:get).and_return(response)
52
52
  qr = Quickbooks::Base.new(account, :invoice)
53
53
  expect(qr.show.last).to match /1234/
54
54
  end
55
+
56
+ it "description should display using the total for payment" do
57
+ xml = File.read(File.join('spec', 'fixtures', 'payments.xml'))
58
+ response = Struct.new(:plain_body, :code).new(xml, 200)
59
+ allow_any_instance_of(OAuth::AccessToken).to receive(:get).and_return(response)
60
+ qr = Quickbooks::Base.new(account, :payment)
61
+ expect(qr.show.last).to match /100\.0/
62
+ end
63
+
64
+ it "description should display 'nil' as no description fits" do
65
+ xml = File.read(File.join('spec', 'fixtures', 'dummy.xml'))
66
+ xml.gsub!('Dummy', 'SalesReceipt')
67
+ response = Struct.new(:plain_body, :code).new(xml, 200)
68
+ allow_any_instance_of(OAuth::AccessToken).to receive(:get).and_return(response)
69
+ qr = Quickbooks::Base.new(account, :sales_receipt)
70
+ expect(qr.show.last).to match /nil/
71
+ end
72
+
55
73
  end
56
74
 
57
75
  describe ".retrieve" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickbooks-ruby-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-05 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: quickbooks-ruby
@@ -82,7 +82,9 @@ files:
82
82
  - lib/quickbooks/base.rb
83
83
  - lib/quickbooks/base/configuration.rb
84
84
  - quickbooks-ruby-base.gemspec
85
+ - spec/fixtures/dummy.xml
85
86
  - spec/fixtures/invoices.xml
87
+ - spec/fixtures/payments.xml
86
88
  - spec/fixtures/tax_codes.xml
87
89
  - spec/fixtures/vendors.xml
88
90
  - spec/quickbooks_ruby_base_spec.rb
@@ -112,7 +114,9 @@ signing_key:
112
114
  specification_version: 4
113
115
  summary: Base class to provide common methods for the quickbooks-ruby gem
114
116
  test_files:
117
+ - spec/fixtures/dummy.xml
115
118
  - spec/fixtures/invoices.xml
119
+ - spec/fixtures/payments.xml
116
120
  - spec/fixtures/tax_codes.xml
117
121
  - spec/fixtures/vendors.xml
118
122
  - spec/quickbooks_ruby_base_spec.rb