solidus_avatax_certified 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +28 -0
- data/Gemfile +3 -0
- data/README.md +4 -0
- data/app/assets/javascripts/spree/backend/address_validator.js +1 -1
- data/app/assets/javascripts/spree/frontend/address_validator.js +1 -1
- data/app/controllers/spree/admin/avatax_settings_controller.rb +5 -13
- data/app/models/solidus_avatax_certified/address.rb +2 -8
- data/app/models/solidus_avatax_certified/avatax_log.rb +10 -20
- data/app/models/solidus_avatax_certified/line.rb +0 -6
- data/app/models/solidus_avatax_certified/preference_updater.rb +11 -28
- data/app/models/solidus_avatax_certified/request/base.rb +64 -0
- data/app/models/solidus_avatax_certified/request/cancel_tax.rb +14 -0
- data/app/models/solidus_avatax_certified/request/get_tax.rb +27 -0
- data/app/models/solidus_avatax_certified/request/return_tax.rb +50 -0
- data/app/models/solidus_avatax_certified/response/address_validation.rb +11 -0
- data/app/models/solidus_avatax_certified/response/base.rb +25 -0
- data/app/models/solidus_avatax_certified/response/cancel_tax.rb +15 -0
- data/app/models/solidus_avatax_certified/response/get_tax.rb +11 -0
- data/app/models/spree/address_decorator.rb +2 -2
- data/app/models/spree/adjustment_decorator.rb +0 -2
- data/app/models/spree/avalara_transaction.rb +20 -108
- data/app/models/spree/avatax_configuration.rb +25 -0
- data/app/models/spree/calculator/avalara_transaction.rb +18 -10
- data/app/models/spree/order_decorator.rb +7 -15
- data/app/models/spree/payment_decorator.rb +2 -7
- data/app/models/spree/refund_decorator.rb +6 -10
- data/app/models/spree/shipping_rate_decorator.rb +1 -1
- data/app/models/tax_svc.rb +71 -61
- data/app/views/spree/admin/avatax_settings/edit.html.erb +34 -54
- data/app/views/spree/admin/avatax_settings/show.html.erb +28 -35
- data/app/views/spree/checkout/_address_validator_button.html.erb +1 -1
- data/config/initializers/avatax.rb +11 -2
- data/config/locales/en.yml +9 -3
- data/config/routes.rb +1 -1
- data/db/migrate/20170509201056_drop_spree_avalara_preferences.rb +6 -0
- data/lib/solidus_avatax_certified/exceptions.rb +4 -0
- data/lib/solidus_avatax_certified/preference_seeder.rb +9 -27
- data/lib/solidus_avatax_certified/version.rb +3 -0
- data/lib/solidus_avatax_certified.rb +2 -0
- data/solidus_avatax_certified.gemspec +6 -3
- data/spec/controllers/spree/admin/avatax_settings_controller_spec.rb +8 -8
- data/spec/factories/response_hash_factories.rb +88 -0
- data/spec/features/checkout_spec.rb +1 -1
- data/spec/features/vat_spec.rb +1 -1
- data/spec/models/solidus_avatax_certified/address_spec.rb +22 -7
- data/spec/models/solidus_avatax_certified/avatax_log_spec.rb +17 -24
- data/spec/models/solidus_avatax_certified/line_spec.rb +8 -4
- data/spec/models/solidus_avatax_certified/request/base_spec.rb +13 -0
- data/spec/models/solidus_avatax_certified/request/cancel_tax_spec.rb +13 -0
- data/spec/models/solidus_avatax_certified/request/get_tax_spec.rb +31 -0
- data/spec/models/solidus_avatax_certified/request/return_tax_spec.rb +31 -0
- data/spec/models/solidus_avatax_certified/response/base_spec.rb +21 -0
- data/spec/models/spree/address_decorator_spec.rb +5 -5
- data/spec/models/spree/adjustment_decorator_spec.rb +0 -10
- data/spec/models/spree/avalara_transaction_spec.rb +12 -12
- data/spec/models/spree/calculator/avalara_transaction_spec.rb +4 -3
- data/spec/models/spree/order_decorator_spec.rb +38 -12
- data/spec/models/spree/payment_decorator_spec.rb +7 -9
- data/spec/models/spree/refund_decorator_spec.rb +1 -1
- data/spec/models/tax_svc_spec.rb +65 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/support/avatax_config_preferences.rb +1 -3
- data/spec/support/vcr.rb +1 -1
- data/spec/vcr/Spree_Order/_cancel_avalara/error/should_raise_exception_if_preference_is_enabled.yml +191 -0
- data/spec/vcr/Spree_Order/_cancel_avalara/error/should_receive_ResultCode_of_Error.yml +191 -0
- data/spec/vcr/{SolidusAvataxCertified_Address/_validate/fails_when_information_is_incorrect.yml → Spree_Order/_validate_ship_address/validation_failed/raise_exceptions_if_raise_exceptions_preference_is_enabled.yml} +8 -8
- data/spec/vcr/Spree_Order/_validate_ship_address/validation_failed/should_return_false.yml +54 -0
- data/spec/vcr/Spree_Payment/_avalara_finalize/should_receive_avalara_finalize.yml +205 -0
- data/spec/vcr/TaxSvc/_cancel_tax/respond_with_success.yml +121 -0
- data/spec/vcr/TaxSvc/_cancel_tax/should_raise_error.yml +58 -0
- data/spec/vcr/TaxSvc/_get_tax/fails/fails_when_no_lines_are_given.yml +60 -0
- data/spec/vcr/TaxSvc/_get_tax/fails/fails_when_no_params_are_given.yml +68 -0
- data/spec/vcr/TaxSvc/_get_tax/fails/responds_with_error_when_result_code_is_not_a_success.yml +61 -0
- data/spec/vcr/TaxSvc/_get_tax/gets_tax_when_all_credentials_are_there.yml +68 -0
- data/spec/vcr/TaxSvc/_ping/should_return_estimate.yml +81 -0
- data/spec/vcr/address_validation_failure.yml +54 -0
- data/spec/vcr/address_validation_success.yml +16 -16
- data/spec/vcr/order_capture.yml +21 -21
- data/spec/vcr/order_capture_finalize.yml +22 -91
- metadata +56 -13
- data/GEM_VERSION +0 -1
- data/app/models/spree/avalara_preference.rb +0 -72
- data/spec/factories/avalara_preference_factory.rb +0 -7
- data/spec/models/spree/avalara_preference_spec.rb +0 -173
- data/spec/vcr/Spree_Payment/_avalara_finalize/should_update_the_amount_to_be_the_order_total.yml +0 -136
@@ -9,23 +9,22 @@
|
|
9
9
|
<% end %>
|
10
10
|
|
11
11
|
<%= form_tag(admin_avatax_settings_path, :method => :put, :id => :avatax_settings_form) do %>
|
12
|
-
|
13
12
|
<div class="yui-g">
|
14
13
|
<div class="yui-u first">
|
15
14
|
<fieldset>
|
16
15
|
<legend><%= Spree.t('avatax_api_keys') %></legend>
|
17
16
|
<p>
|
18
17
|
<label><%= Spree.t('avatax_company_code') %></label><br />
|
19
|
-
<%= text_field_tag('settings[company_code]', Spree::
|
18
|
+
<%= text_field_tag('settings[company_code]', Spree::Avatax::Config.company_code, :maxlength => 256, :class => 'avatax') %>
|
20
19
|
</p>
|
21
20
|
|
22
21
|
<p>
|
23
22
|
<label><%= Spree.t('avatax_account') %></label><br />
|
24
|
-
<%= text_field_tag('settings[account]', Spree::
|
23
|
+
<%= text_field_tag('settings[account]', Spree::Avatax::Config.account, :maxlength => 256, :class => 'avatax') %>
|
25
24
|
</p>
|
26
25
|
<p>
|
27
26
|
<label><%= Spree.t('avatax_license_key') %></label><br />
|
28
|
-
<%= text_field_tag('settings[license_key]', Spree::
|
27
|
+
<%= text_field_tag('settings[license_key]', Spree::Avatax::Config.license_key, :maxlength => 256, :class => 'avatax') %>
|
29
28
|
</p>
|
30
29
|
</fieldset>
|
31
30
|
|
@@ -33,7 +32,7 @@
|
|
33
32
|
<legend><%= Spree.t('avatax_endpoint_urls') %></legend>
|
34
33
|
<p>
|
35
34
|
<label><%= Spree.t('avatax_endpoint') %></label><br />
|
36
|
-
<%= text_field_tag('settings[endpoint]', Spree::
|
35
|
+
<%= text_field_tag('settings[endpoint]', Spree::Avatax::Config.endpoint, :size => 46, :maxlength => 256, :class => 'avatax') %>
|
37
36
|
</p>
|
38
37
|
<p>
|
39
38
|
<label><%= Spree.t('avatax_tax_service_path') %></label><br />
|
@@ -46,54 +45,51 @@
|
|
46
45
|
</fieldset>
|
47
46
|
|
48
47
|
<fieldset>
|
49
|
-
<legend><%= Spree.t('avatax_logging') %></legend>
|
50
48
|
<p>
|
51
|
-
<label><%= Spree.t(
|
52
|
-
<%= check_box_tag
|
49
|
+
<label><%= Spree.t(:avatax_tax_calculation) %>:</label>
|
50
|
+
<%= check_box_tag "settings[tax_calculation]", true, Spree::Avatax::Config.tax_calculation, class: 'avatax' %>
|
53
51
|
</p>
|
52
|
+
|
54
53
|
<p>
|
55
|
-
<label><%= Spree.t(
|
56
|
-
<%= check_box_tag
|
54
|
+
<label><%= Spree.t(:avatax_document_committing) %>:</label>
|
55
|
+
<%= check_box_tag "settings[document_commit]", true, Spree::Avatax::Config.document_commit, class: 'avatax' %>
|
57
56
|
</p>
|
58
57
|
</fieldset>
|
59
58
|
|
60
59
|
<fieldset>
|
61
|
-
<legend><%= Spree.t('avatax_address_validation') %></legend>
|
62
60
|
<p>
|
63
|
-
<label><%= Spree.t(
|
64
|
-
<%= check_box_tag
|
61
|
+
<label><%= Spree.t(:log) %>:</label>
|
62
|
+
<%= check_box_tag "settings[log]", true, Spree::Avatax::Config.log, class: 'avatax' %>
|
65
63
|
</p>
|
66
64
|
<p>
|
67
|
-
<label
|
68
|
-
<%= check_box_tag
|
65
|
+
<label><%= Spree.t(:log_to_stdout) %>:</label>
|
66
|
+
<%= check_box_tag "settings[log_to_stdout]", true, Spree::Avatax::Config.log_to_stdout, class: 'avatax' %>
|
69
67
|
</p>
|
70
68
|
<p>
|
71
|
-
<label
|
72
|
-
<%= check_box_tag
|
69
|
+
<label><%= Spree.t(:raise_exceptions) %>:</label>
|
70
|
+
<%= check_box_tag "settings[raise_exceptions]", true, Spree::Avatax::Config.raise_exceptions, class: 'avatax' %>
|
73
71
|
</p>
|
74
|
-
</fieldset>
|
75
|
-
|
76
|
-
<fieldset>
|
77
|
-
<legend><%= Spree.t('avatax_address_validation_enabled_countries') %></legend>
|
78
72
|
<p>
|
79
|
-
|
80
|
-
|
81
|
-
<%= select_tag('settings[address_validation_enabled_countries]', options_from_collection_for_select(Spree::Country.all, "name", "name", selected: current_countries), multiple: true, class: "select2 fullwidth") %>
|
73
|
+
<label><%= Spree.t(:enable_avatax_address_validation) %>:</label>
|
74
|
+
<%= check_box_tag "settings[address_validation]", true, Spree::Avatax::Config.address_validation, class: 'avatax' %>
|
82
75
|
</p>
|
83
|
-
</fieldset>
|
84
|
-
<fieldset>
|
85
|
-
<legend><%= Spree.t('avatax_tax_calculation') %></legend>
|
86
76
|
<p>
|
87
|
-
<label
|
88
|
-
<%= check_box_tag
|
77
|
+
<label>Refuse Checkout if Address Validation Fails</label>
|
78
|
+
<%= check_box_tag "settings[refuse_checkout_address_validation_error]", true, Spree::Avatax::Config.refuse_checkout_address_validation_error, class: 'avatax' %>
|
89
79
|
</p>
|
80
|
+
<p>
|
81
|
+
<label>Customer can Validate Address in Checkout</label>
|
82
|
+
<%= check_box_tag "settings[customer_can_validate]", true, Spree::Avatax::Config.customer_can_validate, class: 'avatax' %>
|
83
|
+
</p>
|
84
|
+
|
90
85
|
</fieldset>
|
91
86
|
|
92
|
-
|
93
|
-
<legend><%= Spree.t('
|
87
|
+
<fieldset>
|
88
|
+
<legend><%= Spree.t('avatax_address_validation_enabled_countries') %></legend>
|
94
89
|
<p>
|
95
|
-
|
96
|
-
|
90
|
+
<% current_countries = Spree::Country.where(name: Spree::Avatax::Config.address_validation_enabled_countries) %>
|
91
|
+
<label><%= Spree.t('avatax_address_validation_enabled_countries') %></label><br />
|
92
|
+
<%= select_tag('settings[address_validation_enabled_countries]', options_from_collection_for_select(Spree::Country.all, "name", "name", selected: current_countries), multiple: true, class: "select2 fullwidth") %>
|
97
93
|
</p>
|
98
94
|
</fieldset>
|
99
95
|
|
@@ -132,34 +128,18 @@
|
|
132
128
|
<a href="#" class="button address_validator" style="float: right;">Validate</a>
|
133
129
|
</fieldset>
|
134
130
|
<fieldset>
|
135
|
-
<legend><%= Spree.t('
|
136
|
-
<p>
|
131
|
+
<legend><%= Spree.t('avatax_log') %></legend>
|
132
|
+
<p>The avatax log is located in the log directory of your spree app.</p>
|
137
133
|
<table>
|
138
134
|
<tr>
|
139
135
|
<td>
|
140
136
|
<table>
|
141
137
|
<tr>
|
142
|
-
<td>
|
143
|
-
<td><%= link_to("Download", {controller: :avatax_settings, action: :
|
144
|
-
</td>
|
145
|
-
<td>
|
146
|
-
<%= link_to("Clear Data", {controller: :avatax_settings, action: :erase_data, remote: true, log_name: "tax_svc"}) %>
|
147
|
-
</td>
|
148
|
-
</tr>
|
149
|
-
<tr>
|
150
|
-
<td>Avalara Function calls - post_order_to_avalara.log</td>
|
151
|
-
<td><%= link_to("Download", {controller: :avatax_settings, action: :get_file_post_order_to_avalara}) %>
|
152
|
-
</td>
|
153
|
-
<td>
|
154
|
-
<%= link_to("Clear Data", {controller: :avatax_settings, action: :erase_data, remote: true, log_name: "post_order_to_avalara"}) %>
|
155
|
-
</td>
|
156
|
-
</tr>
|
157
|
-
<tr>
|
158
|
-
<td>Spree Order Item integration calls - avalara_order.log</td>
|
159
|
-
<td><%= link_to("Download", {controller: :avatax_settings, action: :get_file_avalara_order}) %>
|
138
|
+
<td>Avatax Log - avatax.log</td>
|
139
|
+
<td><%= link_to("Download", { controller: :avatax_settings, action: :download_avatax_log }) %>
|
160
140
|
</td>
|
161
141
|
<td>
|
162
|
-
<%= link_to("Clear Data", {controller: :avatax_settings, action: :erase_data, remote: true
|
142
|
+
<%= link_to("Clear Data", { controller: :avatax_settings, action: :erase_data, remote: true }) %>
|
163
143
|
</td>
|
164
144
|
</tr>
|
165
145
|
</table>
|
@@ -11,19 +11,19 @@
|
|
11
11
|
<table>
|
12
12
|
<tr>
|
13
13
|
<th scope="row"><%= Spree.t(:avatax_company_code) %>:</th>
|
14
|
-
<td><%= Spree::
|
14
|
+
<td><%= Spree::Avatax::Config.company_code %></td>
|
15
15
|
</tr>
|
16
16
|
<tr>
|
17
17
|
<th scope="row"><%= Spree.t(:avatax_license_key) %>:</th>
|
18
|
-
<td><%= Spree::
|
18
|
+
<td><%= Spree::Avatax::Config.license_key %></td>
|
19
19
|
</tr>
|
20
20
|
<tr>
|
21
21
|
<th scope="row"><%= Spree.t(:avatax_account) %>:</th>
|
22
|
-
<td><%= Spree::
|
22
|
+
<td><%= Spree::Avatax::Config.account %></td>
|
23
23
|
</tr>
|
24
24
|
<tr>
|
25
25
|
<th scope="row"><%= Spree.t(:avatax_endpoint) %>:</th>
|
26
|
-
<td><%= Spree::
|
26
|
+
<td><%= Spree::Avatax::Config.endpoint %></td>
|
27
27
|
</tr>
|
28
28
|
<tr>
|
29
29
|
<th scope="row"><%= Spree.t(:avatax_tax_service_path) %>:</th>
|
@@ -34,28 +34,40 @@
|
|
34
34
|
<td><%= AVATAX_SERVICEPATH_ADDRESS %></td>
|
35
35
|
</tr>
|
36
36
|
<tr>
|
37
|
-
<th scope="row"><%= Spree.t(:
|
38
|
-
<td><%= Spree::
|
37
|
+
<th scope="row"><%= Spree.t(:enable_avatax_tax_calculation) %>:</th>
|
38
|
+
<td><%= Spree::Avatax::Config.tax_calculation %></td>
|
39
39
|
</tr>
|
40
40
|
<tr>
|
41
|
-
<th scope="row"><%= Spree.t(:
|
42
|
-
<td><%= Spree::
|
41
|
+
<th scope="row"><%= Spree.t(:enable_avatax_document_committing) %>:</th>
|
42
|
+
<td><%= Spree::Avatax::Config.document_commit %></td>
|
43
|
+
</tr>
|
44
|
+
<tr>
|
45
|
+
<th scope="row"><%= Spree.t(:log) %>:</th>
|
46
|
+
<td><%= Spree::Avatax::Config.log %></td>
|
47
|
+
</tr>
|
48
|
+
<tr>
|
49
|
+
<th scope="row"><%= Spree.t(:log_to_stdout) %>:</th>
|
50
|
+
<td><%= Spree::Avatax::Config.log_to_stdout %></td>
|
51
|
+
</tr>
|
52
|
+
<tr>
|
53
|
+
<th scope="row"><%= Spree.t(:raise_exceptions) %>:</th>
|
54
|
+
<td><%= Spree::Avatax::Config.raise_exceptions %></td>
|
43
55
|
</tr>
|
44
56
|
<tr>
|
45
57
|
<th scope="row"><%= Spree.t(:enable_avatax_address_validation) %>:</th>
|
46
|
-
<td><%= Spree::
|
58
|
+
<td><%= Spree::Avatax::Config.address_validation %></td>
|
47
59
|
</tr>
|
48
60
|
<tr>
|
49
61
|
<th scope="row">Refuse Checkout if Address Validation Fails</th>
|
50
|
-
<td><%= Spree::
|
62
|
+
<td><%= Spree::Avatax::Config.refuse_checkout_address_validation_error %></td>
|
51
63
|
</tr>
|
52
64
|
<tr>
|
53
65
|
<th scope="row">Customer can Validate Address in Checkout</th>
|
54
|
-
<td><%= Spree::
|
66
|
+
<td><%= Spree::Avatax::Config.customer_can_validate %></td>
|
55
67
|
</tr>
|
56
68
|
<tr>
|
57
69
|
<th scope="row"><%= Spree.t(:avatax_address_validation_enabled_countries) %>:</th>
|
58
|
-
<% address_validated_countries = Spree::
|
70
|
+
<% address_validated_countries = Spree::Avatax::Config.address_validation_enabled_countries %>
|
59
71
|
<td>
|
60
72
|
<% unless address_validated_countries.nil? %>
|
61
73
|
<ul style="list-style: inside;">
|
@@ -66,14 +78,6 @@
|
|
66
78
|
<% end %>
|
67
79
|
</td>
|
68
80
|
</tr>
|
69
|
-
<tr>
|
70
|
-
<th scope="row"><%= Spree.t(:enable_avatax_tax_calculation) %>:</th>
|
71
|
-
<td><%= Spree::AvalaraPreference.tax_calculation.value %></td>
|
72
|
-
</tr>
|
73
|
-
<tr>
|
74
|
-
<th scope="row"><%= Spree.t(:enable_avatax_document_committing) %>:</th>
|
75
|
-
<td><%= Spree::AvalaraPreference.document_commit.value %></td>
|
76
|
-
</tr>
|
77
81
|
|
78
82
|
<tr>
|
79
83
|
<th scope="row"><%= Spree.t(:business_address) %>:</th>
|
@@ -99,23 +103,12 @@
|
|
99
103
|
|
100
104
|
|
101
105
|
<tr>
|
102
|
-
<th
|
106
|
+
<th><%= Spree.t('avatax_log') %></th>
|
103
107
|
<td>
|
104
|
-
|
108
|
+
The avatax log is located in the log directory of your spree app.
|
105
109
|
<table>
|
106
|
-
|
107
|
-
<td
|
108
|
-
<td><%= link_to("Download", {controller: :avatax_settings, action: :get_file_txt_tax_svc}) %>
|
109
|
-
</td>
|
110
|
-
</tr>
|
111
|
-
<tr>
|
112
|
-
<td>Avalara Function calls - post_order_to_avalara.log</td>
|
113
|
-
<td><%= link_to("Download", {controller: :avatax_settings, action: :get_file_post_order_to_avalara}) %>
|
114
|
-
</td>
|
115
|
-
</tr>
|
116
|
-
<tr>
|
117
|
-
<td>Spree Order Item integration calls - avalara_order.log</td>
|
118
|
-
<td><%= link_to("Download", {controller: :avatax_settings, action: :get_file_avalara_order}) %>
|
110
|
+
<td>Avatax Log - avatax.log</td>
|
111
|
+
<td><%= link_to("Download", { controller: :avatax_settings, action: :download_avatax_log }) %>
|
119
112
|
</td>
|
120
113
|
</tr>
|
121
114
|
</table>
|
@@ -1,5 +1,14 @@
|
|
1
|
-
gem_version = File.read(File.expand_path('../../../GEM_VERSION',__FILE__)).strip
|
2
|
-
|
3
1
|
AVATAX_CLIENT_VERSION = "a0o33000004FH8l"
|
4
2
|
AVATAX_SERVICEPATH_ADDRESS = '/1.0/address/'
|
5
3
|
AVATAX_SERVICEPATH_TAX = '/1.0/tax/'
|
4
|
+
|
5
|
+
module Spree
|
6
|
+
module Avatax
|
7
|
+
Config = Spree::AvataxConfiguration.new
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Spree::Avatax::Config.company_code = ENV['AVATAX_COMPANY_CODE'] if ENV['AVATAX_COMPANY_CODE']
|
12
|
+
Spree::Avatax::Config.account = ENV['AVATAX_ACCOUNT'] if ENV['AVATAX_ACCOUNT']
|
13
|
+
Spree::Avatax::Config.license_key = ENV['AVATAX_LICENSE_KEY'] if ENV['AVATAX_LICENSE_KEY']
|
14
|
+
Spree::Avatax::Config.endpoint = ENV['AVATAX_ENDPOINT'] if ENV['AVATAX_ENDPOINT']
|
data/config/locales/en.yml
CHANGED
@@ -16,8 +16,13 @@ en:
|
|
16
16
|
avatax_endpoint: Avatax Endpoint
|
17
17
|
avatax_tax_service_path: Avatax Tax Service Path
|
18
18
|
avatax_address_service_path: Avatax Address Service Path
|
19
|
-
|
20
|
-
|
19
|
+
log: Enable Avatax Logging to log/avatax.log
|
20
|
+
log_to_stdout: Enable Logging to STDOUT
|
21
|
+
tax_calculation: Tax Calculation
|
22
|
+
document_commit: Document Committing
|
23
|
+
address_validation: Address Validation
|
24
|
+
refuse_checkout_address_validation_error: Refuse Checkout if Address Validation Fails
|
25
|
+
customer_can_validate: Customer can Validate address on address page
|
21
26
|
enable_avatax_address_validation: Enable Address Validation
|
22
27
|
avatax_address_validation_enabled_countries: Address Validation Enabled Countries
|
23
28
|
enable_avatax_tax_calculation: Enable Avatax Tax Calculation
|
@@ -29,7 +34,8 @@ en:
|
|
29
34
|
avatax_endpoint_urls: Avatax Endpoint URLs
|
30
35
|
avatax_logging: Avatax Logging
|
31
36
|
avatax_address_validation: Avatax Address Validation
|
32
|
-
|
37
|
+
avatax_log: Avatax Log
|
33
38
|
avatax_tax_calculation: Avatax Tax Calculation
|
34
39
|
avatax_document_committing: Avatax Document Committing
|
35
40
|
save_preferences: Save Preferences
|
41
|
+
raise_exceptions: Raise Exceptions
|
data/config/routes.rb
CHANGED
@@ -3,7 +3,7 @@ Spree::Core::Engine.routes.draw do
|
|
3
3
|
resources :avalara_entity_use_codes
|
4
4
|
|
5
5
|
resource :avatax_settings do
|
6
|
-
get :ping_my_service, :
|
6
|
+
get :ping_my_service, :download_avatax_log, :erase_data, :validate_address
|
7
7
|
end
|
8
8
|
|
9
9
|
resources :users do
|
@@ -1,8 +1,5 @@
|
|
1
1
|
module SolidusAvataxCertified
|
2
2
|
class PreferenceSeeder
|
3
|
-
BOOLEAN_PREFERENCES = ['log', 'address_validation', 'tax_calculation', 'document_commit', 'log_to_stdout', 'refuse_checkout_address_validation_error', 'customer_can_validate'].freeze
|
4
|
-
STORABLE_ENV_PREFERENCES = ['company_code', 'endpoint', 'account', 'license_key'].freeze
|
5
|
-
|
6
3
|
class << self
|
7
4
|
|
8
5
|
def seed!(print_messages=true)
|
@@ -16,49 +13,34 @@ module SolidusAvataxCertified
|
|
16
13
|
protected
|
17
14
|
|
18
15
|
def stored_env_prefs
|
19
|
-
|
16
|
+
Spree::AvataxConfiguration.storable_env_preferences.each do |env|
|
20
17
|
if !ENV["AVATAX_#{env.upcase}"].blank?
|
21
18
|
value = ENV["AVATAX_#{env.upcase}"]
|
22
19
|
else
|
23
20
|
value = nil
|
24
21
|
end
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
save_preference(pref)
|
23
|
+
Spree::Avatax::Config[env.to_sym] = value
|
29
24
|
end
|
30
25
|
end
|
31
26
|
|
32
27
|
def boolean_prefs
|
33
|
-
|
34
|
-
if ['refuse_checkout_address_validation_error', 'log_to_stdout'].include?(preference)
|
35
|
-
|
28
|
+
Spree::AvataxConfiguration.boolean_preferences.each do |preference|
|
29
|
+
if ['refuse_checkout_address_validation_error', 'log_to_stdout', 'raise_exceptions'].include?(preference)
|
30
|
+
Spree::Avatax::Config[preference.to_sym] = false
|
36
31
|
else
|
37
|
-
|
32
|
+
Spree::Avatax::Config[preference.to_sym] = true
|
38
33
|
end
|
39
|
-
|
40
|
-
save_preference(pref)
|
41
34
|
end
|
42
35
|
end
|
43
36
|
|
44
37
|
def enabled_countries_pref
|
45
|
-
|
46
|
-
save_preference(pref)
|
38
|
+
Spree::Avatax::Config.address_validation_enabled_countries = ['United States', 'Canada']
|
47
39
|
end
|
48
40
|
|
49
41
|
def origin_address
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
save_preference(pref)
|
54
|
-
end
|
55
|
-
|
56
|
-
def save_preference(preference)
|
57
|
-
if preference.save
|
58
|
-
success_message(preference) if @print_messages
|
59
|
-
else
|
60
|
-
puts "#{preference.errors.full_messages.to_sentence}"
|
61
|
-
end
|
42
|
+
origin = Spree::Avatax::Config.origin
|
43
|
+
origin = "{}" if origin.nil?
|
62
44
|
end
|
63
45
|
|
64
46
|
def success_message(preference)
|
@@ -1,17 +1,20 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require 'solidus_avatax_certified/version'
|
3
6
|
|
4
7
|
Gem::Specification.new do |s|
|
5
8
|
s.platform = Gem::Platform::RUBY
|
6
9
|
s.name = 'solidus_avatax_certified'
|
7
|
-
s.version =
|
10
|
+
s.version = SolidusAvataxCertified::VERSION
|
8
11
|
s.summary = 'Solidus extension for Avalara tax calculation.'
|
9
12
|
s.description = 'Solidus extension for Avalara tax calculation.'
|
10
13
|
s.required_ruby_version = '>= 2.1'
|
11
14
|
|
12
15
|
s.author = 'Allison Reilly'
|
13
16
|
s.email = 'acreilly3@gmail.com'
|
14
|
-
s.homepage = 'http://www.
|
17
|
+
s.homepage = 'http://www.boomerdigital.net'
|
15
18
|
|
16
19
|
s.files = `git ls-files`.split("\n")
|
17
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -14,24 +14,24 @@ describe Spree::Admin::AvataxSettingsController, :type => :controller do
|
|
14
14
|
it { should be_success }
|
15
15
|
end
|
16
16
|
|
17
|
-
describe '/avatax_settings/
|
18
|
-
before { File.new("#{Rails.root}/log/
|
19
|
-
after { File.delete("#{Rails.root}/log/
|
17
|
+
describe '/avatax_settings/download_avatax_log' do
|
18
|
+
before { File.new("#{Rails.root}/log/avatax.log", 'w') }
|
19
|
+
after { File.delete("#{Rails.root}/log/avatax.log") }
|
20
20
|
|
21
|
-
subject { get :
|
21
|
+
subject { get :download_avatax_log }
|
22
22
|
it { should be_success }
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '/avatax_settings/erase_data' do
|
26
26
|
it 'erases the log' do
|
27
27
|
Dir.mkdir('log') unless Dir.exist?('log')
|
28
|
-
file = File.open("log/
|
28
|
+
file = File.open("log/avatax.log", 'w') { |f| f.write('Hyah!') }
|
29
29
|
|
30
|
-
expect(File.read('log/
|
30
|
+
expect(File.read('log/avatax.log')).to eq('Hyah!')
|
31
31
|
|
32
|
-
get :erase_data
|
32
|
+
get :erase_data
|
33
33
|
|
34
|
-
expect(File.read('log/
|
34
|
+
expect(File.read('log/avatax.log')).to eq('')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
|
3
|
+
factory :response_hash_success, class: Hash do
|
4
|
+
ResultCode 'Success'
|
5
|
+
DocCode 'R207073277'
|
6
|
+
DocDate '2017-03-22'
|
7
|
+
Timestamp '2017-03-22T19:58:32.6529101Z'
|
8
|
+
TotalAmount '15'
|
9
|
+
TotalDiscount '0'
|
10
|
+
TotalExemption '0'
|
11
|
+
TotalTaxable '15'
|
12
|
+
TotalTax '0.6'
|
13
|
+
TotalTaxCalculated '0.6'
|
14
|
+
TaxLines [
|
15
|
+
{'LineNo'=>'1-LI',
|
16
|
+
'TaxCode'=>'PC030000',
|
17
|
+
'Taxability'=>'true',
|
18
|
+
'BoundaryLevel'=>'Zip5',
|
19
|
+
'Exemption'=>'0',
|
20
|
+
'Discount'=>'0',
|
21
|
+
'Taxable'=>'10',
|
22
|
+
'Rate'=>'0.040000',
|
23
|
+
'Tax'=>'0.4',
|
24
|
+
'TaxCalculated'=>'0.4',
|
25
|
+
'TaxDetails'=>
|
26
|
+
[{'Country'=>'US',
|
27
|
+
'Region'=>'AL',
|
28
|
+
'JurisType'=>'State',
|
29
|
+
'JurisCode'=>'01',
|
30
|
+
'Taxable'=>'10',
|
31
|
+
'Rate'=>'0.040000',
|
32
|
+
'Tax'=>'0.4',
|
33
|
+
'JurisName'=>'ALABAMA',
|
34
|
+
'TaxName'=>'AL STATE TAX'}]},
|
35
|
+
{'LineNo'=>'1-FR',
|
36
|
+
'TaxCode'=>'FR000000',
|
37
|
+
'Taxability'=>'true',
|
38
|
+
'BoundaryLevel'=>'Zip5',
|
39
|
+
'Exemption'=>'0',
|
40
|
+
'Discount'=>'0',
|
41
|
+
'Taxable'=>'5',
|
42
|
+
'Rate'=>'0.040000',
|
43
|
+
'Tax'=>'0.2',
|
44
|
+
'TaxCalculated'=>'0.2',
|
45
|
+
'TaxDetails'=>
|
46
|
+
[{'Country'=>'US',
|
47
|
+
'Region'=>'AL',
|
48
|
+
'JurisType'=>'State',
|
49
|
+
'JurisCode'=>'01',
|
50
|
+
'Taxable'=>'5',
|
51
|
+
'Rate'=>'0.040000',
|
52
|
+
'Tax'=>'0.2',
|
53
|
+
'JurisName'=>'ALABAMA',
|
54
|
+
'TaxName'=>'AL STATE TAX'}]}
|
55
|
+
]
|
56
|
+
TaxAddresses [
|
57
|
+
{'Address'=>'A Different Road',
|
58
|
+
'AddressCode'=>'Dest',
|
59
|
+
'City'=>'Montgomery',
|
60
|
+
'Country'=>'US',
|
61
|
+
'PostalCode'=>'36104',
|
62
|
+
'Region'=>'AL',
|
63
|
+
'TaxRegionId'=>'2052799',
|
64
|
+
'JurisCode'=>'0110151000'},
|
65
|
+
{'Address'=>'1600 Pennsylvania Ave NW',
|
66
|
+
'AddressCode'=>'2',
|
67
|
+
'City'=>'Washington',
|
68
|
+
'Country'=>'US',
|
69
|
+
'PostalCode'=>'20500',
|
70
|
+
'Region'=>'DC',
|
71
|
+
'TaxRegionId'=>'0',
|
72
|
+
'JurisCode'=>'1100000000'}
|
73
|
+
]
|
74
|
+
TaxDate '2017-03-22'
|
75
|
+
end
|
76
|
+
|
77
|
+
factory :response_hash_error, class: Hash do
|
78
|
+
ResultCode 'Error'
|
79
|
+
Messages [
|
80
|
+
{
|
81
|
+
'Summary'=>'Lines[0].TaxCode length must be between 0 and 25 characters.',
|
82
|
+
'RefersTo'=>'Lines[0].TaxCode',
|
83
|
+
'Severity'=>'Error',
|
84
|
+
'Source'=>'Avalara.AvaTax.Services'
|
85
|
+
}
|
86
|
+
]
|
87
|
+
end
|
88
|
+
end
|
@@ -147,7 +147,7 @@ describe "Checkout", :vcr, type: :feature, inaccessible: true do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def visit_delivery
|
150
|
-
VCR.use_cassette('address_validation_success') do
|
150
|
+
VCR.use_cassette('address_validation_success', allow_playback_repeats: true) do
|
151
151
|
visit_address
|
152
152
|
fill_in_address
|
153
153
|
click_button 'Save and Continue'
|
data/spec/features/vat_spec.rb
CHANGED
@@ -140,7 +140,7 @@ describe "VAT", :vcr do
|
|
140
140
|
|
141
141
|
|
142
142
|
def set_seller_location
|
143
|
-
Spree::
|
143
|
+
Spree::Avatax::Config.origin = "{\"Address1\":\"34 Borgo degli Albizi\",\"Address2\":\"\",\"City\":\"Florence\",\"Region\":\"\",\"Zip5\":\"50122\",\"Zip4\":\"\",\"Country\":\"IT\"}"
|
144
144
|
Spree::StockLocation.update_all(address1: '150 Piccadilly', city: 'Florence', country_id: it.id)
|
145
145
|
end
|
146
146
|
|