spree_exactor 1.1.4.20130729 → 1.1.5.20130731
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/helpers/spree_exactor_connector.rb +13 -4
- data/app/models/spree/calculator/exactor_tax_calculator.rb +4 -0
- data/app/models/spree/order_decorator.rb +29 -1
- data/app/models/spree/shipment_decorator.rb +17 -0
- data/db/migrate/20130731110400_add_commit_option_to_order.rb +5 -0
- data/lib/generators/spree_exactor/install/install_generator.rb +1 -0
- data/spree_exactor.gemspec +3 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0f00d92c091463778e6980f170f498afefc09e4
|
4
|
+
data.tar.gz: 357356a22904958b90db1590392cac48f651aecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: effe15c9dea6eac0de075d1584084450db437a45be19be2979dc844a58f05ba1b1193a875a3c973878eedad7f508c115767219ea67cd9fc7563637ab7b41c1ff
|
7
|
+
data.tar.gz: 360f65ff9dbedb539a3bae5a471010aad150d66221a1b98f3494037196ed0b3cdcc0abdcd1707e989f5a7c08c81d12aac5fa7b455a1ed59581118a13293372c4
|
data/Gemfile.lock
CHANGED
@@ -4,7 +4,7 @@ require 'bigdecimal/util'
|
|
4
4
|
|
5
5
|
module SpreeExactorConnector
|
6
6
|
class SpreeExactorConnector
|
7
|
-
PLUGIN_VERSION = "
|
7
|
+
PLUGIN_VERSION = "20130731"
|
8
8
|
TEST_TRANSACTION_NAME = "Spree Test Transaction"
|
9
9
|
TEST_ITEM_DESRIPTION = "Exactor Account Verification. Plug-in version:"
|
10
10
|
PLUGIN_NAME = "SpreeCommerce"
|
@@ -115,6 +115,7 @@ module SpreeExactorConnector
|
|
115
115
|
if (response.is_valid)
|
116
116
|
order.update_column(:exactor_invoice_transaction, nil)
|
117
117
|
order.update_column(:exactor_commit_transaction, response.commit_id)
|
118
|
+
order.update_column(:exactor_commit_option, @settings.commit_option)
|
118
119
|
else
|
119
120
|
order.errors[:base]<<"Tax calculation failure: #{response.error_code}:#{response.error_description}"
|
120
121
|
end
|
@@ -122,7 +123,9 @@ module SpreeExactorConnector
|
|
122
123
|
end
|
123
124
|
|
124
125
|
def do_cancel!(order)
|
125
|
-
if can_be_handled?(Spree::ExactorSetting::COMMIT_OPTIONS::TRANSACTION_STATE, order) or
|
126
|
+
if can_be_handled?(Spree::ExactorSetting::COMMIT_OPTIONS::TRANSACTION_STATE, order) or
|
127
|
+
can_be_handled?(Spree::ExactorSetting::COMMIT_OPTIONS::PAYMENT_STATE, order)
|
128
|
+
can_be_handled?(Spree::ExactorSetting::COMMIT_OPTIONS::SHIPMENT_STATE, order)
|
126
129
|
if !order.exactor_commit_transaction.nil?
|
127
130
|
response = refund_transaction(order)
|
128
131
|
if (response.is_valid)
|
@@ -154,13 +157,19 @@ module SpreeExactorConnector
|
|
154
157
|
if (can_be_handled?(Spree::ExactorSetting::COMMIT_OPTIONS::PAYMENT_STATE, order))
|
155
158
|
update_tax_if_needed(order)
|
156
159
|
resp = nil
|
160
|
+
|
161
|
+
# Check a case: transaction has been committed on transaction state, then user changed commit option to payment state and paid for the order.
|
162
|
+
if order.exactor_commit_transaction and order.exactor_commit_option != Spree::ExactorSetting::COMMIT_OPTIONS::TRANSACTION_STATE
|
163
|
+
return
|
164
|
+
end
|
165
|
+
|
157
166
|
if order.exactor_commit_transaction
|
158
167
|
resp = refund_transaction(order)
|
159
168
|
end
|
160
|
-
if
|
169
|
+
if !resp or resp.is_valid
|
161
170
|
resp = do_commit!(order)
|
162
171
|
end
|
163
|
-
if
|
172
|
+
if !resp.is_valid
|
164
173
|
order.current_payment.errors[:base]<<"Tax synchronization failure: #{resp.error_code}:#{resp.error_description}" unless order.current_payment.nil?
|
165
174
|
end
|
166
175
|
end
|
@@ -13,6 +13,10 @@ class Spree::Calculator::ExactorTaxCalculator < Spree::Calculator
|
|
13
13
|
# don't try to calculate hash for partially formed order
|
14
14
|
return false unless is_full?(computable)
|
15
15
|
|
16
|
+
return false if !computable.updated_shipment_count.nil? and !computable.is_last_shipment_updated?
|
17
|
+
|
18
|
+
computable.updated_shipment_count_reset
|
19
|
+
|
16
20
|
order_hash = exactor.calculate_hash(computable)
|
17
21
|
current_order_hash = Spree::Order.find(computable.id).exactor_order_hash_sum
|
18
22
|
result = order_hash!=current_order_hash
|
@@ -68,7 +68,7 @@ module Spree
|
|
68
68
|
end
|
69
69
|
|
70
70
|
Order.class_eval do
|
71
|
-
attr_accessible :exactor_invoice_transaction, :exactor_commit_transaction, :exactor_order_hash_sum, :exactor_is_edit
|
71
|
+
attr_accessible :exactor_invoice_transaction, :exactor_commit_transaction, :exactor_order_hash_sum, :exactor_is_edit, :exactor_commit_option
|
72
72
|
after_save :on_saved
|
73
73
|
attr_accessor :current_payment
|
74
74
|
|
@@ -93,5 +93,33 @@ module Spree
|
|
93
93
|
on_update
|
94
94
|
update_column(:exactor_is_edit, nil);
|
95
95
|
end
|
96
|
+
|
97
|
+
# WORKAROUND BEGIN
|
98
|
+
# Reloading or submitting of delivery page leads to shipment recreation every time.
|
99
|
+
# The problem appears if user changes shipping methods for more than one packages.
|
100
|
+
# Spree invoke tax recalculation for each change. We count updated shipments.
|
101
|
+
# And if last update took a place then invoke tax recalculation.
|
102
|
+
|
103
|
+
@@updated_shipment_counter = Hash.new(nil)
|
104
|
+
|
105
|
+
def updated_shipment_count
|
106
|
+
return nil if @@updated_shipment_counter.nil?
|
107
|
+
return @@updated_shipment_counter[self.id]
|
108
|
+
end
|
109
|
+
|
110
|
+
def is_last_shipment_updated?
|
111
|
+
self.updated_shipment_count >= self.shipments.size
|
112
|
+
end
|
113
|
+
|
114
|
+
def updated_shipment_count_reset
|
115
|
+
@@updated_shipment_counter[self.id] = nil
|
116
|
+
end
|
117
|
+
|
118
|
+
def updated_shipment_count_inc
|
119
|
+
@@updated_shipment_counter[self.id] = 0 if self.updated_shipment_count.nil?
|
120
|
+
|
121
|
+
@@updated_shipment_counter[self.id] += 1
|
122
|
+
end
|
123
|
+
# WORKAROUND END
|
96
124
|
end
|
97
125
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spree
|
2
|
+
|
3
|
+
Shipment.class_eval do
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
class Shipment
|
8
|
+
alias :super_selected_shipping_rate_id= :selected_shipping_rate_id=
|
9
|
+
|
10
|
+
def selected_shipping_rate_id=(id)
|
11
|
+
self.order.updated_shipment_count_inc
|
12
|
+
|
13
|
+
self.super_selected_shipping_rate_id=id
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -12,6 +12,7 @@ module SpreeExactor
|
|
12
12
|
supported_versions '1.1.2.20130723'=>['2.0.*']
|
13
13
|
supported_versions '1.1.3.20130726'=>['2.0.*']
|
14
14
|
supported_versions '1.1.4.20130729'=>['2.0.*']
|
15
|
+
supported_versions '1.1.5.20130731'=>['2.0.*']
|
15
16
|
unless @supported_versions.include? _plugin_version
|
16
17
|
puts "Unknown plug-in version. Try any of those: "+ @supported_versions.keys.to_s
|
17
18
|
exit(0)
|
data/spree_exactor.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.platform = Gem::Platform::RUBY
|
4
4
|
s.name = 'spree_exactor'
|
5
|
-
s.version = '1.1.
|
5
|
+
s.version = '1.1.5.20130731'
|
6
6
|
s.summary = 'Exactor sales tax compliance module for SpreeCommerce'
|
7
7
|
s.description = 'Sales tax compliance module for (i) calculating sales tax with SpreeCommerce; and (ii) generating and filing sales tax returns in all US jurisdictions (state and local).'
|
8
8
|
s.required_ruby_version = '>= 2.0.0'
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"db/migrate/20120713152512_modify_dependent_entities.rb",
|
26
26
|
"db/migrate/20120813124740_extend_user.rb",
|
27
27
|
"db/migrate/20120815104739_add_exactor_tor_inline_tax.rb",
|
28
|
+
"db/migrate/20130731110400_add_commit_option_to_order.rb",
|
28
29
|
"config/routes.rb",
|
29
30
|
"config/locales/en.yml",
|
30
31
|
".rspec",
|
@@ -45,6 +46,7 @@ Gem::Specification.new do |s|
|
|
45
46
|
"app/models/spree/line_item_decorator.rb",
|
46
47
|
"app/models/spree/order_decorator.rb",
|
47
48
|
"app/models/spree/order_updater_decorator.rb",
|
49
|
+
"app/models/spree/shipment_decorator.rb",
|
48
50
|
"app/models/spree/tax_rate_decorator.rb",
|
49
51
|
"app/models/spree/adjustment_decorator.rb",
|
50
52
|
"app/models/spree/payment_decorator.rb",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_exactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5.20130731
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Exactor, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- db/migrate/20120713152512_modify_dependent_entities.rb
|
88
88
|
- db/migrate/20120813124740_extend_user.rb
|
89
89
|
- db/migrate/20120815104739_add_exactor_tor_inline_tax.rb
|
90
|
+
- db/migrate/20130731110400_add_commit_option_to_order.rb
|
90
91
|
- config/routes.rb
|
91
92
|
- config/locales/en.yml
|
92
93
|
- .rspec
|
@@ -107,6 +108,7 @@ files:
|
|
107
108
|
- app/models/spree/line_item_decorator.rb
|
108
109
|
- app/models/spree/order_decorator.rb
|
109
110
|
- app/models/spree/order_updater_decorator.rb
|
111
|
+
- app/models/spree/shipment_decorator.rb
|
110
112
|
- app/models/spree/tax_rate_decorator.rb
|
111
113
|
- app/models/spree/adjustment_decorator.rb
|
112
114
|
- app/models/spree/payment_decorator.rb
|