taxjar-ruby 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +212 -212
- data/lib/taxjar/breakdown.rb +23 -0
- data/lib/taxjar/breakdown_line_item.rb +18 -0
- data/lib/taxjar/shipping.rb +26 -5
- data/lib/taxjar/version.rb +1 -1
- data/spec/fixtures/taxes.json +36 -12
- data/spec/fixtures/taxes_canada.json +57 -0
- data/spec/fixtures/taxes_international.json +39 -0
- data/spec/taxjar/api/api_spec.rb +146 -5
- data/taxjar-ruby.gemspec +3 -3
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b7aa7c93c3a6dc05ffd13a0d6efd955033d841e
|
4
|
+
data.tar.gz: 1ef818356db3fb21e1b94bb6342ffae716eef57e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cfe6ce5a86c1b2a4995152b76cbb016d3b64b3807f62fade7ee9b3dd8dd0f90aadf90116cf3a95131735b51d9efb3d50e6b98ee60bf313fe159047c99be10e4
|
7
|
+
data.tar.gz: 7240aad485c2d64e7ed8a1e5cf819c7837db1862c699f29991e567430ece0e102021353ff3cbbe4529905bb57508716d4216452a3d5b7cb1e143a7c0da81b19c
|
data/README.md
CHANGED
@@ -72,19 +72,19 @@ client.categories
|
|
72
72
|
```ruby
|
73
73
|
[
|
74
74
|
#<Taxjar::Category:0x007f081dc3e278 @attrs={
|
75
|
-
:name =>
|
75
|
+
:name => 'Digital Goods',
|
76
76
|
:product_tax_code => 31000,
|
77
|
-
:description =>
|
77
|
+
:description => 'Digital products transferred electronically.'
|
78
78
|
}>,
|
79
79
|
#<Taxjar::Category:0x007f081dc3de90 @attrs={
|
80
|
-
:name =>
|
80
|
+
:name => 'Clothing',
|
81
81
|
:product_tax_code => 20010,
|
82
|
-
:description =>
|
82
|
+
:description => 'All human wearing apparel suitable for general use'
|
83
83
|
}>,
|
84
84
|
#<Taxjar::Category:0x007f081dc3da80 @attrs={
|
85
|
-
:name =>
|
85
|
+
:name => 'Non-Prescription',
|
86
86
|
:product_tax_code => 51010,
|
87
|
-
:description =>
|
87
|
+
:description => 'Drugs for human use without a prescription'
|
88
88
|
}>
|
89
89
|
]
|
90
90
|
```
|
@@ -128,29 +128,29 @@ rates = client.rates_for_location('00150', {
|
|
128
128
|
|
129
129
|
```ruby
|
130
130
|
#<Taxjar::Rate:0x007fc47056a928 @attrs={
|
131
|
-
:zip =>
|
132
|
-
:state =>
|
131
|
+
:zip => '90002',
|
132
|
+
:state => 'CA',
|
133
133
|
:state_rate => 0.065,
|
134
|
-
:county =>
|
134
|
+
:county => 'LOS ANGELES',
|
135
135
|
:county_rate => 0.01,
|
136
|
-
:city =>
|
136
|
+
:city => 'WATTS',
|
137
137
|
:city_rate => 0,
|
138
138
|
:combined_district_rate => 0.015,
|
139
139
|
:combined_rate => 0.09
|
140
140
|
}>
|
141
141
|
|
142
142
|
#<Taxjar::Rate:0x007fc47056a928 @attrs={
|
143
|
-
:zip =>
|
144
|
-
:city =>
|
145
|
-
:state =>
|
146
|
-
:country =>
|
147
|
-
:combined_rate =>
|
143
|
+
:zip => 'V5K0A1',
|
144
|
+
:city => 'Vancouver',
|
145
|
+
:state => 'BC',
|
146
|
+
:country => 'CA',
|
147
|
+
:combined_rate => '0.12'
|
148
148
|
}>
|
149
149
|
|
150
150
|
#<Taxjar::Rate:0x007fc47056a928 @attrs={
|
151
|
-
:country =>
|
152
|
-
:name =>
|
153
|
-
:standard_rate =>
|
151
|
+
:country => 'FI',
|
152
|
+
:name => 'Finland',
|
153
|
+
:standard_rate => '0.24',
|
154
154
|
:reduced_rate => nil,
|
155
155
|
:super_reduced_rate => nil,
|
156
156
|
:parking_rate => nil,
|
@@ -181,7 +181,7 @@ client.tax_for_order({
|
|
181
181
|
:from_country => 'US',
|
182
182
|
:from_zip => '92093',
|
183
183
|
:from_city => 'San Diego',
|
184
|
-
:amount => 15
|
184
|
+
:amount => 15,
|
185
185
|
:shipping => 1.5,
|
186
186
|
:nexus_addresses => [{:address_id => 1,
|
187
187
|
:country => 'US',
|
@@ -190,7 +190,7 @@ client.tax_for_order({
|
|
190
190
|
:city => 'Santa Barbara',
|
191
191
|
:street => '1218 State St.'}],
|
192
192
|
:line_items => [{:quantity => 1,
|
193
|
-
:unit_price => 15
|
193
|
+
:unit_price => 15,
|
194
194
|
:product_tax_code => 20010}]
|
195
195
|
})
|
196
196
|
```
|
@@ -203,26 +203,26 @@ client.tax_for_order({
|
|
203
203
|
:amount_to_collect => 1.35,
|
204
204
|
:has_nexus => true,
|
205
205
|
:freight_taxable => false,
|
206
|
-
:tax_source =>
|
206
|
+
:tax_source => 'destination',
|
207
207
|
:breakdown => {
|
208
|
-
:state_taxable_amount => 15
|
208
|
+
:state_taxable_amount => 15,
|
209
209
|
:state_tax_collectable => 0.98,
|
210
|
-
:county_taxable_amount => 15
|
210
|
+
:county_taxable_amount => 15,
|
211
211
|
:county_tax_collectable => 0.15,
|
212
|
-
:city_taxable_amount => 0
|
213
|
-
:city_tax_collectable => 0
|
214
|
-
:special_district_taxable_amount => 15
|
212
|
+
:city_taxable_amount => 0,
|
213
|
+
:city_tax_collectable => 0,
|
214
|
+
:special_district_taxable_amount => 15,
|
215
215
|
:special_district_tax_collectable => 0.22,
|
216
216
|
:line_items => [
|
217
217
|
{
|
218
218
|
:id => 1,
|
219
|
-
:state_taxable_amount => 15
|
219
|
+
:state_taxable_amount => 15,
|
220
220
|
:state_sales_tax_rate => 0.065,
|
221
|
-
:county_taxable_amount => 15
|
221
|
+
:county_taxable_amount => 15,
|
222
222
|
:county_tax_rate => 0.01,
|
223
|
-
:city_taxable_amount => 0
|
224
|
-
:city_tax_rate => 0
|
225
|
-
:special_district_taxable_amount => 15
|
223
|
+
:city_taxable_amount => 0,
|
224
|
+
:city_tax_rate => 0,
|
225
|
+
:special_district_taxable_amount => 15,
|
226
226
|
:special_tax_rate => 0.015
|
227
227
|
}
|
228
228
|
]
|
@@ -237,7 +237,7 @@ client.tax_for_order({
|
|
237
237
|
:rate => 0.2,
|
238
238
|
:has_nexus => true,
|
239
239
|
:freight_taxable => true,
|
240
|
-
:tax_source =>
|
240
|
+
:tax_source => 'origin'
|
241
241
|
}>
|
242
242
|
```
|
243
243
|
|
@@ -286,33 +286,33 @@ client.show_order('123')
|
|
286
286
|
|
287
287
|
```ruby
|
288
288
|
#<Taxjar::Order:0x007fd3e514a940 @attrs={
|
289
|
-
:transaction_id =>
|
289
|
+
:transaction_id => '123',
|
290
290
|
:user_id => 11836,
|
291
|
-
:transaction_date =>
|
291
|
+
:transaction_date => '2015-05-14T00:00:00Z',
|
292
292
|
:transaction_reference_id => nil,
|
293
|
-
:from_country =>
|
293
|
+
:from_country => 'US',
|
294
294
|
:from_zip => 93107,
|
295
|
-
:from_state =>
|
296
|
-
:from_city =>
|
297
|
-
:from_street =>
|
298
|
-
:to_country =>
|
295
|
+
:from_state => 'CA',
|
296
|
+
:from_city => 'SANTA BARBARA',
|
297
|
+
:from_street => '1281 State St',
|
298
|
+
:to_country => 'US',
|
299
299
|
:to_zip => 90002,
|
300
|
-
:to_state =>
|
301
|
-
:to_city =>
|
302
|
-
:to_street =>
|
303
|
-
:amount => 17
|
300
|
+
:to_state => 'CA',
|
301
|
+
:to_city => 'LOS ANGELES',
|
302
|
+
:to_street => '123 Palm Grove Ln',
|
303
|
+
:amount => 17,
|
304
304
|
:shipping => 2,
|
305
305
|
:sales_tax => 0.95,
|
306
306
|
:line_items => [
|
307
307
|
{
|
308
308
|
:id => 1,
|
309
309
|
:quantity => 1,
|
310
|
-
:product_identifier =>
|
310
|
+
:product_identifier => '12-34243-0',
|
311
311
|
:product_tax_code => nil,
|
312
|
-
:description =>
|
313
|
-
:unit_price =>
|
314
|
-
:discount =>
|
315
|
-
:sales_tax =>
|
312
|
+
:description => 'Heavy Widget',
|
313
|
+
:unit_price => 15,
|
314
|
+
:discount => 0,
|
315
|
+
:sales_tax => 0.95
|
316
316
|
}
|
317
317
|
]
|
318
318
|
}>
|
@@ -345,13 +345,13 @@ order = client.create_order({
|
|
345
345
|
:to_city => 'Los Angeles',
|
346
346
|
:to_street => '123 Palm Grove Ln',
|
347
347
|
:to_zip => '90002',
|
348
|
-
:amount =>
|
348
|
+
:amount => 16.5,
|
349
349
|
:shipping => 1.5,
|
350
350
|
:sales_tax => 0.95,
|
351
351
|
:line_items => [{:quantity => 1,
|
352
352
|
:product_identifier => '12-34243-9',
|
353
353
|
:description => 'Fuzzy Widget',
|
354
|
-
:unit_price => 15
|
354
|
+
:unit_price => 15,
|
355
355
|
:sales_tax => 0.95}]
|
356
356
|
})
|
357
357
|
```
|
@@ -360,33 +360,33 @@ order = client.create_order({
|
|
360
360
|
|
361
361
|
```ruby
|
362
362
|
#<Taxjar::Order:0x007f6d65b252d0 @attrs={
|
363
|
-
:transaction_id =>
|
363
|
+
:transaction_id => '20',
|
364
364
|
:user_id => 11836,
|
365
|
-
:transaction_date =>
|
365
|
+
:transaction_date => '2015-05-14T00:00:00Z',
|
366
366
|
:transaction_reference_id => nil,
|
367
|
-
:from_country =>
|
367
|
+
:from_country => 'US',
|
368
368
|
:from_zip => 93101,
|
369
|
-
:from_state =>
|
370
|
-
:from_city =>
|
371
|
-
:from_street =>
|
372
|
-
:to_country =>
|
369
|
+
:from_state => 'CA',
|
370
|
+
:from_city => 'SANTA BARBARA',
|
371
|
+
:from_street => '1218 State St',
|
372
|
+
:to_country => 'US',
|
373
373
|
:to_zip => 90002,
|
374
|
-
:to_state =>
|
375
|
-
:to_city =>
|
376
|
-
:to_street =>
|
377
|
-
:amount =>
|
374
|
+
:to_state => 'CA',
|
375
|
+
:to_city => 'LOS ANGELES',
|
376
|
+
:to_street => '123 Palm Grove Ln',
|
377
|
+
:amount => 16.5,
|
378
378
|
:shipping => 1.5,
|
379
379
|
:sales_tax => 0.95,
|
380
380
|
:line_items => [
|
381
381
|
{
|
382
382
|
:id => 1,
|
383
383
|
:quantity => 1,
|
384
|
-
:product_identifier =>
|
384
|
+
:product_identifier => '12-34243-9',
|
385
385
|
:product_tax_code => nil,
|
386
|
-
:description =>
|
387
|
-
:unit_price =>
|
388
|
-
:discount =>
|
389
|
-
:sales_tax =>
|
386
|
+
:description => 'Fuzzy Widget',
|
387
|
+
:unit_price => 15,
|
388
|
+
:discount => 0,
|
389
|
+
:sales_tax => 0.95
|
390
390
|
}
|
391
391
|
]
|
392
392
|
}>
|
@@ -408,13 +408,13 @@ client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')
|
|
408
408
|
|
409
409
|
order = client.update_order({
|
410
410
|
:transaction_id => '123',
|
411
|
-
:amount => 17
|
412
|
-
:shipping => 2
|
411
|
+
:amount => 17,
|
412
|
+
:shipping => 2,
|
413
413
|
:line_items => [{:quantity => 1,
|
414
414
|
:product_identifier => '12-34243-0',
|
415
415
|
:description => 'Heavy Widget',
|
416
|
-
:unit_price => 15
|
417
|
-
:discount => 0
|
416
|
+
:unit_price => 15,
|
417
|
+
:discount => 0,
|
418
418
|
:sales_tax => 0.95}]
|
419
419
|
})
|
420
420
|
```
|
@@ -423,33 +423,33 @@ order = client.update_order({
|
|
423
423
|
|
424
424
|
```ruby
|
425
425
|
#<Taxjar::Order:0x007f6d65b252d0 @attrs={
|
426
|
-
:transaction_id =>
|
426
|
+
:transaction_id => '123',
|
427
427
|
:user_id => 11836,
|
428
|
-
:transaction_date =>
|
428
|
+
:transaction_date => '2015-05-14T00:00:00Z',
|
429
429
|
:transaction_reference_id => nil,
|
430
|
-
:from_country =>
|
430
|
+
:from_country => 'US',
|
431
431
|
:from_zip => 93101,
|
432
|
-
:from_state =>
|
433
|
-
:from_city =>
|
434
|
-
:from_street =>
|
435
|
-
:to_country =>
|
432
|
+
:from_state => 'CA',
|
433
|
+
:from_city => 'SANTA BARBARA',
|
434
|
+
:from_street => '1218 State St',
|
435
|
+
:to_country => 'US',
|
436
436
|
:to_zip => 90002,
|
437
|
-
:to_state =>
|
438
|
-
:to_city =>
|
439
|
-
:to_street =>
|
440
|
-
:amount => 17
|
441
|
-
:shipping => 2
|
437
|
+
:to_state => 'CA',
|
438
|
+
:to_city => 'LOS ANGELES',
|
439
|
+
:to_street => '123 Palm Grove Ln',
|
440
|
+
:amount => 17,
|
441
|
+
:shipping => 2,
|
442
442
|
:sales_tax => 0.95,
|
443
443
|
:line_items => [
|
444
444
|
{
|
445
445
|
:id => 1,
|
446
446
|
:quantity => 1,
|
447
|
-
:product_identifier =>
|
447
|
+
:product_identifier => '12-34243-0',
|
448
448
|
:product_tax_code => nil,
|
449
|
-
:description =>
|
450
|
-
:unit_price =>
|
451
|
-
:discount =>
|
452
|
-
:sales_tax =>
|
449
|
+
:description => 'Heavy Widget',
|
450
|
+
:unit_price => 15,
|
451
|
+
:discount => 0,
|
452
|
+
:sales_tax => 0.95
|
453
453
|
}
|
454
454
|
]
|
455
455
|
}>
|
@@ -476,33 +476,33 @@ client.delete_order(123)
|
|
476
476
|
|
477
477
|
```ruby
|
478
478
|
#<Taxjar::Order:0x007f6d65b252d0 @attrs={
|
479
|
-
:transaction_id =>
|
479
|
+
:transaction_id => '123',
|
480
480
|
:user_id => 11836,
|
481
|
-
:transaction_date =>
|
481
|
+
:transaction_date => '2015-05-14T00:00:00Z',
|
482
482
|
:transaction_reference_id => nil,
|
483
|
-
:from_country =>
|
483
|
+
:from_country => 'US',
|
484
484
|
:from_zip => 93101,
|
485
|
-
:from_state =>
|
486
|
-
:from_city =>
|
487
|
-
:from_street =>
|
488
|
-
:to_country =>
|
485
|
+
:from_state => 'CA',
|
486
|
+
:from_city => 'SANTA BARBARA',
|
487
|
+
:from_street => '1218 State St',
|
488
|
+
:to_country => 'US',
|
489
489
|
:to_zip => 90002,
|
490
|
-
:to_state =>
|
491
|
-
:to_city =>
|
492
|
-
:to_street =>
|
493
|
-
:amount => 17
|
494
|
-
:shipping => 2
|
490
|
+
:to_state => 'CA',
|
491
|
+
:to_city => 'LOS ANGELES',
|
492
|
+
:to_street => '123 Palm Grove Ln',
|
493
|
+
:amount => 17,
|
494
|
+
:shipping => 2,
|
495
495
|
:sales_tax => 0.95,
|
496
496
|
:line_items => [
|
497
497
|
{
|
498
498
|
:id => 1,
|
499
499
|
:quantity => 1,
|
500
|
-
:product_identifier =>
|
500
|
+
:product_identifier => '12-34243-0',
|
501
501
|
:product_tax_code => nil,
|
502
|
-
:description =>
|
503
|
-
:unit_price =>
|
504
|
-
:discount =>
|
505
|
-
:sales_tax =>
|
502
|
+
:description => 'Heavy Widget',
|
503
|
+
:unit_price => 15,
|
504
|
+
:discount => 0,
|
505
|
+
:sales_tax => 0.95
|
506
506
|
}
|
507
507
|
]
|
508
508
|
}>
|
@@ -553,33 +553,33 @@ client.show_refund('321')
|
|
553
553
|
|
554
554
|
```ruby
|
555
555
|
#<Taxjar::Refund:0x007f6da40e33a0 @attrs={
|
556
|
-
:transaction_id =>
|
556
|
+
:transaction_id => '321',
|
557
557
|
:user_id => 11836,
|
558
|
-
:transaction_date =>
|
558
|
+
:transaction_date => '2015-06-14T00:00:00Z',
|
559
559
|
:transaction_reference_id => 123,
|
560
|
-
:from_country =>
|
560
|
+
:from_country => 'US',
|
561
561
|
:from_zip => 93107,
|
562
|
-
:from_state =>
|
563
|
-
:from_city =>
|
564
|
-
:from_street =>
|
565
|
-
:to_country =>
|
562
|
+
:from_state => 'CA',
|
563
|
+
:from_city => 'SANTA BARBARA',
|
564
|
+
:from_street => '1218 State St',
|
565
|
+
:to_country => 'US',
|
566
566
|
:to_zip => 90002,
|
567
|
-
:to_state =>
|
568
|
-
:to_city =>
|
569
|
-
:to_street =>
|
570
|
-
:amount => 17
|
571
|
-
:shipping => 2
|
567
|
+
:to_state => 'CA',
|
568
|
+
:to_city => 'LOS ANGELES',
|
569
|
+
:to_street => '123 Palm Grove Ln',
|
570
|
+
:amount => 17,
|
571
|
+
:shipping => 2,
|
572
572
|
:sales_tax => 0.95,
|
573
573
|
:line_items => [
|
574
574
|
{
|
575
575
|
:id => 1,
|
576
576
|
:quantity => 1,
|
577
|
-
:product_identifier =>
|
577
|
+
:product_identifier => '12-34243-0',
|
578
578
|
:product_tax_code => nil,
|
579
|
-
:description =>
|
580
|
-
:unit_price =>
|
581
|
-
:discount =>
|
582
|
-
:sales_tax =>
|
579
|
+
:description => 'Heavy Widget',
|
580
|
+
:unit_price => 15,
|
581
|
+
:discount => 0,
|
582
|
+
:sales_tax => 0.95
|
583
583
|
}
|
584
584
|
]
|
585
585
|
}>
|
@@ -613,13 +613,13 @@ refund = client.create_refund({
|
|
613
613
|
:to_state => 'CA',
|
614
614
|
:to_city => 'Los Angeles',
|
615
615
|
:to_street => '123 Palm Grove Ln',
|
616
|
-
:amount =>
|
616
|
+
:amount => 16.5,
|
617
617
|
:shipping => 1.5,
|
618
618
|
:sales_tax => 0.95,
|
619
619
|
:line_items => [{:quantity => 1,
|
620
620
|
:product_identifier => '12-34243-9',
|
621
621
|
:description => 'Fuzzy Widget',
|
622
|
-
:unit_price => 15
|
622
|
+
:unit_price => 15,
|
623
623
|
:sales_tax => 0.95}]
|
624
624
|
})
|
625
625
|
```
|
@@ -628,33 +628,33 @@ refund = client.create_refund({
|
|
628
628
|
|
629
629
|
```ruby
|
630
630
|
#<Taxjar::Refund:0x007f6da40e33a0 @attrs={
|
631
|
-
:transaction_id =>
|
631
|
+
:transaction_id => '321',
|
632
632
|
:user_id => 11836,
|
633
|
-
:transaction_date =>
|
634
|
-
:transaction_reference_id =>
|
635
|
-
:from_country =>
|
633
|
+
:transaction_date => '2015-06-14T00:00:00Z',
|
634
|
+
:transaction_reference_id => '123',
|
635
|
+
:from_country => 'US',
|
636
636
|
:from_zip => 93107,
|
637
|
-
:from_state =>
|
638
|
-
:from_city =>
|
639
|
-
:from_street =>
|
640
|
-
:to_country =>
|
637
|
+
:from_state => 'CA',
|
638
|
+
:from_city => 'SANTA BARBARA',
|
639
|
+
:from_street => '1218 State St',
|
640
|
+
:to_country => 'US',
|
641
641
|
:to_zip => 90002,
|
642
|
-
:to_state =>
|
643
|
-
:to_city =>
|
644
|
-
:to_street =>
|
645
|
-
:amount =>
|
646
|
-
:shipping =>
|
642
|
+
:to_state => 'CA',
|
643
|
+
:to_city => 'LOS ANGELES',
|
644
|
+
:to_street => '123 Palm Grove Ln',
|
645
|
+
:amount => 16.5,
|
646
|
+
:shipping => 1.5,
|
647
647
|
:sales_tax => 0.95,
|
648
648
|
:line_items => [
|
649
649
|
{
|
650
650
|
:id => 1,
|
651
651
|
:quantity => 1,
|
652
|
-
:product_identifier =>
|
652
|
+
:product_identifier => '12-34243-0',
|
653
653
|
:product_tax_code => nil,
|
654
|
-
:description =>
|
655
|
-
:unit_price =>
|
656
|
-
:discount =>
|
657
|
-
:sales_tax =>
|
654
|
+
:description => 'Heavy Widget',
|
655
|
+
:unit_price => 15,
|
656
|
+
:discount => 0,
|
657
|
+
:sales_tax => 0.95
|
658
658
|
}
|
659
659
|
]
|
660
660
|
}>
|
@@ -676,13 +676,13 @@ client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')
|
|
676
676
|
|
677
677
|
refund = client.update_refund({
|
678
678
|
:transaction_id => '321',
|
679
|
-
:amount => 17
|
680
|
-
:shipping => 2
|
679
|
+
:amount => 17,
|
680
|
+
:shipping => 2,
|
681
681
|
:sales_tax => 0.95,
|
682
682
|
:line_items => [{:quantity => 1,
|
683
683
|
:product_identifier => '12-34243-9',
|
684
684
|
:description => 'Heavy Widget',
|
685
|
-
:unit_price => 15
|
685
|
+
:unit_price => 15,
|
686
686
|
:sales_tax => 0.95}]
|
687
687
|
})
|
688
688
|
```
|
@@ -691,33 +691,33 @@ refund = client.update_refund({
|
|
691
691
|
|
692
692
|
```ruby
|
693
693
|
#<Taxjar::Refund:0x007f6da40e33a0 @attrs={
|
694
|
-
:transaction_id =>
|
694
|
+
:transaction_id => '321',
|
695
695
|
:user_id => 11836,
|
696
|
-
:transaction_date =>
|
697
|
-
:transaction_reference_id =>
|
698
|
-
:from_country =>
|
696
|
+
:transaction_date => '2015-06-14T00:00:00Z',
|
697
|
+
:transaction_reference_id => '123',
|
698
|
+
:from_country => 'US',
|
699
699
|
:from_zip => 93107,
|
700
|
-
:from_state =>
|
701
|
-
:from_city =>
|
702
|
-
:from_street =>
|
703
|
-
:to_country =>
|
700
|
+
:from_state => 'CA',
|
701
|
+
:from_city => 'SANTA BARBARA',
|
702
|
+
:from_street => '1218 State St',
|
703
|
+
:to_country => 'US',
|
704
704
|
:to_zip => 90002,
|
705
|
-
:to_state =>
|
706
|
-
:to_city =>
|
707
|
-
:to_street =>
|
705
|
+
:to_state => 'CA',
|
706
|
+
:to_city => 'LOS ANGELES',
|
707
|
+
:to_street => '123 Palm Grove Ln',
|
708
708
|
:amount => 17.95,
|
709
|
-
:shipping => 2
|
709
|
+
:shipping => 2,
|
710
710
|
:sales_tax => 0.95,
|
711
711
|
:line_items => [
|
712
712
|
{
|
713
713
|
:id => 1,
|
714
714
|
:quantity => 1,
|
715
|
-
:product_identifier =>
|
715
|
+
:product_identifier => '12-34243-9',
|
716
716
|
:product_tax_code => nil,
|
717
|
-
:description =>
|
718
|
-
:unit_price =>
|
719
|
-
:discount =>
|
720
|
-
:sales_tax =>
|
717
|
+
:description => 'Heavy Widget',
|
718
|
+
:unit_price => 15,
|
719
|
+
:discount => 0,
|
720
|
+
:sales_tax => 0.95
|
721
721
|
}
|
722
722
|
]
|
723
723
|
}>
|
@@ -744,33 +744,33 @@ client.delete_refund(321)
|
|
744
744
|
|
745
745
|
```ruby
|
746
746
|
#<Taxjar::Refund:0x007f6da40e33a0 @attrs={
|
747
|
-
:transaction_id =>
|
747
|
+
:transaction_id => '321',
|
748
748
|
:user_id => 11836,
|
749
|
-
:transaction_date =>
|
750
|
-
:transaction_reference_id =>
|
751
|
-
:from_country =>
|
749
|
+
:transaction_date => '2015-06-14T00:00:00Z',
|
750
|
+
:transaction_reference_id => '123',
|
751
|
+
:from_country => 'US',
|
752
752
|
:from_zip => 93107,
|
753
|
-
:from_state =>
|
754
|
-
:from_city =>
|
755
|
-
:from_street =>
|
756
|
-
:to_country =>
|
753
|
+
:from_state => 'CA',
|
754
|
+
:from_city => 'SANTA BARBARA',
|
755
|
+
:from_street => '1218 State St',
|
756
|
+
:to_country => 'US',
|
757
757
|
:to_zip => 90002,
|
758
|
-
:to_state =>
|
759
|
-
:to_city =>
|
760
|
-
:to_street =>
|
758
|
+
:to_state => 'CA',
|
759
|
+
:to_city => 'LOS ANGELES',
|
760
|
+
:to_street => '123 Palm Grove Ln',
|
761
761
|
:amount => 17.95,
|
762
|
-
:shipping => 2
|
762
|
+
:shipping => 2,
|
763
763
|
:sales_tax => 0.95,
|
764
764
|
:line_items => [
|
765
765
|
{
|
766
766
|
:id => 1,
|
767
767
|
:quantity => 1,
|
768
|
-
:product_identifier =>
|
768
|
+
:product_identifier => '12-34243-9',
|
769
769
|
:product_tax_code => nil,
|
770
|
-
:description =>
|
771
|
-
:unit_price =>
|
772
|
-
:discount =>
|
773
|
-
:sales_tax =>
|
770
|
+
:description => 'Heavy Widget',
|
771
|
+
:unit_price => 15,
|
772
|
+
:discount => 0,
|
773
|
+
:sales_tax => 0.95
|
774
774
|
}
|
775
775
|
]
|
776
776
|
}>
|
@@ -786,8 +786,8 @@ client.nexus_regions
|
|
786
786
|
#### Example Request
|
787
787
|
|
788
788
|
```ruby
|
789
|
-
require
|
790
|
-
client = Taxjar::Client.new(api_key:
|
789
|
+
require 'taxjar'
|
790
|
+
client = Taxjar::Client.new(api_key: '9e0cd62a22f451701f29c3bde214')
|
791
791
|
|
792
792
|
nexus_regions = client.nexus_regions
|
793
793
|
```
|
@@ -797,22 +797,22 @@ nexus_regions = client.nexus_regions
|
|
797
797
|
```ruby
|
798
798
|
[
|
799
799
|
{
|
800
|
-
:country_code =>
|
801
|
-
:country =>
|
802
|
-
:region_code =>
|
803
|
-
:region =>
|
800
|
+
:country_code => 'US',
|
801
|
+
:country => 'United States',
|
802
|
+
:region_code => 'CA',
|
803
|
+
:region => 'California'
|
804
804
|
},
|
805
805
|
{
|
806
|
-
:country_code =>
|
807
|
-
:country =>
|
808
|
-
:region_code =>
|
809
|
-
:region =>
|
806
|
+
:country_code => 'US',
|
807
|
+
:country => 'United States',
|
808
|
+
:region_code => 'NY',
|
809
|
+
:region => 'New York'
|
810
810
|
},
|
811
811
|
{
|
812
|
-
:country_code =>
|
813
|
-
:country =>
|
814
|
-
:region_code =>
|
815
|
-
:region =>
|
812
|
+
:country_code => 'US',
|
813
|
+
:country => 'United States',
|
814
|
+
:region_code => 'WA',
|
815
|
+
:region => 'Washington'
|
816
816
|
}
|
817
817
|
]
|
818
818
|
```
|
@@ -844,11 +844,11 @@ validation = client.validate({
|
|
844
844
|
:exists => true,
|
845
845
|
:vies_available => true,
|
846
846
|
:vies_response => {
|
847
|
-
:country_code =>
|
848
|
-
:vat_number =>
|
849
|
-
:request_date =>
|
847
|
+
:country_code => 'FR',
|
848
|
+
:vat_number => '40303265045',
|
849
|
+
:request_date => '2016-02-10',
|
850
850
|
:valid => true,
|
851
|
-
:name =>
|
851
|
+
:name => 'SA SODIMAS',
|
852
852
|
:address => "11 RUE AMPERE\n26600 PONT DE L ISERE"
|
853
853
|
}
|
854
854
|
}>
|
@@ -876,44 +876,44 @@ summarized_rates = client.summary_rates
|
|
876
876
|
```ruby
|
877
877
|
[
|
878
878
|
{
|
879
|
-
:country_code =>
|
880
|
-
:country =>
|
881
|
-
:region_code =>
|
882
|
-
:region =>
|
879
|
+
:country_code => 'US',
|
880
|
+
:country => 'United States',
|
881
|
+
:region_code => 'CA',
|
882
|
+
:region => 'California',
|
883
883
|
:minimum_rate => {
|
884
|
-
:label =>
|
884
|
+
:label => 'State Tax',
|
885
885
|
:rate => 0.065
|
886
886
|
},
|
887
887
|
:average_rate => {
|
888
|
-
:label =>
|
888
|
+
:label => 'Tax',
|
889
889
|
:rate => 0.0827
|
890
890
|
}
|
891
891
|
},
|
892
892
|
{
|
893
|
-
:country_code =>
|
894
|
-
:country =>
|
895
|
-
:region_code =>
|
896
|
-
:region =>
|
893
|
+
:country_code => 'CA',
|
894
|
+
:country => 'Canada',
|
895
|
+
:region_code => 'BC',
|
896
|
+
:region => 'British Columbia',
|
897
897
|
:minimum_rate => {
|
898
|
-
:label =>
|
898
|
+
:label => 'GST',
|
899
899
|
:rate => 0.05
|
900
900
|
},
|
901
901
|
:average_rate => {
|
902
|
-
:label =>
|
902
|
+
:label => 'PST',
|
903
903
|
:rate => 0.12
|
904
904
|
}
|
905
905
|
},
|
906
906
|
{
|
907
|
-
:country_code =>
|
908
|
-
:country =>
|
907
|
+
:country_code => 'UK',
|
908
|
+
:country => 'United Kingdom',
|
909
909
|
:region_code => nil,
|
910
910
|
:region => nil,
|
911
911
|
:minimum_rate => {
|
912
|
-
:label =>
|
912
|
+
:label => 'VAT',
|
913
913
|
:rate => 0.2
|
914
914
|
},
|
915
915
|
:average_rate => {
|
916
|
-
:label =>
|
916
|
+
:label => 'VAT',
|
917
917
|
:rate => 0.2
|
918
918
|
}
|
919
919
|
}
|
data/lib/taxjar/breakdown.rb
CHANGED
@@ -5,15 +5,38 @@ module Taxjar
|
|
5
5
|
class Breakdown < Taxjar::Base
|
6
6
|
extend ModelAttribute
|
7
7
|
|
8
|
+
attribute :taxable_amount, :float
|
9
|
+
attribute :tax_collectable, :float
|
10
|
+
attribute :combined_tax_rate, :float
|
8
11
|
attribute :state_taxable_amount, :float
|
12
|
+
attribute :state_tax_rate, :float
|
9
13
|
attribute :state_tax_collectable, :float
|
10
14
|
attribute :county_taxable_amount, :float
|
15
|
+
attribute :county_tax_rate, :float
|
11
16
|
attribute :county_tax_collectable, :float
|
12
17
|
attribute :city_taxable_amount, :float
|
18
|
+
attribute :city_tax_rate, :float
|
13
19
|
attribute :city_tax_collectable, :float
|
14
20
|
attribute :special_district_taxable_amount, :float
|
21
|
+
attribute :special_tax_rate, :float
|
15
22
|
attribute :special_district_tax_collectable, :float
|
16
23
|
|
24
|
+
# International
|
25
|
+
attribute :country_taxable_amount, :float
|
26
|
+
attribute :country_tax_rate, :float
|
27
|
+
attribute :country_tax_collectable, :float
|
28
|
+
|
29
|
+
# Canada
|
30
|
+
attribute :gst_taxable_amount, :float
|
31
|
+
attribute :gst_tax_rate, :float
|
32
|
+
attribute :gst, :float
|
33
|
+
attribute :pst_taxable_amount, :float
|
34
|
+
attribute :pst_tax_rate, :float
|
35
|
+
attribute :pst, :float
|
36
|
+
attribute :qst_taxable_amount, :float
|
37
|
+
attribute :qst_tax_rate, :float
|
38
|
+
attribute :qst, :float
|
39
|
+
|
17
40
|
object_attr_reader Taxjar::Shipping, :shipping
|
18
41
|
|
19
42
|
def line_items
|
@@ -5,7 +5,9 @@ module Taxjar
|
|
5
5
|
extend ModelAttribute
|
6
6
|
|
7
7
|
attribute :id, :integer
|
8
|
+
attribute :taxable_amount, :float
|
8
9
|
attribute :tax_collectable, :float
|
10
|
+
attribute :combined_tax_rate, :float
|
9
11
|
attribute :state_taxable_amount, :float
|
10
12
|
attribute :state_sales_tax_rate, :float
|
11
13
|
attribute :state_amount, :float
|
@@ -18,5 +20,21 @@ module Taxjar
|
|
18
20
|
attribute :special_district_taxable_amount, :float
|
19
21
|
attribute :special_tax_rate, :float
|
20
22
|
attribute :special_district_amount, :float
|
23
|
+
|
24
|
+
# International
|
25
|
+
attribute :country_taxable_amount, :float
|
26
|
+
attribute :country_tax_rate, :float
|
27
|
+
attribute :country_tax_collectable, :float
|
28
|
+
|
29
|
+
# Canada
|
30
|
+
attribute :gst_taxable_amount, :float
|
31
|
+
attribute :gst_tax_rate, :float
|
32
|
+
attribute :gst, :float
|
33
|
+
attribute :pst_taxable_amount, :float
|
34
|
+
attribute :pst_tax_rate, :float
|
35
|
+
attribute :pst, :float
|
36
|
+
attribute :qst_taxable_amount, :float
|
37
|
+
attribute :qst_tax_rate, :float
|
38
|
+
attribute :qst, :float
|
21
39
|
end
|
22
40
|
end
|
data/lib/taxjar/shipping.rb
CHANGED
@@ -3,16 +3,37 @@ require 'taxjar/base'
|
|
3
3
|
module Taxjar
|
4
4
|
class Shipping < Taxjar::Base
|
5
5
|
extend ModelAttribute
|
6
|
-
|
6
|
+
|
7
7
|
attribute :taxable_amount, :float
|
8
8
|
attribute :tax_collectable, :float
|
9
|
-
attribute :
|
9
|
+
attribute :combined_tax_rate, :float
|
10
|
+
attribute :state_taxable_amount, :float
|
10
11
|
attribute :state_sales_tax_rate, :float
|
11
|
-
attribute :
|
12
|
+
attribute :state_amount, :float
|
13
|
+
attribute :county_taxable_amount, :float
|
12
14
|
attribute :county_tax_rate, :float
|
13
|
-
attribute :
|
15
|
+
attribute :county_amount, :float
|
16
|
+
attribute :city_taxable_amount, :float
|
14
17
|
attribute :city_tax_rate, :float
|
15
|
-
attribute :
|
18
|
+
attribute :city_amount, :float
|
19
|
+
attribute :special_taxable_amount, :float
|
16
20
|
attribute :special_tax_rate, :float
|
21
|
+
attribute :special_district_amount, :float
|
22
|
+
|
23
|
+
# International
|
24
|
+
attribute :country_taxable_amount, :float
|
25
|
+
attribute :country_tax_rate, :float
|
26
|
+
attribute :country_tax_collectable, :float
|
27
|
+
|
28
|
+
# Canada
|
29
|
+
attribute :gst_taxable_amount, :float
|
30
|
+
attribute :gst_tax_rate, :float
|
31
|
+
attribute :gst, :float
|
32
|
+
attribute :pst_taxable_amount, :float
|
33
|
+
attribute :pst_tax_rate, :float
|
34
|
+
attribute :pst, :float
|
35
|
+
attribute :qst_taxable_amount, :float
|
36
|
+
attribute :qst_tax_rate, :float
|
37
|
+
attribute :qst, :float
|
17
38
|
end
|
18
39
|
end
|
data/lib/taxjar/version.rb
CHANGED
data/spec/fixtures/taxes.json
CHANGED
@@ -1,42 +1,66 @@
|
|
1
1
|
{
|
2
2
|
"tax": {
|
3
3
|
"order_total_amount": 16.5,
|
4
|
+
"shipping": 1.5,
|
5
|
+
"taxable_amount": 16.5,
|
4
6
|
"amount_to_collect": 1.16,
|
7
|
+
"rate": 0.07,
|
5
8
|
"has_nexus": true,
|
6
9
|
"freight_taxable": true,
|
7
10
|
"tax_source": "destination",
|
8
11
|
"breakdown": {
|
9
|
-
"
|
10
|
-
|
11
|
-
|
12
|
-
"county_amount": 0,
|
13
|
-
"county_tax_rate": 0,
|
14
|
-
"city_amount": 0,
|
15
|
-
"city_tax_rate": 0,
|
16
|
-
"special_district_amount": 0,
|
17
|
-
"special_tax_rate": 0
|
18
|
-
},
|
12
|
+
"taxable_amount": 16.5,
|
13
|
+
"tax_collectable": 1.16,
|
14
|
+
"combined_tax_rate": 0.07,
|
19
15
|
"state_taxable_amount": 16.5,
|
16
|
+
"state_tax_rate": 0.07,
|
20
17
|
"state_tax_collectable": 1.16,
|
21
18
|
"county_taxable_amount": 0,
|
19
|
+
"county_tax_rate": 0,
|
22
20
|
"county_tax_collectable": 0,
|
23
21
|
"city_taxable_amount": 0,
|
22
|
+
"city_tax_rate": 0,
|
24
23
|
"city_tax_collectable": 0,
|
25
24
|
"special_district_taxable_amount": 0,
|
25
|
+
"special_tax_rate": 0,
|
26
26
|
"special_district_tax_collectable": 0,
|
27
|
+
"shipping": {
|
28
|
+
"taxable_amount": 1.5,
|
29
|
+
"tax_collectable": 0.11,
|
30
|
+
"combined_tax_rate": 0.07,
|
31
|
+
"state_taxable_amount": 1.5,
|
32
|
+
"state_sales_tax_rate": 0.07,
|
33
|
+
"state_amount": 0.11,
|
34
|
+
"county_taxable_amount": 0,
|
35
|
+
"county_tax_rate": 0,
|
36
|
+
"county_amount": 0,
|
37
|
+
"city_taxable_amount": 0,
|
38
|
+
"city_tax_rate": 0,
|
39
|
+
"city_amount": 0,
|
40
|
+
"special_taxable_amount": 0,
|
41
|
+
"special_tax_rate": 0,
|
42
|
+
"special_district_amount": 0
|
43
|
+
},
|
27
44
|
"line_items": [
|
28
45
|
{
|
29
46
|
"id": "1",
|
47
|
+
"taxable_amount": 15,
|
48
|
+
"tax_collectable": 1.05,
|
49
|
+
"combined_tax_rate": 0.07,
|
30
50
|
"state_taxable_amount": 15,
|
31
51
|
"state_sales_tax_rate": 0.07,
|
52
|
+
"state_amount": 1.05,
|
32
53
|
"county_taxable_amount": 0,
|
33
54
|
"county_tax_rate": 0,
|
55
|
+
"county_amount": 0,
|
34
56
|
"city_taxable_amount": 0,
|
35
57
|
"city_tax_rate": 0,
|
58
|
+
"city_amount": 0,
|
36
59
|
"special_district_taxable_amount": 0,
|
37
|
-
"special_tax_rate": 0
|
60
|
+
"special_tax_rate": 0,
|
61
|
+
"special_district_amount": 0
|
38
62
|
}
|
39
63
|
]
|
40
64
|
}
|
41
65
|
}
|
42
|
-
}
|
66
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
{
|
2
|
+
"tax": {
|
3
|
+
"order_total_amount": 26.95,
|
4
|
+
"shipping": 10,
|
5
|
+
"taxable_amount": 26.95,
|
6
|
+
"amount_to_collect": 3.5,
|
7
|
+
"rate": 0.13,
|
8
|
+
"has_nexus": true,
|
9
|
+
"freight_taxable": true,
|
10
|
+
"tax_source": "destination",
|
11
|
+
"breakdown": {
|
12
|
+
"taxable_amount": 26.95,
|
13
|
+
"tax_collectable": 3.5,
|
14
|
+
"combined_tax_rate": 0.13,
|
15
|
+
"gst_taxable_amount": 26.95,
|
16
|
+
"gst_tax_rate": 0.05,
|
17
|
+
"gst": 1.35,
|
18
|
+
"pst_taxable_amount": 26.95,
|
19
|
+
"pst_tax_rate": 0.08,
|
20
|
+
"pst": 2.16,
|
21
|
+
"qst_taxable_amount": 0,
|
22
|
+
"qst_tax_rate": 0,
|
23
|
+
"qst": 0,
|
24
|
+
"shipping": {
|
25
|
+
"taxable_amount": 10,
|
26
|
+
"tax_collectable": 1.3,
|
27
|
+
"combined_tax_rate": 0.13,
|
28
|
+
"gst_taxable_amount": 10,
|
29
|
+
"gst_tax_rate": 0.05,
|
30
|
+
"gst": 0.5,
|
31
|
+
"pst_taxable_amount": 10,
|
32
|
+
"pst_tax_rate": 0.08,
|
33
|
+
"pst": 0.8,
|
34
|
+
"qst_taxable_amount": 0,
|
35
|
+
"qst_tax_rate": 0,
|
36
|
+
"qst": 0
|
37
|
+
},
|
38
|
+
"line_items": [
|
39
|
+
{
|
40
|
+
"id": "1",
|
41
|
+
"taxable_amount": 16.95,
|
42
|
+
"tax_collectable": 2.2,
|
43
|
+
"combined_tax_rate": 0.13,
|
44
|
+
"gst_taxable_amount": 16.95,
|
45
|
+
"gst_tax_rate": 0.05,
|
46
|
+
"gst": 0.85,
|
47
|
+
"pst_taxable_amount": 16.95,
|
48
|
+
"pst_tax_rate": 0.08,
|
49
|
+
"pst": 1.36,
|
50
|
+
"qst_taxable_amount": 0,
|
51
|
+
"qst_tax_rate": 0,
|
52
|
+
"qst": 0
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"tax": {
|
3
|
+
"order_total_amount": 26.95,
|
4
|
+
"shipping": 10,
|
5
|
+
"taxable_amount": 26.95,
|
6
|
+
"amount_to_collect": 6.47,
|
7
|
+
"rate": 0.24,
|
8
|
+
"has_nexus": true,
|
9
|
+
"freight_taxable": true,
|
10
|
+
"tax_source": "destination",
|
11
|
+
"breakdown": {
|
12
|
+
"taxable_amount": 26.95,
|
13
|
+
"tax_collectable": 6.47,
|
14
|
+
"combined_tax_rate": 0.24,
|
15
|
+
"country_taxable_amount": 26.95,
|
16
|
+
"country_tax_rate": 0.24,
|
17
|
+
"country_tax_collectable": 6.47,
|
18
|
+
"shipping": {
|
19
|
+
"taxable_amount": 10,
|
20
|
+
"tax_collectable": 2.4,
|
21
|
+
"combined_tax_rate": 0.24,
|
22
|
+
"country_taxable_amount": 10,
|
23
|
+
"country_tax_rate": 0.24,
|
24
|
+
"country_tax_collectable": 2.4
|
25
|
+
},
|
26
|
+
"line_items": [
|
27
|
+
{
|
28
|
+
"id": "1",
|
29
|
+
"taxable_amount": 16.95,
|
30
|
+
"tax_collectable": 4.07,
|
31
|
+
"combined_tax_rate": 0.24,
|
32
|
+
"country_taxable_amount": 16.95,
|
33
|
+
"country_tax_rate": 0.24,
|
34
|
+
"country_tax_collectable": 4.07
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
data/spec/taxjar/api/api_spec.rb
CHANGED
@@ -85,8 +85,7 @@ describe Taxjar::API do
|
|
85
85
|
|
86
86
|
describe "#tax_for_order" do
|
87
87
|
before do
|
88
|
-
stub_post("/v2/taxes").to_return(body: fixture('taxes.json'),
|
89
|
-
headers: {content_type: 'application/json; charset=utf-8'})
|
88
|
+
stub_post("/v2/taxes").to_return(body: fixture('taxes.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
90
89
|
|
91
90
|
@order = {:from_country => 'US',
|
92
91
|
:from_zip => '07001',
|
@@ -109,7 +108,10 @@ describe Taxjar::API do
|
|
109
108
|
tax = @client.tax_for_order(@order)
|
110
109
|
expect(tax).to be_a Taxjar::Tax
|
111
110
|
expect(tax.order_total_amount).to eq(16.5)
|
111
|
+
expect(tax.shipping).to eq(1.5)
|
112
|
+
expect(tax.taxable_amount).to eq(16.5)
|
112
113
|
expect(tax.amount_to_collect).to eq(1.16)
|
114
|
+
expect(tax.rate).to eq(0.07)
|
113
115
|
expect(tax.has_nexus).to eq(true)
|
114
116
|
expect(tax.freight_taxable).to eq(true)
|
115
117
|
expect(tax.tax_source).to eq('destination')
|
@@ -119,37 +121,176 @@ describe Taxjar::API do
|
|
119
121
|
tax = @client.tax_for_order(@order)
|
120
122
|
expect(tax.breakdown.state_taxable_amount).to eq(16.5)
|
121
123
|
expect(tax.breakdown.state_tax_collectable).to eq(1.16)
|
124
|
+
expect(tax.breakdown.combined_tax_rate).to eq(0.07)
|
125
|
+
expect(tax.breakdown.state_taxable_amount).to eq(16.5)
|
126
|
+
expect(tax.breakdown.state_tax_rate).to eq(0.07)
|
127
|
+
expect(tax.breakdown.state_tax_collectable).to eq(1.16)
|
122
128
|
expect(tax.breakdown.county_taxable_amount).to eq(0)
|
129
|
+
expect(tax.breakdown.county_tax_rate).to eq(0)
|
123
130
|
expect(tax.breakdown.county_tax_collectable).to eq(0)
|
124
131
|
expect(tax.breakdown.city_taxable_amount).to eq(0)
|
132
|
+
expect(tax.breakdown.city_tax_rate).to eq(0)
|
125
133
|
expect(tax.breakdown.city_tax_collectable).to eq(0)
|
126
134
|
expect(tax.breakdown.special_district_taxable_amount).to eq(0)
|
135
|
+
expect(tax.breakdown.special_tax_rate).to eq(0)
|
127
136
|
expect(tax.breakdown.special_district_tax_collectable).to eq(0)
|
128
137
|
end
|
129
138
|
|
130
139
|
it 'allows access to breakdown.shipping' do
|
131
140
|
tax = @client.tax_for_order(@order)
|
141
|
+
expect(tax.breakdown.shipping.taxable_amount).to eq(1.5)
|
142
|
+
expect(tax.breakdown.shipping.tax_collectable).to eq(0.11)
|
143
|
+
expect(tax.breakdown.shipping.state_taxable_amount).to eq(1.5)
|
132
144
|
expect(tax.breakdown.shipping.state_amount).to eq(0.11)
|
133
145
|
expect(tax.breakdown.shipping.state_sales_tax_rate).to eq(0.07)
|
134
|
-
expect(tax.breakdown.shipping.
|
146
|
+
expect(tax.breakdown.shipping.state_amount).to eq(0.11)
|
147
|
+
expect(tax.breakdown.shipping.county_taxable_amount).to eq(0)
|
135
148
|
expect(tax.breakdown.shipping.county_tax_rate).to eq(0)
|
136
|
-
expect(tax.breakdown.shipping.
|
149
|
+
expect(tax.breakdown.shipping.county_amount).to eq(0)
|
150
|
+
expect(tax.breakdown.shipping.city_taxable_amount).to eq(0)
|
137
151
|
expect(tax.breakdown.shipping.city_tax_rate).to eq(0)
|
138
|
-
expect(tax.breakdown.shipping.
|
152
|
+
expect(tax.breakdown.shipping.city_amount).to eq(0)
|
153
|
+
expect(tax.breakdown.shipping.special_taxable_amount).to eq(0)
|
139
154
|
expect(tax.breakdown.shipping.special_tax_rate).to eq(0)
|
155
|
+
expect(tax.breakdown.shipping.special_district_amount).to eq(0)
|
140
156
|
end
|
141
157
|
|
142
158
|
it 'allows access to breakdown.line_items' do
|
143
159
|
tax = @client.tax_for_order(@order)
|
144
160
|
expect(tax.breakdown.line_items[0].id).to eq(1)
|
161
|
+
expect(tax.breakdown.line_items[0].taxable_amount).to eq(15)
|
162
|
+
expect(tax.breakdown.line_items[0].tax_collectable).to eq(1.05)
|
163
|
+
expect(tax.breakdown.line_items[0].combined_tax_rate).to eq(0.07)
|
145
164
|
expect(tax.breakdown.line_items[0].state_taxable_amount).to eq(15)
|
146
165
|
expect(tax.breakdown.line_items[0].state_sales_tax_rate).to eq(0.07)
|
166
|
+
expect(tax.breakdown.line_items[0].state_amount).to eq(1.05)
|
147
167
|
expect(tax.breakdown.line_items[0].county_taxable_amount).to eq(0)
|
148
168
|
expect(tax.breakdown.line_items[0].county_tax_rate).to eq(0)
|
169
|
+
expect(tax.breakdown.line_items[0].county_amount).to eq(0)
|
149
170
|
expect(tax.breakdown.line_items[0].city_taxable_amount).to eq(0)
|
150
171
|
expect(tax.breakdown.line_items[0].city_tax_rate).to eq(0)
|
172
|
+
expect(tax.breakdown.line_items[0].city_amount).to eq(0)
|
151
173
|
expect(tax.breakdown.line_items[0].special_district_taxable_amount).to eq(0)
|
152
174
|
expect(tax.breakdown.line_items[0].special_tax_rate).to eq(0)
|
175
|
+
expect(tax.breakdown.line_items[0].special_district_amount).to eq(0)
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "international orders" do
|
179
|
+
before do
|
180
|
+
stub_post("/v2/taxes").to_return(body: fixture('taxes_international.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'returns the requested taxes' do
|
184
|
+
tax = @client.tax_for_order(@order)
|
185
|
+
expect(tax).to be_a Taxjar::Tax
|
186
|
+
expect(tax.order_total_amount).to eq(26.95)
|
187
|
+
expect(tax.shipping).to eq(10)
|
188
|
+
expect(tax.taxable_amount).to eq(26.95)
|
189
|
+
expect(tax.amount_to_collect).to eq(6.47)
|
190
|
+
expect(tax.rate).to eq(0.24)
|
191
|
+
expect(tax.has_nexus).to eq(true)
|
192
|
+
expect(tax.freight_taxable).to eq(true)
|
193
|
+
expect(tax.tax_source).to eq('destination')
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'allows access to breakdown' do
|
197
|
+
tax = @client.tax_for_order(@order)
|
198
|
+
expect(tax.breakdown.taxable_amount).to eq(26.95)
|
199
|
+
expect(tax.breakdown.tax_collectable).to eq(6.47)
|
200
|
+
expect(tax.breakdown.combined_tax_rate).to eq(0.24)
|
201
|
+
expect(tax.breakdown.country_taxable_amount).to eq(26.95)
|
202
|
+
expect(tax.breakdown.country_tax_rate).to eq(0.24)
|
203
|
+
expect(tax.breakdown.country_tax_collectable).to eq(6.47)
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'allows access to breakdown.shipping' do
|
207
|
+
tax = @client.tax_for_order(@order)
|
208
|
+
expect(tax.breakdown.shipping.taxable_amount).to eq(10)
|
209
|
+
expect(tax.breakdown.shipping.tax_collectable).to eq(2.4)
|
210
|
+
expect(tax.breakdown.shipping.combined_tax_rate).to eq(0.24)
|
211
|
+
expect(tax.breakdown.shipping.country_taxable_amount).to eq(10)
|
212
|
+
expect(tax.breakdown.shipping.country_tax_rate).to eq(0.24)
|
213
|
+
expect(tax.breakdown.shipping.country_tax_collectable).to eq(2.4)
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'allows access to breakdown.line_items' do
|
217
|
+
tax = @client.tax_for_order(@order)
|
218
|
+
expect(tax.breakdown.line_items[0].id).to eq(1)
|
219
|
+
expect(tax.breakdown.line_items[0].taxable_amount).to eq(16.95)
|
220
|
+
expect(tax.breakdown.line_items[0].tax_collectable).to eq(4.07)
|
221
|
+
expect(tax.breakdown.line_items[0].combined_tax_rate).to eq(0.24)
|
222
|
+
expect(tax.breakdown.line_items[0].country_taxable_amount).to eq(16.95)
|
223
|
+
expect(tax.breakdown.line_items[0].country_tax_rate).to eq(0.24)
|
224
|
+
expect(tax.breakdown.line_items[0].country_tax_collectable).to eq(4.07)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
describe "canadian orders" do
|
229
|
+
before do
|
230
|
+
stub_post("/v2/taxes").to_return(body: fixture('taxes_canada.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'returns the requested taxes' do
|
234
|
+
tax = @client.tax_for_order(@order)
|
235
|
+
expect(tax).to be_a Taxjar::Tax
|
236
|
+
expect(tax.order_total_amount).to eq(26.95)
|
237
|
+
expect(tax.shipping).to eq(10)
|
238
|
+
expect(tax.taxable_amount).to eq(26.95)
|
239
|
+
expect(tax.amount_to_collect).to eq(3.5)
|
240
|
+
expect(tax.rate).to eq(0.13)
|
241
|
+
expect(tax.has_nexus).to eq(true)
|
242
|
+
expect(tax.freight_taxable).to eq(true)
|
243
|
+
expect(tax.tax_source).to eq('destination')
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'allows access to breakdown' do
|
247
|
+
tax = @client.tax_for_order(@order)
|
248
|
+
expect(tax.breakdown.taxable_amount).to eq(26.95)
|
249
|
+
expect(tax.breakdown.tax_collectable).to eq(3.5)
|
250
|
+
expect(tax.breakdown.combined_tax_rate).to eq(0.13)
|
251
|
+
expect(tax.breakdown.gst_taxable_amount).to eq(26.95)
|
252
|
+
expect(tax.breakdown.gst_tax_rate).to eq(0.05)
|
253
|
+
expect(tax.breakdown.gst).to eq(1.35)
|
254
|
+
expect(tax.breakdown.pst_taxable_amount).to eq(26.95)
|
255
|
+
expect(tax.breakdown.pst_tax_rate).to eq(0.08)
|
256
|
+
expect(tax.breakdown.pst).to eq(2.16)
|
257
|
+
expect(tax.breakdown.qst_taxable_amount).to eq(0)
|
258
|
+
expect(tax.breakdown.qst_tax_rate).to eq(0)
|
259
|
+
expect(tax.breakdown.qst).to eq(0)
|
260
|
+
end
|
261
|
+
|
262
|
+
it 'allows access to breakdown.shipping' do
|
263
|
+
tax = @client.tax_for_order(@order)
|
264
|
+
expect(tax.breakdown.shipping.taxable_amount).to eq(10)
|
265
|
+
expect(tax.breakdown.shipping.tax_collectable).to eq(1.3)
|
266
|
+
expect(tax.breakdown.shipping.combined_tax_rate).to eq(0.13)
|
267
|
+
expect(tax.breakdown.shipping.gst_taxable_amount).to eq(10)
|
268
|
+
expect(tax.breakdown.shipping.gst_tax_rate).to eq(0.05)
|
269
|
+
expect(tax.breakdown.shipping.gst).to eq(0.5)
|
270
|
+
expect(tax.breakdown.shipping.pst_taxable_amount).to eq(10)
|
271
|
+
expect(tax.breakdown.shipping.pst_tax_rate).to eq(0.08)
|
272
|
+
expect(tax.breakdown.shipping.pst).to eq(0.8)
|
273
|
+
expect(tax.breakdown.shipping.qst_taxable_amount).to eq(0)
|
274
|
+
expect(tax.breakdown.shipping.qst_tax_rate).to eq(0)
|
275
|
+
expect(tax.breakdown.shipping.qst).to eq(0)
|
276
|
+
end
|
277
|
+
|
278
|
+
it 'allows access to breakdown.line_items' do
|
279
|
+
tax = @client.tax_for_order(@order)
|
280
|
+
expect(tax.breakdown.line_items[0].id).to eq(1)
|
281
|
+
expect(tax.breakdown.line_items[0].taxable_amount).to eq(16.95)
|
282
|
+
expect(tax.breakdown.line_items[0].tax_collectable).to eq(2.2)
|
283
|
+
expect(tax.breakdown.line_items[0].combined_tax_rate).to eq(0.13)
|
284
|
+
expect(tax.breakdown.line_items[0].gst_taxable_amount).to eq(16.95)
|
285
|
+
expect(tax.breakdown.line_items[0].gst_tax_rate).to eq(0.05)
|
286
|
+
expect(tax.breakdown.line_items[0].gst).to eq(0.85)
|
287
|
+
expect(tax.breakdown.line_items[0].pst_taxable_amount).to eq(16.95)
|
288
|
+
expect(tax.breakdown.line_items[0].pst_tax_rate).to eq(0.08)
|
289
|
+
expect(tax.breakdown.line_items[0].pst).to eq(1.36)
|
290
|
+
expect(tax.breakdown.line_items[0].qst_taxable_amount).to eq(0)
|
291
|
+
expect(tax.breakdown.line_items[0].qst_tax_rate).to eq(0)
|
292
|
+
expect(tax.breakdown.line_items[0].qst).to eq(0)
|
293
|
+
end
|
153
294
|
end
|
154
295
|
end
|
155
296
|
|
data/taxjar-ruby.gemspec
CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'addressable', '~>2.3'
|
22
|
-
spec.add_dependency 'http', '~>0.9.4'
|
23
|
-
spec.add_dependency 'memoizable', '~>0.4.0'
|
21
|
+
spec.add_dependency 'addressable', '~> 2.3.8'
|
22
|
+
spec.add_dependency 'http', '~> 0.9.4'
|
23
|
+
spec.add_dependency 'memoizable', '~> 0.4.0'
|
24
24
|
spec.add_dependency 'taxjar-model_attribute', '~> 3.1'
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taxjar-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TaxJar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.3.8
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.3.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: http
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,6 +141,8 @@ files:
|
|
141
141
|
- spec/fixtures/refunds.json
|
142
142
|
- spec/fixtures/summary_rates.json
|
143
143
|
- spec/fixtures/taxes.json
|
144
|
+
- spec/fixtures/taxes_canada.json
|
145
|
+
- spec/fixtures/taxes_international.json
|
144
146
|
- spec/fixtures/validation.json
|
145
147
|
- spec/helper.rb
|
146
148
|
- spec/taxjar/api/api_spec.rb
|
@@ -186,6 +188,8 @@ test_files:
|
|
186
188
|
- spec/fixtures/refunds.json
|
187
189
|
- spec/fixtures/summary_rates.json
|
188
190
|
- spec/fixtures/taxes.json
|
191
|
+
- spec/fixtures/taxes_canada.json
|
192
|
+
- spec/fixtures/taxes_international.json
|
189
193
|
- spec/fixtures/validation.json
|
190
194
|
- spec/helper.rb
|
191
195
|
- spec/taxjar/api/api_spec.rb
|