quickeebooks 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +19 -16
- data/README.md +29 -23
- data/coverage/assets/0.7.1/application.css +1110 -0
- data/coverage/assets/0.7.1/application.js +626 -0
- data/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
- data/coverage/assets/0.7.1/favicon_green.png +0 -0
- data/coverage/assets/0.7.1/favicon_red.png +0 -0
- data/coverage/assets/0.7.1/favicon_yellow.png +0 -0
- data/coverage/assets/0.7.1/loading.gif +0 -0
- data/coverage/assets/0.7.1/magnify.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +29154 -0
- data/lib/quickeebooks/common/online_line_item_model_methods.rb +43 -0
- data/lib/quickeebooks/common/service_crud.rb +56 -0
- data/lib/quickeebooks/online/model/bill.rb +26 -0
- data/lib/quickeebooks/online/model/bill_header.rb +21 -0
- data/lib/quickeebooks/online/model/bill_line_item.rb +22 -0
- data/lib/quickeebooks/online/model/bill_reimbursable.rb +11 -0
- data/lib/quickeebooks/online/model/invoice.rb +2 -31
- data/lib/quickeebooks/online/model/payment.rb +5 -33
- data/lib/quickeebooks/online/service/bill.rb +17 -0
- data/lib/quickeebooks/online/service/customer.rb +3 -47
- data/lib/quickeebooks/online/service/invoice.rb +1 -1
- data/lib/quickeebooks/online/service/payment.rb +3 -46
- data/lib/quickeebooks/online/service/service_base.rb +3 -2
- data/lib/quickeebooks/online/service/sort.rb +1 -12
- data/lib/quickeebooks/shared/service/filter.rb +19 -2
- data/lib/quickeebooks/shared/service/sort.rb +22 -0
- data/lib/quickeebooks/version.rb +1 -1
- data/lib/quickeebooks/windows/service/clazz.rb +1 -5
- data/lib/quickeebooks/windows/service/customer.rb +9 -13
- data/lib/quickeebooks/windows/service/item.rb +2 -5
- data/lib/quickeebooks/windows/service/service_base.rb +30 -15
- data/lib/quickeebooks/windows/service/sort.rb +8 -0
- data/lib/quickeebooks.rb +11 -5
- data/quickeebooks.gemspec +2 -2
- data/spec/quickeebooks/common/online_line_item_model_methods_spec.rb +41 -0
- data/spec/quickeebooks/common/service_crud_spec.rb +41 -0
- data/spec/quickeebooks/online/account_spec.rb +4 -8
- data/spec/quickeebooks/online/bill_spec.rb +17 -0
- data/spec/quickeebooks/online/company_meta_data_spec.rb +6 -9
- data/spec/quickeebooks/online/customer_spec.rb +10 -14
- data/spec/quickeebooks/online/invoice_spec.rb +3 -7
- data/spec/quickeebooks/online/payment_spec.rb +6 -10
- data/spec/quickeebooks/online/services/account_spec.rb +8 -13
- data/spec/quickeebooks/online/services/bill_spec.rb +61 -0
- data/spec/quickeebooks/online/services/company_meta_data_spec.rb +2 -7
- data/spec/quickeebooks/online/services/customer_spec.rb +15 -20
- data/spec/quickeebooks/online/services/filter_spec.rb +0 -5
- data/spec/quickeebooks/online/services/invoice_spec.rb +5 -10
- data/spec/quickeebooks/online/services/payment_spec.rb +63 -0
- data/spec/quickeebooks/online/services/service_base_spec.rb +62 -9
- data/spec/quickeebooks/shared/access_token_spec.rb +6 -11
- data/spec/quickeebooks/shared/filter_spec.rb +159 -0
- data/spec/quickeebooks/shared/sort_spec.rb +17 -0
- data/spec/quickeebooks/windows/customer_spec.rb +11 -15
- data/spec/quickeebooks/windows/services/class_spec.rb +2 -7
- data/spec/quickeebooks/windows/services/company_meta_data_spec.rb +2 -7
- data/spec/quickeebooks/windows/services/customer_spec.rb +16 -21
- data/spec/quickeebooks/windows/services/invoice_spec.rb +13 -19
- data/spec/quickeebooks/windows/services/payment_spec.rb +6 -12
- data/spec/quickeebooks/windows/services/sales_rep_spec.rb +6 -11
- data/spec/quickeebooks/windows/services/sales_taxes_spec.rb +5 -10
- data/spec/quickeebooks/windows/services/service_base_spec.rb +95 -0
- data/spec/quickeebooks/windows/services/ship_method_spec.rb +4 -9
- data/spec/quickeebooks_spec.rb +0 -3
- data/spec/spec_helper.rb +30 -1
- data/spec/support/oauth.rb +20 -0
- data/spec/xml/online/bill.xml +32 -0
- data/spec/xml/online/bill2.xml +32 -0
- data/spec/xml/online/bills.xml +33 -0
- data/spec/xml/online/payment.xml +1 -1
- data/spec/xml/online/payment2.xml +24 -0
- data/spec/xml/online/payments.xml +30 -0
- metadata +103 -40
- data/spec/quickeebooks/online/services/sort_spec.rb +0 -17
@@ -1,8 +1,3 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Windows::Service::Customer" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -19,9 +14,9 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
19
14
|
})
|
20
15
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
16
|
end
|
22
|
-
|
17
|
+
|
23
18
|
it "can fetch a list of customers" do
|
24
|
-
xml =
|
19
|
+
xml = windowsFixture("customers.xml")
|
25
20
|
model = Quickeebooks::Windows::Model::Customer
|
26
21
|
service = Quickeebooks::Windows::Service::Customer.new
|
27
22
|
service.access_token = @oauth
|
@@ -31,23 +26,23 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
31
26
|
accounts.entries.count.should == 3
|
32
27
|
wine_house = accounts.entries.first
|
33
28
|
wine_house.name.should == "Wine House"
|
34
|
-
|
29
|
+
|
35
30
|
billing_address = wine_house.billing_address
|
36
31
|
billing_address.should_not == nil
|
37
32
|
billing_address.line2.should == "2311 Maple Ave"
|
38
33
|
billing_address.city.should == "Los Angeles"
|
39
34
|
billing_address.state.should == "CA"
|
40
35
|
billing_address.postal_code.should == "90064"
|
41
|
-
|
36
|
+
|
42
37
|
email = wine_house.email
|
43
38
|
email.should_not == nil
|
44
39
|
email.address.should == "no-reply@winehouse.com"
|
45
40
|
email.tag.should == "Business"
|
46
41
|
email.default.should == "1"
|
47
42
|
end
|
48
|
-
|
43
|
+
|
49
44
|
it "can fetch a customer by ID" do
|
50
|
-
xml =
|
45
|
+
xml = windowsFixture("fetch_customer_by_id.xml")
|
51
46
|
model = Quickeebooks::Windows::Model::Customer
|
52
47
|
service = Quickeebooks::Windows::Service::Customer.new
|
53
48
|
service.access_token = @oauth
|
@@ -56,7 +51,7 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
56
51
|
customer = service.fetch_by_id(341)
|
57
52
|
customer.name.should == "Wine Stop"
|
58
53
|
end
|
59
|
-
|
54
|
+
|
60
55
|
it "cannot create a customer without a name" do
|
61
56
|
customer = Quickeebooks::Windows::Model::Customer.new
|
62
57
|
service = Quickeebooks::Windows::Service::Customer.new
|
@@ -65,7 +60,7 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
65
60
|
lambda do
|
66
61
|
service.create(customer)
|
67
62
|
end.should raise_error(InvalidModelException)
|
68
|
-
|
63
|
+
|
69
64
|
customer.valid?.should == false
|
70
65
|
customer.errors.keys.include?(:name).should == true
|
71
66
|
end
|
@@ -80,7 +75,7 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
80
75
|
end.should raise_error(InvalidModelException)
|
81
76
|
customer.errors.keys.include?(:type_of).should == true
|
82
77
|
end
|
83
|
-
|
78
|
+
|
84
79
|
it "cannot create a customer with invalid name" do
|
85
80
|
customer = Quickeebooks::Windows::Model::Customer.new
|
86
81
|
service = Quickeebooks::Windows::Service::Customer.new
|
@@ -90,7 +85,7 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
90
85
|
lambda do
|
91
86
|
service.create(customer)
|
92
87
|
end.should raise_error(InvalidModelException)
|
93
|
-
|
88
|
+
|
94
89
|
customer.valid?.should == false
|
95
90
|
customer.errors.keys.include?(:name).should == true
|
96
91
|
end
|
@@ -104,7 +99,7 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
104
99
|
lambda do
|
105
100
|
service.create(customer)
|
106
101
|
end.should raise_error(InvalidModelException)
|
107
|
-
|
102
|
+
|
108
103
|
customer.valid?.should == false
|
109
104
|
customer.errors.keys.include?(:addresses).should == true
|
110
105
|
end
|
@@ -119,13 +114,13 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
119
114
|
lambda do
|
120
115
|
service.create(customer)
|
121
116
|
end.should raise_error(InvalidModelException)
|
122
|
-
|
117
|
+
|
123
118
|
customer.valid?.should == false
|
124
119
|
customer.errors.keys.include?(:email).should == true
|
125
120
|
end
|
126
121
|
|
127
122
|
it "can create a customer" do
|
128
|
-
xml =
|
123
|
+
xml = windowsFixture("customer_create_success.xml")
|
129
124
|
service = Quickeebooks::Windows::Service::Customer.new
|
130
125
|
model = Quickeebooks::Windows::Model::Customer
|
131
126
|
customer = Quickeebooks::Windows::Model::Customer.new
|
@@ -153,10 +148,10 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
153
148
|
create_response.success.party_role_ref.id.value.should == "6762304"
|
154
149
|
create_response.success.request_name.should == "CustomerAdd"
|
155
150
|
end
|
156
|
-
|
151
|
+
|
157
152
|
it "can update a customer name" do
|
158
|
-
customer_xml =
|
159
|
-
update_response_xml =
|
153
|
+
customer_xml = windowsFixture("customer.xml")
|
154
|
+
update_response_xml = windowsFixture("customer_update_success.xml")
|
160
155
|
service = Quickeebooks::Windows::Service::Customer.new
|
161
156
|
model = Quickeebooks::Windows::Model::Customer
|
162
157
|
customer = model.from_xml(customer_xml)
|
@@ -1,9 +1,3 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
require "date"
|
6
|
-
|
7
1
|
describe "Quickeebooks::Windows::Service::Invoice" do
|
8
2
|
before(:all) do
|
9
3
|
FakeWeb.allow_net_connect = false
|
@@ -20,18 +14,18 @@ describe "Quickeebooks::Windows::Service::Invoice" do
|
|
20
14
|
})
|
21
15
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
22
16
|
end
|
23
|
-
|
17
|
+
|
24
18
|
it "can fetch a list of invoices" do
|
25
|
-
xml =
|
19
|
+
xml = windowsFixture("invoices.xml")
|
26
20
|
service = Quickeebooks::Windows::Service::Invoice.new
|
27
21
|
service.access_token = @oauth
|
28
22
|
service.realm_id = @realm_id
|
29
|
-
|
23
|
+
|
30
24
|
model = Quickeebooks::Windows::Model::Invoice
|
31
|
-
FakeWeb.register_uri(:
|
25
|
+
FakeWeb.register_uri(:post, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
|
32
26
|
invoices = service.list
|
33
27
|
invoices.entries.count.should == 7
|
34
|
-
|
28
|
+
|
35
29
|
invoice = invoices.entries.first
|
36
30
|
invoice.id.value.should == "9107908"
|
37
31
|
invoice.header.should_not == nil
|
@@ -39,7 +33,7 @@ describe "Quickeebooks::Windows::Service::Invoice" do
|
|
39
33
|
header.doc_number.should == "12-225"
|
40
34
|
header.txn_date.should == DateTime.parse('2012-07-10T00:00:00Z')
|
41
35
|
header.customer_name.should == "Zanotto's Fine Grocer"
|
42
|
-
|
36
|
+
|
43
37
|
header.remit_to_id.value.should == "2"
|
44
38
|
header.remit_to_name.should == "Zanotto's Fine Grocer"
|
45
39
|
header.ship_date.should == DateTime.parse('2012-07-11T00:00:00Z')
|
@@ -51,7 +45,7 @@ describe "Quickeebooks::Windows::Service::Invoice" do
|
|
51
45
|
header.ar_account_id.value.should == "30"
|
52
46
|
header.ar_account_name.should == "Accounts Receivable"
|
53
47
|
header.due_date.should == DateTime.parse('2012-08-09T00:00:00Z')
|
54
|
-
|
48
|
+
|
55
49
|
bill_addr = header.billing_address
|
56
50
|
bill_addr.should_not == nil
|
57
51
|
bill_addr.line1.should == "981 Lusk Blvd."
|
@@ -65,10 +59,10 @@ describe "Quickeebooks::Windows::Service::Invoice" do
|
|
65
59
|
ship_addr.city.should == "San Jose"
|
66
60
|
ship_addr.state.should == "CA"
|
67
61
|
ship_addr.postal_code.should == "95126"
|
68
|
-
|
62
|
+
|
69
63
|
header.bill_email.should == "thorn@zanottos.com"
|
70
64
|
header.balance.should == header.total_amount
|
71
|
-
|
65
|
+
|
72
66
|
line1 = invoice.line_items.first
|
73
67
|
line1.should_not == nil
|
74
68
|
line1.desc.should == "PVR2920"
|
@@ -78,13 +72,13 @@ describe "Quickeebooks::Windows::Service::Invoice" do
|
|
78
72
|
line1.unit_price.should == 144.00
|
79
73
|
line1.quantity.should == 2.67
|
80
74
|
end
|
81
|
-
|
75
|
+
|
82
76
|
it "can create an invoice" do
|
83
|
-
xml =
|
77
|
+
xml = windowsFixture("invoice_success_create.xml")
|
84
78
|
service = Quickeebooks::Windows::Service::Invoice.new
|
85
79
|
service.access_token = @oauth
|
86
80
|
service.realm_id = @realm_id
|
87
|
-
|
81
|
+
|
88
82
|
model = Quickeebooks::Windows::Model::Invoice
|
89
83
|
FakeWeb.register_uri(:post, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
|
90
84
|
|
@@ -124,7 +118,7 @@ describe "Quickeebooks::Windows::Service::Invoice" do
|
|
124
118
|
invoice.header = header
|
125
119
|
|
126
120
|
created_invoice = service.create(invoice)
|
127
|
-
|
121
|
+
|
128
122
|
created_invoice.success?.should == true
|
129
123
|
created_invoice.success.object_ref.id.value.should == "9107908"
|
130
124
|
created_invoice.success.request_name.should == "InvoiceAdd"
|
@@ -1,9 +1,3 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
require "date"
|
6
|
-
|
7
1
|
describe "Quickeebooks::Windows::Service::Payment" do
|
8
2
|
before(:all) do
|
9
3
|
FakeWeb.allow_net_connect = false
|
@@ -20,27 +14,27 @@ describe "Quickeebooks::Windows::Service::Payment" do
|
|
20
14
|
})
|
21
15
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
22
16
|
end
|
23
|
-
|
17
|
+
|
24
18
|
it "can fetch a list of payments" do
|
25
|
-
xml =
|
19
|
+
xml = windowsFixture("payments.xml")
|
26
20
|
service = Quickeebooks::Windows::Service::Payment.new
|
27
21
|
service.access_token = @oauth
|
28
22
|
service.realm_id = @realm_id
|
29
|
-
|
23
|
+
|
30
24
|
model = Quickeebooks::Windows::Model::Payment
|
31
|
-
FakeWeb.register_uri(:
|
25
|
+
FakeWeb.register_uri(:post,
|
32
26
|
service.url_for_resource(model::REST_RESOURCE),
|
33
27
|
:status => ["200", "OK"],
|
34
28
|
:body => xml)
|
35
29
|
payments = service.list
|
36
30
|
payments.entries.count.should == 1
|
37
|
-
|
31
|
+
|
38
32
|
payment = payments.entries.first
|
39
33
|
payment.id.value.should == "4"
|
40
34
|
payment.header.should_not be_nil
|
41
35
|
header = payment.header
|
42
36
|
header.customer_name.should == "Davis"
|
43
|
-
|
37
|
+
|
44
38
|
line1 = payment.line_items.first
|
45
39
|
line1.should_not be_nil
|
46
40
|
line1.amount.should == header.total_amount
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Windows::Service::SalesRep" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -19,25 +14,25 @@ describe "Quickeebooks::Windows::Service::SalesRep" do
|
|
19
14
|
})
|
20
15
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
16
|
end
|
22
|
-
|
17
|
+
|
23
18
|
it "can fetch a list of sales reps" do
|
24
|
-
xml =
|
19
|
+
xml = windowsFixture("sales_reps.xml")
|
25
20
|
service = Quickeebooks::Windows::Service::SalesRep.new
|
26
21
|
service.access_token = @oauth
|
27
22
|
service.realm_id = @realm_id
|
28
|
-
|
23
|
+
|
29
24
|
model = Quickeebooks::Windows::Model::SalesRep
|
30
|
-
FakeWeb.register_uri(:
|
25
|
+
FakeWeb.register_uri(:post, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
|
31
26
|
reps = service.list
|
32
27
|
reps.entries.count.should == 10
|
33
|
-
|
28
|
+
|
34
29
|
lukas = reps.entries.detect { |sr| sr.id.value == "13" }
|
35
30
|
lukas.should_not == nil
|
36
31
|
lukas.external_key.value.should == "13"
|
37
32
|
lukas.initials.should == "LB"
|
38
33
|
lukas.vendor.vendor_id.value.should == "275"
|
39
34
|
lukas.vendor.vendor_name.should == "Lukas Billybob"
|
40
|
-
|
35
|
+
|
41
36
|
other_name = reps.entries.detect { |r| r.other_name? }
|
42
37
|
other_name.should_not == nil
|
43
38
|
other_name.other_name.other_name_id.value.should == "96"
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Windows::Service::SalesTax" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -19,23 +14,23 @@ describe "Quickeebooks::Windows::Service::SalesTax" do
|
|
19
14
|
})
|
20
15
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
16
|
end
|
22
|
-
|
17
|
+
|
23
18
|
it "can fetch a list of sales taxes" do
|
24
|
-
xml =
|
19
|
+
xml = windowsFixture("sales_taxes.xml")
|
25
20
|
model = Quickeebooks::Windows::Model::SalesTax
|
26
21
|
service = Quickeebooks::Windows::Service::SalesTax.new
|
27
22
|
service.access_token = @oauth
|
28
23
|
service.realm_id = @realm_id
|
29
|
-
FakeWeb.register_uri(:
|
24
|
+
FakeWeb.register_uri(:post, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
|
30
25
|
shipping_methods = service.list
|
31
26
|
shipping_methods.entries.count.should == 2
|
32
|
-
|
27
|
+
|
33
28
|
sf = shipping_methods.entries.detect { |sm| sm.name == "San Francisco County" }
|
34
29
|
sf.should_not == nil
|
35
30
|
sf.id.value.should == "80"
|
36
31
|
sf.desc.should == 'Sales Tax - San Francisco'
|
37
32
|
sf.tax_rate.should == 8.5
|
38
|
-
|
33
|
+
|
39
34
|
end
|
40
35
|
|
41
36
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
describe "Quickeebooks::Windows::Service::ServiceBase" do
|
2
|
+
before(:all) do
|
3
|
+
FakeWeb.allow_net_connect = false
|
4
|
+
qb_key = "key"
|
5
|
+
qb_secret = "secreet"
|
6
|
+
|
7
|
+
@realm_id = "9991111222"
|
8
|
+
@oauth_consumer = OAuth::Consumer.new(qb_key, qb_key, {
|
9
|
+
:site => "https://oauth.intuit.com",
|
10
|
+
:request_token_path => "/oauth/v1/get_request_token",
|
11
|
+
:authorize_path => "/oauth/v1/get_access_token",
|
12
|
+
:access_token_path => "/oauth/v1/get_access_token"
|
13
|
+
})
|
14
|
+
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
15
|
+
|
16
|
+
@service = Quickeebooks::Windows::Service::ServiceBase.new
|
17
|
+
@service.access_token = @oauth
|
18
|
+
@service.instance_eval {
|
19
|
+
@realm_id = "9991111222"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#fetch_collection" do
|
24
|
+
let(:default_params){ "<StartPage>1</StartPage><ChunkSize>20</ChunkSize>" }
|
25
|
+
|
26
|
+
before do
|
27
|
+
stub_const("Object::REST_RESOURCE", "foos")
|
28
|
+
stub_const("Object::XML_NODE", "Foo")
|
29
|
+
|
30
|
+
@url = @service.url_for_resource(Object::REST_RESOURCE)
|
31
|
+
end
|
32
|
+
|
33
|
+
def wrap_result(res)
|
34
|
+
%Q{<?xml version="1.0" encoding="utf-8"?>\n<FooQuery xmlns="http://www.intuit.com/sb/cdm/v2">#{res}</FooQuery>}
|
35
|
+
end
|
36
|
+
|
37
|
+
it "uses all default values" do
|
38
|
+
@service.should_receive(:do_http_post).with(@url,
|
39
|
+
wrap_result(default_params),
|
40
|
+
{},
|
41
|
+
{"Content-Type"=>"text/xml"})
|
42
|
+
|
43
|
+
@service.send(:fetch_collection, Object)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "queries arbitrary things" do
|
47
|
+
@service.should_receive(:do_http_post).with(@url,
|
48
|
+
wrap_result("#{default_params}<Something>42</Something>"),
|
49
|
+
{},
|
50
|
+
{"Content-Type"=>"text/xml"})
|
51
|
+
|
52
|
+
@service.send(:fetch_collection, Object, "<Something>42</Something>")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "filters" do
|
56
|
+
filter = Quickeebooks::Windows::Service::Filter.new(:boolean, :field => "IsPaid", :value => "true")
|
57
|
+
|
58
|
+
@service.should_receive(:do_http_post).with(@url,
|
59
|
+
wrap_result("<IsPaid>true</IsPaid>#{default_params}"),
|
60
|
+
{},
|
61
|
+
{"Content-Type"=>"text/xml"})
|
62
|
+
|
63
|
+
@service.send(:fetch_collection, Object, nil, [filter])
|
64
|
+
end
|
65
|
+
|
66
|
+
it "paginates" do
|
67
|
+
@service.should_receive(:do_http_post).with(@url,
|
68
|
+
wrap_result("<StartPage>2</StartPage><ChunkSize>20</ChunkSize>"),
|
69
|
+
{},
|
70
|
+
{"Content-Type"=>"text/xml"})
|
71
|
+
|
72
|
+
@service.send(:fetch_collection, Object, nil, nil, 2)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "changes per_page" do
|
76
|
+
@service.should_receive(:do_http_post).with(@url,
|
77
|
+
wrap_result("<StartPage>1</StartPage><ChunkSize>10</ChunkSize>"),
|
78
|
+
{},
|
79
|
+
{"Content-Type"=>"text/xml"})
|
80
|
+
|
81
|
+
@service.send(:fetch_collection, Object, nil, nil, 1, 10)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "sorts" do
|
85
|
+
sorter = Quickeebooks::Windows::Service::Sort.new('FamilyName', 'Ascending')
|
86
|
+
|
87
|
+
@service.should_receive(:do_http_post).with(@url,
|
88
|
+
wrap_result("#{default_params}<SortByColumn sortOrder=\"Ascending\">FamilyName</SortByColumn>"),
|
89
|
+
{},
|
90
|
+
{"Content-Type"=>"text/xml"})
|
91
|
+
|
92
|
+
@service.send(:fetch_collection, Object, nil, nil, 1, 20, sorter)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Windows::Service::ShipMethod" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -19,17 +14,17 @@ describe "Quickeebooks::Windows::Service::ShipMethod" do
|
|
19
14
|
})
|
20
15
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
16
|
end
|
22
|
-
|
17
|
+
|
23
18
|
it "can fetch a list of shipping methods" do
|
24
|
-
xml =
|
19
|
+
xml = windowsFixture("ship_methods.xml")
|
25
20
|
model = Quickeebooks::Windows::Model::ShipMethod
|
26
21
|
service = Quickeebooks::Windows::Service::ShipMethod.new
|
27
22
|
service.access_token = @oauth
|
28
23
|
service.realm_id = @realm_id
|
29
|
-
FakeWeb.register_uri(:
|
24
|
+
FakeWeb.register_uri(:post, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
|
30
25
|
shipping_methods = service.list
|
31
26
|
shipping_methods.entries.count.should == 15
|
32
|
-
|
27
|
+
|
33
28
|
vinlux = shipping_methods.entries.detect { |sm| sm.name == "Vinlux" }
|
34
29
|
vinlux.should_not == nil
|
35
30
|
vinlux.id.value.should == "13"
|
data/spec/quickeebooks_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
unless ENV['CI']
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start do
|
5
|
+
add_filter 'spec'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
1
9
|
require "rubygems"
|
2
10
|
require "rspec"
|
11
|
+
require "fakeweb"
|
12
|
+
require "oauth"
|
3
13
|
|
4
14
|
$:.unshift "lib"
|
15
|
+
require 'quickeebooks'
|
5
16
|
|
6
17
|
def mock_error(subject, message)
|
7
18
|
mock_exit do
|
@@ -10,11 +21,29 @@ def mock_error(subject, message)
|
|
10
21
|
end
|
11
22
|
end
|
12
23
|
|
24
|
+
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
|
25
|
+
|
13
26
|
def mock_exit(&block)
|
14
27
|
block.should raise_error(SystemExit)
|
15
28
|
end
|
16
29
|
|
17
30
|
RSpec.configure do |config|
|
18
31
|
config.color_enabled = true
|
19
|
-
config.mock_with :rr
|
20
32
|
end
|
33
|
+
|
34
|
+
def fixture_path
|
35
|
+
File.expand_path("../xml", __FILE__)
|
36
|
+
end
|
37
|
+
|
38
|
+
def onlineFixture(file)
|
39
|
+
File.new(fixture_path + '/online/' + file).read
|
40
|
+
end
|
41
|
+
|
42
|
+
def sharedFixture(file)
|
43
|
+
File.new(fixture_path + '/shared/' + file).read
|
44
|
+
end
|
45
|
+
|
46
|
+
def windowsFixture(file)
|
47
|
+
File.new(fixture_path + '/windows/' + file).read
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
def construct_oauth_service(model)
|
3
|
+
FakeWeb.allow_net_connect = false
|
4
|
+
qb_key = "key"
|
5
|
+
qb_secret = "secreet"
|
6
|
+
@realm_id = "9991111222"
|
7
|
+
@oauth_consumer = OAuth::Consumer.new(qb_key, qb_key, {
|
8
|
+
:site => "https://oauth.intuit.com",
|
9
|
+
:request_token_path => "/oauth/v1/get_request_token",
|
10
|
+
:authorize_path => "/oauth/v1/get_access_token",
|
11
|
+
:access_token_path => "/oauth/v1/get_access_token"
|
12
|
+
})
|
13
|
+
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
14
|
+
|
15
|
+
@service = "Quickeebooks::Online::Service::#{model.to_s.capitalize}".constantize.new
|
16
|
+
@service.access_token = @oauth
|
17
|
+
@service.instance_eval {
|
18
|
+
@realm_id = "9991111222"
|
19
|
+
}
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Bill xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2">
|
3
|
+
<Id>56</Id>
|
4
|
+
<SyncToken>0</SyncToken>
|
5
|
+
<MetaData>
|
6
|
+
<CreateTime>2010-09-13T21:40:41-07:00</CreateTime>
|
7
|
+
<LastUpdatedTime>2010-09-13T21:40:41-07:00</LastUpdatedTime>
|
8
|
+
</MetaData>
|
9
|
+
<Header>
|
10
|
+
<DocNumber>2004</DocNumber>
|
11
|
+
<TxnDate>2010-08-06</TxnDate>
|
12
|
+
<Msg>4 Pens</Msg>
|
13
|
+
<VendorId>7</VendorId>
|
14
|
+
<VendorName>Digital</VendorName>
|
15
|
+
<TotalAmt>50</TotalAmt>
|
16
|
+
<SalesTermId>5</SalesTermId>
|
17
|
+
<SalesTermName>Due before receipt</SalesTermName>
|
18
|
+
<DueDate>2010-08-11</DueDate>
|
19
|
+
</Header>
|
20
|
+
<Line>
|
21
|
+
<Desc>Pens</Desc>
|
22
|
+
<Amount>25</Amount>
|
23
|
+
<BillableStatus>NotBillable</BillableStatus>
|
24
|
+
<Qty>5</Qty>
|
25
|
+
<UnitPrice>5</UnitPrice>
|
26
|
+
<ItemId>2</ItemId>
|
27
|
+
<ReimbursableInfo>
|
28
|
+
<CustomerId>5</CustomerId>
|
29
|
+
<CustomerName>2</CustomerName>
|
30
|
+
</ReimbursableInfo>
|
31
|
+
</Line>
|
32
|
+
</Bill>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Bill xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2">
|
3
|
+
<Id>96</Id>
|
4
|
+
<SyncToken>1</SyncToken>
|
5
|
+
<MetaData>
|
6
|
+
<CreateTime>2010-09-13T21:40:41-07:00</CreateTime>
|
7
|
+
<LastUpdatedTime>2010-09-13T21:40:41-07:00</LastUpdatedTime>
|
8
|
+
</MetaData>
|
9
|
+
<Header>
|
10
|
+
<DocNumber>2004</DocNumber>
|
11
|
+
<TxnDate>2010-08-06</TxnDate>
|
12
|
+
<Msg>3 Pens</Msg>
|
13
|
+
<VendorId>7</VendorId>
|
14
|
+
<VendorName>Digital</VendorName>
|
15
|
+
<TotalAmt>75</TotalAmt>
|
16
|
+
<SalesTermId>5</SalesTermId>
|
17
|
+
<SalesTermName>Due before receipt</SalesTermName>
|
18
|
+
<DueDate>2010-08-11</DueDate>
|
19
|
+
</Header>
|
20
|
+
<Line>
|
21
|
+
<Desc>Pens</Desc>
|
22
|
+
<Amount>25</Amount>
|
23
|
+
<BillableStatus>NotBillable</BillableStatus>
|
24
|
+
<Qty>3</Qty>
|
25
|
+
<UnitPrice>5</UnitPrice>
|
26
|
+
<ItemId>2</ItemId>
|
27
|
+
<ReimbursableInfo>
|
28
|
+
<CustomerId>5</CustomerId>
|
29
|
+
<CustomerName>2</CustomerName>
|
30
|
+
</ReimbursableInfo>
|
31
|
+
</Line>
|
32
|
+
</Bill>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<qbo:SearchResults xmlns:qbo="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1">
|
3
|
+
<qbo:CdmCollections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Bills">
|
4
|
+
<Bill>
|
5
|
+
<Id>56</Id>
|
6
|
+
<SyncToken>1</SyncToken>
|
7
|
+
<MetaData>
|
8
|
+
<CreateTime>2010-09-13T21:40:41-07:00</CreateTime>
|
9
|
+
<LastUpdatedTime>2010-09-13T21:44:43-07:00</LastUpdatedTime>
|
10
|
+
</MetaData>
|
11
|
+
<Header>
|
12
|
+
<DocNumber>2004</DocNumber>
|
13
|
+
<TxnDate>2010-08-06-07:00</TxnDate>
|
14
|
+
<VendorId>7</VendorId>
|
15
|
+
<TotalAmt>25.00</TotalAmt>
|
16
|
+
<SalesTermId>5</SalesTermId>
|
17
|
+
<DueDate>2010-08-11-07:00</DueDate>
|
18
|
+
<Balance>25.00</Balance>
|
19
|
+
</Header>
|
20
|
+
<Line>
|
21
|
+
<Id>1</Id>
|
22
|
+
<Desc>Pens</Desc>
|
23
|
+
<Amount>25.00</Amount>
|
24
|
+
<ItemId>2</ItemId>
|
25
|
+
<UnitPrice>5</UnitPrice>
|
26
|
+
<Qty>7</Qty>
|
27
|
+
<AccountId>30</AccountId>
|
28
|
+
</Line>
|
29
|
+
</Bill>
|
30
|
+
</qbo:CdmCollections>
|
31
|
+
<qbo:Count>1</qbo:Count>
|
32
|
+
<qbo:CurrentPage>1</qbo:CurrentPage>
|
33
|
+
</qbo:SearchResults>
|
data/spec/xml/online/payment.xml
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<Payment xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:ns2="http://www.intuit.com/sb/cdm/qbopayroll/v1"
|
3
|
+
xmlns:ns3="http://www.intuit.com/sb/cdm/qbo">
|
4
|
+
<Id>50</Id>
|
5
|
+
<SyncToken>2</SyncToken>
|
6
|
+
<MetaData>
|
7
|
+
<CreateTime>2010-09-14T05:33:24-07:00</CreateTime>
|
8
|
+
<LastUpdatedTime>2010-09-14T05:33:24-07:00</LastUpdatedTime>
|
9
|
+
</MetaData>
|
10
|
+
<Header>
|
11
|
+
<DocNumber>84</DocNumber>
|
12
|
+
<TxnDate>2010-08-09-07:00</TxnDate>
|
13
|
+
<Note>Payment against Invoice</Note>
|
14
|
+
<CustomerId>7</CustomerId>
|
15
|
+
<DepositToAccountId>41</DepositToAccountId>
|
16
|
+
<PaymentMethodId>1</PaymentMethodId>
|
17
|
+
<TotalAmt>50.00</TotalAmt>
|
18
|
+
<ProcessPayment>false</ProcessPayment>
|
19
|
+
</Header>
|
20
|
+
<Line>
|
21
|
+
<Amount>50.00</Amount>
|
22
|
+
<TxnId>18</TxnId>
|
23
|
+
</Line>
|
24
|
+
</Payment>
|