taxamo-ns 2.3.5 → 2.3.6

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: d1099262fd43990e995e29ddbf20ac25978cd57f
4
- data.tar.gz: ad728960e0cc78a323674fb04631203af416fbc7
3
+ metadata.gz: c555b2d070dc07d9054c8646b2811c6ab1e81ac4
4
+ data.tar.gz: d4ce2bc63d1fbfb6db88b95f251b0b254d6e06e7
5
5
  SHA512:
6
- metadata.gz: 5e52926bf9c175ffc57f26de106fd8d8038f674f90dd561880bfabad8981ae4bab9ef742f66dbac6fb92a3e2f0dcdcc5640f5a334fc3095f6d2cab05fa0a933e
7
- data.tar.gz: cff2e9df040625abaefddd422fdb9e3ca020deb0726c589d55ad9265b760a1188e6d24055cfe566bae8bdf77d7f87c8fcf3a965ebd1f6ecef013a181430111cc
6
+ metadata.gz: 5f5a628c0341b84b710ef365665678c8a04fc02e6f0de9bdbb2c0e575c1c85842906fe1b88a43f65d8f8a2a244b9cde214ac3c7c21e63911ad5aa10304efa6a9
7
+ data.tar.gz: 38027edac38d35227f452e95d7b2e8aba6913f07cfd3b20b2b82585b84ee912e45ad8c8ba56bf9ce373640db5a1b69a437ba38beeac6aa34050c31050dbf15c3
data/README.md CHANGED
@@ -20,7 +20,7 @@ The library can also be installed directy - just fetch this repository and issue
20
20
 
21
21
  ```shell
22
22
  $ gem build taxamo.gemspec
23
- $ gem install taxamo-ns-2.3.5.gem
23
+ $ gem install taxamo-ns-2.3.6.gem
24
24
  ```
25
25
 
26
26
  Finally, you can use this github repo and add the following line to your project's `Gemfile` file:
@@ -37,6 +37,9 @@ gem "taxamo", github: "taxamo/taxamo-ruby", '~> 1.1'
37
37
 
38
38
  ## Changes
39
39
 
40
+ 2.3.6 (2017-11-09):
41
+ * add control_flags to transaction class and update calculate_simple_tax with new fields
42
+
40
43
  2.3.5 (2017-11-01):
41
44
  * add warnings and tax_entity_additional_id field to the transaction object
42
45
 
@@ -609,8 +609,8 @@ module Taxamo
609
609
 
610
610
  end
611
611
 
612
- def calculate_simple_tax (product_type,invoice_address_city,buyer_credit_card_prefix,currency_code,invoice_address_region,unit_price,quantity,buyer_tax_number,force_country_code,order_date,amount,billing_country_code,invoice_address_postal_code,total_amount,tax_deducted,opts={})
613
- query_param_keys = [:product_type,:invoice_address_city,:buyer_credit_card_prefix,:currency_code,:invoice_address_region,:unit_price,:quantity,:buyer_tax_number,:force_country_code,:order_date,:amount,:billing_country_code,:invoice_address_postal_code,:total_amount,:tax_deducted]
612
+ def calculate_simple_tax (product_type,invoice_address_city,buyer_credit_card_prefix,currency_code,invoice_address_region,unit_price,quantity,buyer_tax_number,force_country_code,order_date,amount,billing_country_code,invoice_address_postal_code,total_amount,tax_deducted,b2b_number_service_on_error=nil,b2b_number_service_timeoutms=nil,b2b_number_service_cache_expiry_days=nil,opts={})
613
+ query_param_keys = [:product_type,:invoice_address_city,:buyer_credit_card_prefix,:currency_code,:invoice_address_region,:unit_price,:quantity,:buyer_tax_number,:force_country_code,:order_date,:amount,:billing_country_code,:invoice_address_postal_code,:total_amount,:tax_deducted,:b2b_number_service_on_error,:b2b_number_service_timeoutms,:b2b_number_service_cache_expiry_days]
614
614
 
615
615
  # verify existence of params
616
616
  raise "currency_code is required" if currency_code.nil?
@@ -630,7 +630,10 @@ module Taxamo
630
630
  :billing_country_code => billing_country_code,
631
631
  :invoice_address_postal_code => invoice_address_postal_code,
632
632
  :total_amount => total_amount,
633
- :tax_deducted => tax_deducted}.merge(opts)
633
+ :tax_deducted => tax_deducted,
634
+ :b2b_number_service_on_error => b2b_number_service_on_error,
635
+ :b2b_number_service_timeoutms => b2b_number_service_timeoutms,
636
+ :b2b_number_service_cache_expiry_days => b2b_number_service_cache_expiry_days}.merge(opts)
634
637
 
635
638
  #resource path
636
639
  path = "/api/v1/tax/calculate".sub('{format}','json')
@@ -0,0 +1,68 @@
1
+ # Copyright 2014-2015 Taxamo, Ltd.
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ module Taxamo
14
+ class ControlFlags
15
+ attr_accessor :key, :value
16
+
17
+ # :internal => :external
18
+ def self.attribute_map
19
+ {
20
+ :key => :key,
21
+ :value => :value
22
+
23
+ }
24
+ end
25
+
26
+ def initialize(attributes = {})
27
+ return if attributes.nil? or attributes.empty?
28
+ # Morph attribute keys into undescored rubyish style
29
+ if attributes.key?("key")
30
+ @key = attributes["key"]
31
+
32
+ end
33
+ if attributes.key?("value")
34
+ @value = attributes["value"]
35
+
36
+ end
37
+
38
+
39
+ end
40
+
41
+ def to_body
42
+ body = {}
43
+ self.class.attribute_map.each_pair do |key, value|
44
+ v = self.send(key)
45
+ unless v.nil?
46
+ if v.is_a?(Array)
47
+ array = Array.new
48
+ v.each do |item|
49
+ if item.respond_to?("to_body".to_sym)
50
+ array.push item.to_body
51
+ else
52
+ array.push item
53
+ end
54
+ end
55
+ body[value] = array
56
+ else
57
+ if v.respond_to?("to_body".to_sym)
58
+ body[value] = v.to_body
59
+ else
60
+ body[value] = v
61
+ end
62
+ end
63
+ end
64
+ end
65
+ body
66
+ end
67
+ end
68
+ end
@@ -12,7 +12,7 @@
12
12
 
13
13
  module Taxamo
14
14
  class InputTransaction
15
- attr_accessor :order_date_type, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :currency_code, :sub_account_id, :supply_date, :invoice_address, :verification_token, :note, :tax_data, :transaction_lines, :buyer_tax_number, :status, :custom_fields, :force_country_code, :invoice_number, :order_date, :customer_id, :comments, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :additional_currencies, :invoice_place, :evidence, :description, :tax_deducted, :tax_country_code
15
+ attr_accessor :order_date_type, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :currency_code, :sub_account_id, :supply_date, :control_flags, :invoice_address, :verification_token, :note, :tax_data, :transaction_lines, :buyer_tax_number, :status, :custom_fields, :force_country_code, :invoice_number, :order_date, :customer_id, :comments, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :additional_currencies, :invoice_place, :evidence, :description, :tax_deducted, :tax_country_code
16
16
 
17
17
  # :internal => :external
18
18
  def self.attribute_map
@@ -25,6 +25,7 @@ class InputTransaction
25
25
  :currency_code => :currency_code,
26
26
  :sub_account_id => :sub_account_id,
27
27
  :supply_date => :supply_date,
28
+ :control_flags => :control_flags,
28
29
  :invoice_address => :invoice_address,
29
30
  :verification_token => :verification_token,
30
31
  :note => :note,
@@ -88,6 +89,11 @@ class InputTransaction
88
89
  @supply_date = attributes["supply_date"]
89
90
 
90
91
  end
92
+ if attributes.key?("control_flags")
93
+ if (value = attributes["control_flags"]).is_a?(Array)
94
+ @control_flags = value.map{ |v| ControlFlags.new(v) }
95
+ end
96
+ end
91
97
  if attributes.key?("invoice_address")
92
98
  @invoice_address = InvoiceAddress.new(attributes["invoice_address"])
93
99
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  module Taxamo
14
14
  class InputTransactionUpdate
15
- attr_accessor :order_date_type, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :currency_code, :sub_account_id, :supply_date, :invoice_address, :verification_token, :note, :tax_data, :transaction_lines, :buyer_tax_number, :status, :custom_fields, :force_country_code, :invoice_number, :order_date, :customer_id, :comments, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :additional_currencies, :invoice_place, :evidence, :description, :tax_deducted, :tax_country_code
15
+ attr_accessor :order_date_type, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :currency_code, :sub_account_id, :supply_date, :control_flags, :invoice_address, :verification_token, :note, :tax_data, :transaction_lines, :buyer_tax_number, :status, :custom_fields, :force_country_code, :invoice_number, :order_date, :customer_id, :comments, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :additional_currencies, :invoice_place, :evidence, :description, :tax_deducted, :tax_country_code
16
16
 
17
17
  # :internal => :external
18
18
  def self.attribute_map
@@ -25,6 +25,7 @@ class InputTransactionUpdate
25
25
  :currency_code => :currency_code,
26
26
  :sub_account_id => :sub_account_id,
27
27
  :supply_date => :supply_date,
28
+ :control_flags => :control_flags,
28
29
  :invoice_address => :invoice_address,
29
30
  :verification_token => :verification_token,
30
31
  :note => :note,
@@ -88,6 +89,11 @@ class InputTransactionUpdate
88
89
  @supply_date = attributes["supply_date"]
89
90
 
90
91
  end
92
+ if attributes.key?("control_flags")
93
+ if (value = attributes["control_flags"]).is_a?(Array)
94
+ @control_flags = value.map{ |v| ControlFlags.new(v) }
95
+ end
96
+ end
91
97
  if attributes.key?("invoice_address")
92
98
  @invoice_address = InvoiceAddress.new(attributes["invoice_address"])
93
99
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  module Taxamo
14
14
  class Transaction
15
- attr_accessor :confirm_timestamp, :fully_informative, :deducted_tax_amount, :order_date_type, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :create_timestamp, :currency_code, :sub_account_id, :supply_date, :buyer_tax_number_normalized, :invoice_image_url, :key, :buyer_tax_number_format_valid, :tax_number_service, :invoice_address, :buyer_tax_number_valid, :verification_token, :note, :tax_supported, :tax_data, :transaction_lines, :buyer_tax_number, :external_key, :status, :custom_fields, :force_country_code, :countries, :invoice_number, :order_date, :customer_id, :kind, :source, :amount, :comments, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :tax_amount, :tax_entity_additional_id, :warnings, :additional_currencies, :invoice_place, :total_amount, :tax_entity_name, :evidence, :refunded_tax_amount, :manual, :tax_timezone, :description, :test, :tax_deducted, :tax_country_code, :refunded_total_amount
15
+ attr_accessor :confirm_timestamp, :fully_informative, :deducted_tax_amount, :order_date_type, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :create_timestamp, :currency_code, :sub_account_id, :supply_date, :buyer_tax_number_normalized, :invoice_image_url, :key, :buyer_tax_number_format_valid, :tax_number_service, :control_flags, :invoice_address, :buyer_tax_number_valid, :verification_token, :note, :tax_supported, :tax_data, :transaction_lines, :buyer_tax_number, :external_key, :status, :custom_fields, :force_country_code, :countries, :invoice_number, :order_date, :customer_id, :kind, :source, :amount, :comments, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :tax_amount, :tax_entity_additional_id, :warnings, :additional_currencies, :invoice_place, :total_amount, :tax_entity_name, :evidence, :refunded_tax_amount, :manual, :tax_timezone, :description, :test, :tax_deducted, :tax_country_code, :refunded_total_amount
16
16
 
17
17
  # :internal => :external
18
18
  def self.attribute_map
@@ -34,6 +34,7 @@ class Transaction
34
34
  :key => :key,
35
35
  :buyer_tax_number_format_valid => :buyer_tax_number_format_valid,
36
36
  :tax_number_service => :tax_number_service,
37
+ :control_flags => :control_flags,
37
38
  :invoice_address => :invoice_address,
38
39
  :buyer_tax_number_valid => :buyer_tax_number_valid,
39
40
  :verification_token => :verification_token,
@@ -150,6 +151,11 @@ class Transaction
150
151
  @tax_number_service = attributes["tax_number_service"]
151
152
 
152
153
  end
154
+ if attributes.key?("control_flags")
155
+ if (value = attributes["control_flags"]).is_a?(Array)
156
+ @control_flags = value.map{ |v| ControlFlags.new(v) }
157
+ end
158
+ end
153
159
  if attributes.key?("invoice_address")
154
160
  @invoice_address = InvoiceAddress.new(attributes["invoice_address"])
155
161
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  module Taxamo
14
14
  class Transactions
15
- attr_accessor :confirm_timestamp, :fully_informative, :deducted_tax_amount, :order_date_type, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :create_timestamp, :currency_code, :sub_account_id, :supply_date, :buyer_tax_number_normalized, :invoice_image_url, :key, :buyer_tax_number_format_valid, :tax_number_service, :invoice_address, :buyer_tax_number_valid, :verification_token, :note, :tax_supported, :tax_data, :transaction_lines, :buyer_tax_number, :external_key, :status, :custom_fields, :force_country_code, :countries, :invoice_number, :order_date, :customer_id, :kind, :source, :amount, :comments, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :tax_amount, :tax_entity_additional_id, :warnings, :additional_currencies, :invoice_place, :total_amount, :tax_entity_name, :evidence, :refunded_tax_amount, :manual, :tax_timezone, :description, :test, :tax_deducted, :tax_country_code, :refunded_total_amount
15
+ attr_accessor :confirm_timestamp, :fully_informative, :deducted_tax_amount, :order_date_type, :buyer_credit_card_prefix, :custom_data, :buyer_name, :invoice_date, :create_timestamp, :currency_code, :sub_account_id, :supply_date, :buyer_tax_number_normalized, :invoice_image_url, :key, :buyer_tax_number_format_valid, :tax_number_service, :control_flags, :invoice_address, :buyer_tax_number_valid, :verification_token, :note, :tax_supported, :tax_data, :transaction_lines, :buyer_tax_number, :external_key, :status, :custom_fields, :force_country_code, :countries, :invoice_number, :order_date, :customer_id, :kind, :source, :amount, :comments, :buyer_ip, :buyer_email, :original_transaction_key, :billing_country_code, :custom_id, :tax_amount, :tax_entity_additional_id, :warnings, :additional_currencies, :invoice_place, :total_amount, :tax_entity_name, :evidence, :refunded_tax_amount, :manual, :tax_timezone, :description, :test, :tax_deducted, :tax_country_code, :refunded_total_amount
16
16
 
17
17
  # :internal => :external
18
18
  def self.attribute_map
@@ -34,6 +34,7 @@ class Transactions
34
34
  :key => :key,
35
35
  :buyer_tax_number_format_valid => :buyer_tax_number_format_valid,
36
36
  :tax_number_service => :tax_number_service,
37
+ :control_flags => :control_flags,
37
38
  :invoice_address => :invoice_address,
38
39
  :buyer_tax_number_valid => :buyer_tax_number_valid,
39
40
  :verification_token => :verification_token,
@@ -150,6 +151,11 @@ class Transactions
150
151
  @tax_number_service = attributes["tax_number_service"]
151
152
 
152
153
  end
154
+ if attributes.key?("control_flags")
155
+ if (value = attributes["control_flags"]).is_a?(Array)
156
+ @control_flags = value.map{ |v| ControlFlags.new(v) }
157
+ end
158
+ end
153
159
  if attributes.key?("invoice_address")
154
160
  @invoice_address = InvoiceAddress.new(attributes["invoice_address"])
155
161
 
@@ -11,7 +11,7 @@
11
11
  # limitations under the License.
12
12
 
13
13
  module Taxamo
14
- VERSION = "2.3.5"
14
+ VERSION = "2.3.6"
15
15
  end
16
16
 
17
17
 
@@ -114,6 +114,46 @@ class TaxTest < Test::Unit::TestCase
114
114
  assert_equal resp.transaction.transaction_lines[0].tax_rate, 5.5
115
115
  assert_equal resp.transaction.transaction_lines[0].total_amount, 105.5
116
116
 
117
+ end
118
+
119
+
120
+ should 'test simple calculate with b2b flags' do
121
+
122
+ Swagger.configure do |config|
123
+ config.api_key = 'SamplePrivateTestKey1'
124
+ end
125
+
126
+ resp = Taxamo.calculate_simple_tax('e-book', #product_type
127
+ nil, #invoice_address_city
128
+ nil, #buyer_credit_card_prefix
129
+ 'USD', #currency_code
130
+ nil, #invoice_address_region
131
+ nil, #unit_price
132
+ nil, #quantity
133
+ "PL0000000000", #buyer_tax_number
134
+ nil, #force_country_code
135
+ nil, #order_date
136
+ 100, #amount
137
+ 'IE', #billing_country_code
138
+ nil, #invoice_address_postal_code
139
+ nil, #total_amount
140
+ nil, #tax_deducted
141
+ "accept", #b2b_number_service_on_error
142
+ "001", #b2b_number_service_timeoutms
143
+ "0" #b2b_number_service_cache_expiry_days
144
+ )
145
+
146
+ assert_equal resp.transaction.buyer_tax_number_valid, true
147
+ assert_equal resp.transaction.note, "b2b_error_accept"
148
+ assert_equal resp.transaction.warnings[0].type, "vies-error"
149
+ assert_equal resp.transaction.warnings[0].message, "Read timed out"
150
+
151
+ #assert_equal resp.transaction.tax_country_code, 'PL'
152
+ assert_equal resp.transaction.amount, 100
153
+ assert_equal resp.transaction.tax_amount, 0
154
+ assert_equal resp.transaction.total_amount, 100
155
+ assert_equal resp.transaction.tax_deducted, true
156
+
117
157
  end
118
158
 
119
159
  should 'test validate tax number' do
@@ -240,7 +240,7 @@ class TransactionsApiTest < Test::Unit::TestCase
240
240
 
241
241
  end
242
242
 
243
- should "test custom fields" do
243
+ should "test custom fields and control flags" do
244
244
  resp = Taxamo.create_transaction(
245
245
  {'transaction' => {
246
246
  'currency_code' => 'USD',
@@ -250,6 +250,8 @@ class TransactionsApiTest < Test::Unit::TestCase
250
250
  'order_date' => '2014-06-01',
251
251
  'custom_fields' => [{'key' => 'test1', 'value' => 'test2'},
252
252
  {'key' => 'test1', 'value' => 'test3'}],
253
+ 'control_flags' => [{'key' => 'test4', 'value' => 'test5'},
254
+ {'key' => 'test6', 'value' => 'test7'}],
253
255
  'transaction_lines' => [{'amount' => 200,
254
256
  'custom_id' => 'line1',
255
257
  'custom_fields' => [{'key' => 'test11', 'value' => 'test22'},
@@ -263,6 +265,8 @@ class TransactionsApiTest < Test::Unit::TestCase
263
265
  assert_equal resp.transaction.status, 'N'
264
266
  assert_equal resp.transaction.custom_fields[0].key, 'test1'
265
267
  assert_equal resp.transaction.custom_fields[1].value, 'test3'
268
+ assert_equal resp.transaction.control_flags[0].key, 'test4'
269
+ assert_equal resp.transaction.control_flags[1].value, 'test7'
266
270
 
267
271
  resp = Taxamo.get_transaction(resp.transaction.key)
268
272
 
@@ -271,6 +275,8 @@ class TransactionsApiTest < Test::Unit::TestCase
271
275
  assert_equal resp.transaction.custom_fields[0].key, 'test1'
272
276
  assert_equal resp.transaction.custom_fields[1].value, 'test3'
273
277
  assert_equal resp.transaction.transaction_lines[0].custom_fields[1].value, 'test23'
278
+ assert_equal resp.transaction.control_flags[0].key, 'test4'
279
+ assert_equal resp.transaction.control_flags[1].value, 'test7'
274
280
 
275
281
  resp = Taxamo.update_transaction(resp.transaction.key,
276
282
  {'transaction' =>
@@ -302,6 +308,10 @@ class TransactionsApiTest < Test::Unit::TestCase
302
308
  assert_equal resp.transaction.custom_fields[0].key, 'test51'
303
309
  assert_equal resp.transaction.custom_fields[1].value, 'test53'
304
310
  assert_equal resp.transaction.custom_fields[2].value, 'test63'
311
+
312
+ assert_equal resp.transaction.control_flags[0].key, 'test4'
313
+ assert_equal resp.transaction.control_flags[1].value, 'test7'
314
+
305
315
  assert_equal resp.transaction.transaction_lines[0].custom_fields[1].value, 'test43'
306
316
  assert_equal resp.transaction.transaction_lines[1].custom_fields[1].value, 'test83'
307
317
 
@@ -331,6 +341,10 @@ class TransactionsApiTest < Test::Unit::TestCase
331
341
  assert_equal resp.transactions[0].custom_fields[0].key, 'test51'
332
342
  assert_equal resp.transactions[0].custom_fields[1].value, 'test53'
333
343
  assert_equal resp.transactions[0].custom_fields[2].value, 'test63'
344
+
345
+ assert_equal resp.transactions[0].control_flags[0].key, 'test4'
346
+ assert_equal resp.transactions[0].control_flags[1].value, 'test7'
347
+
334
348
  assert_equal resp.transactions[0].transaction_lines[0].custom_fields[1].value, 'test43'
335
349
  assert_equal resp.transactions[0].transaction_lines[1].custom_fields[1].value, 'test83'
336
350
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taxamo-ns
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
4
+ version: 2.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomek Lipski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-01 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -140,6 +140,7 @@ files:
140
140
  - lib/taxamo/models/capturepaymentout.rb
141
141
  - lib/taxamo/models/confirmtransactionin.rb
142
142
  - lib/taxamo/models/confirmtransactionout.rb
143
+ - lib/taxamo/models/controlflags.rb
143
144
  - lib/taxamo/models/countries.rb
144
145
  - lib/taxamo/models/country.rb
145
146
  - lib/taxamo/models/countryschema.rb