effective_orders 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/effective/providers/moneris.rb +5 -1
- data/app/models/effective/cart_item.rb +3 -3
- data/app/models/effective/datatables/orders.rb +27 -10
- data/app/models/effective/order.rb +4 -2
- data/app/models/effective/order_item.rb +2 -2
- data/app/models/effective/subscription.rb +1 -1
- data/app/views/effective/orders/_order_shipping.html.haml +4 -4
- data/lib/effective_orders.rb +2 -2
- data/lib/effective_orders/version.rb +1 -1
- data/spec/dummy/log/test.log +7 -0
- data/spec/models/subscription_spec.rb +1 -1
- metadata +102 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18b94b140cb5e27733403db8ff5c2f2d5334ec53
|
4
|
+
data.tar.gz: 5b50dd174ecb6da78ffadcedc8268c75dc238815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a7cab5b36a1ef78644e174b338862e256ab15a7d7f5debbcb41174eec48958b22b52bb9b1826aac9b5caa0b95daf7f62f70f1fbe1de142c878573ed47f3c569
|
7
|
+
data.tar.gz: 80193c2d5065a6fc1689a267cbe3efb8225898fbbaa3026103ecdf0914b54d2f7e7c3b5e15de67473e05ca032271c56088b8d66456325e9759ec69f466870683
|
@@ -8,7 +8,11 @@ module Effective
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def moneris_postback
|
11
|
-
|
11
|
+
response_order_id = (EffectiveOrders.obfuscate_order_ids == true ? Effective::Order.deobfuscate(params[:response_order_id]).to_i : params[:response_order_id].to_i)
|
12
|
+
response_order_id = response_order_id - EffectiveOrders.moneris[:order_nudge].to_i
|
13
|
+
|
14
|
+
@order ||= Effective::Order.find_by_id(response_order_id)
|
15
|
+
raise ActiveRecord::RecordNotFound unless @order
|
12
16
|
|
13
17
|
EffectiveOrders.authorized?(self, :update, @order)
|
14
18
|
|
@@ -20,8 +20,8 @@ module Effective
|
|
20
20
|
if (purchasable.price || 0).kind_of?(Integer)
|
21
21
|
purchasable.price || 0
|
22
22
|
else
|
23
|
-
ActiveSupport::Deprecation.warn('price is a non-integer. It should be an Integer representing the number of cents. Continuing with (price * 100.0).
|
24
|
-
(purchasable.price * 100.0).
|
23
|
+
ActiveSupport::Deprecation.warn('price is a non-integer. It should be an Integer representing the number of cents. Continuing with (price * 100.0).round(0).to_i conversion') unless EffectiveOrders.silence_deprecation_warnings
|
24
|
+
(purchasable.price * 100.0).round(0).to_i rescue 0
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -30,7 +30,7 @@ module Effective
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def tax
|
33
|
-
tax_exempt ? 0 : (subtotal * tax_rate).
|
33
|
+
tax_exempt ? 0 : (subtotal * tax_rate).round(0).to_i
|
34
34
|
end
|
35
35
|
|
36
36
|
def total
|
@@ -2,24 +2,26 @@ if defined?(EffectiveDatatables)
|
|
2
2
|
module Effective
|
3
3
|
module Datatables
|
4
4
|
class Orders < Effective::Datatable
|
5
|
+
default_order :purchased_at, :desc
|
6
|
+
|
5
7
|
table_column :id do |order|
|
6
8
|
order.to_param
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
|
-
link_to order
|
11
|
+
table_column :email, :column => 'users.email', :label => 'Buyer', :if => Proc.new { attributes[:user_id].blank? } do |order|
|
12
|
+
link_to order[:email], (edit_admin_user_path(order.user_id) rescue admin_user_path(order.user_id) rescue '#')
|
11
13
|
end
|
12
14
|
|
13
|
-
|
15
|
+
table_column :order_items, :sortable => false, :column => 'order_items.title' do |order|
|
14
16
|
content_tag(:ul) do
|
15
|
-
order
|
17
|
+
order[:order_items].split('!!OI!!').map { |oi| content_tag(:li, oi) }.join().html_safe
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
table_column :purchased_at
|
20
22
|
|
21
|
-
|
22
|
-
price_to_currency(order.
|
23
|
+
table_column :total do |order|
|
24
|
+
price_to_currency(order[:total].to_i)
|
23
25
|
end
|
24
26
|
|
25
27
|
table_column :actions, :sortable => false, :filter => false do |order|
|
@@ -32,16 +34,31 @@ if defined?(EffectiveDatatables)
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def collection
|
37
|
+
collection = Effective::Order.unscoped.purchased
|
38
|
+
.joins(:user)
|
39
|
+
.joins(:order_items)
|
40
|
+
.group('users.email')
|
41
|
+
.group('orders.id')
|
42
|
+
.select('users.email AS email')
|
43
|
+
.select('orders.*')
|
44
|
+
.select("#{query_total} AS total")
|
45
|
+
.select("string_agg(order_items.title, '!!OI!!') AS order_items")
|
46
|
+
|
35
47
|
if attributes[:user_id].present?
|
36
|
-
|
48
|
+
collection.where(:user_id => attributes[:user_id])
|
37
49
|
else
|
38
|
-
|
50
|
+
collection
|
39
51
|
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def query_total
|
56
|
+
"SUM((order_items.price * order_items.quantity) + (CASE order_items.tax_exempt WHEN true THEN 0 ELSE ((order_items.price * order_items.quantity) * order_items.tax_rate) END))"
|
40
57
|
end
|
41
58
|
|
42
59
|
def search_column(collection, table_column, search_term)
|
43
|
-
if table_column[:name] == '
|
44
|
-
collection.
|
60
|
+
if table_column[:name] == 'total'
|
61
|
+
collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
45
62
|
else
|
46
63
|
super
|
47
64
|
end
|
@@ -162,10 +162,12 @@ module Effective
|
|
162
162
|
billing_address.full_name
|
163
163
|
elsif user.to_s.start_with?('#<User:') == false
|
164
164
|
user.to_s
|
165
|
-
elsif user.respond_to?(:first_name) && user.respond_to?(:last_name)
|
166
|
-
user.first_name.to_s + ' ' + user.last_name.to_s
|
167
165
|
elsif user.respond_to?(:full_name)
|
168
166
|
user.full_name.to_s
|
167
|
+
elsif user.respond_to?(:first_name) && user.respond_to?(:last_name)
|
168
|
+
user.first_name.to_s + ' ' + user.last_name.to_s
|
169
|
+
else
|
170
|
+
''
|
169
171
|
end
|
170
172
|
end
|
171
173
|
|
@@ -33,7 +33,7 @@ module Effective
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def tax # This is the total tax, for 3 items if quantity is 3
|
36
|
-
tax_exempt ? 0 : (subtotal * tax_rate).
|
36
|
+
tax_exempt ? 0 : (subtotal * tax_rate).round(0).to_i
|
37
37
|
end
|
38
38
|
|
39
39
|
def total
|
@@ -46,7 +46,7 @@ module Effective
|
|
46
46
|
elsif value.kind_of?(String) && !value.include?('.') # Looks like an integer
|
47
47
|
super
|
48
48
|
else # Could be Float, BigDecimal, or String like 9.99
|
49
|
-
ActiveSupport::Deprecation.warn('order_item.price= was passed a non-integer. Expecting an Integer representing the number of cents. Continuing with (price * 100.0).
|
49
|
+
ActiveSupport::Deprecation.warn('order_item.price= was passed a non-integer. Expecting an Integer representing the number of cents. Continuing with (price * 100.0).round(0).to_i conversion') unless EffectiveOrders.silence_deprecation_warnings
|
50
50
|
super((value.to_f * 100.0).to_i)
|
51
51
|
end
|
52
52
|
end
|
@@ -85,7 +85,7 @@ module Effective
|
|
85
85
|
|
86
86
|
def price_with_coupon(amount, coupon)
|
87
87
|
if coupon.percent_off.present?
|
88
|
-
(amount * (coupon.percent_off.to_i / 100.0)).
|
88
|
+
(amount * (coupon.percent_off.to_i / 100.0)).round(0).to_i
|
89
89
|
else
|
90
90
|
[0, amount - coupon.amount_off].max
|
91
91
|
end
|
@@ -8,14 +8,14 @@
|
|
8
8
|
%tbody
|
9
9
|
%tr
|
10
10
|
%td{:style => 'text-align: left;'}
|
11
|
-
- if order.
|
11
|
+
- if order.billing_address.try(:full_name).present? == false
|
12
12
|
= order.billing_name
|
13
13
|
%br
|
14
|
-
|
14
|
+
= mail_to(order.user.email)
|
15
|
+
%br
|
15
16
|
|
16
17
|
- if order.billing_address.present?
|
17
|
-
|
18
|
-
= render :partial => 'effective/addresses/address', :locals => {:address => order.billing_address}
|
18
|
+
= render :partial => 'effective/addresses/address', :locals => {:address => order.billing_address, :email => (order.user.email if order.billing_address.try(:full_name).present?)}
|
19
19
|
|
20
20
|
- if EffectiveOrders.require_shipping_address && order.shipping_address.present?
|
21
21
|
%td{:style => 'text-align: left;'}
|
data/lib/effective_orders.rb
CHANGED
@@ -66,8 +66,8 @@ module EffectiveOrders
|
|
66
66
|
if @@minimum_charge.nil? || @@minimum_charge.kind_of?(Integer)
|
67
67
|
@@minimum_charge
|
68
68
|
else
|
69
|
-
ActiveSupport::Deprecation.warn('EffectiveOrders.minimum_charge config option is a non-integer. It should be an Integer representing the number of cents. Continuing with (price * 100.0).
|
70
|
-
((@@minimum_charge * 100.0).
|
69
|
+
ActiveSupport::Deprecation.warn('EffectiveOrders.minimum_charge config option is a non-integer. It should be an Integer representing the number of cents. Continuing with (price * 100.0).round(0).to_i conversion') unless EffectiveOrders.silence_deprecation_warnings
|
70
|
+
((@@minimum_charge * 100.0).round(0).to_i rescue nil)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
data/spec/dummy/log/test.log
CHANGED
@@ -345,3 +345,10 @@ BLAHBLAH
|
|
345
345
|
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
346
346
|
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
347
347
|
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
348
|
+
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
349
|
+
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
350
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
351
|
+
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
352
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
353
|
+
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
354
|
+
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
@@ -81,7 +81,7 @@ describe Effective::Subscription do
|
|
81
81
|
subscription.stripe_plan_id = plan.id
|
82
82
|
subscription.stripe_coupon_id = coupon.id
|
83
83
|
|
84
|
-
subscription.price.should eq (plan.amount * (coupon.percent_off.to_i / 100.0)).
|
84
|
+
subscription.price.should eq (plan.amount * (coupon.percent_off.to_i / 100.0)).round(0).to_i
|
85
85
|
subscription.title.include?('25% off').should eq true
|
86
86
|
end
|
87
87
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.0.
|
103
|
+
version: 1.0.3
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.0.
|
110
|
+
version: 1.0.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: effective_obfuscation
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,104 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: factory_girl_rails
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rspec-rails
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: shoulda-matchers
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: sqlite3
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: guard
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: guard-rspec
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: guard-livereload
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
153
251
|
description: Quickly build an online store with carts, orders, automatic email receipts
|
154
252
|
and payment collection via Stripe, StripeConnect, PayPal and Moneris.
|
155
253
|
email:
|