effective_orders 2.1.17 → 2.2.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 +0 -3
- data/app/controllers/admin/customers_controller.rb +1 -1
- data/app/controllers/admin/order_items_controller.rb +1 -1
- data/app/controllers/admin/orders_controller.rb +1 -1
- data/app/models/effective/datatables/customers.rb +27 -29
- data/app/models/effective/datatables/order_items.rb +75 -77
- data/app/models/effective/datatables/orders.rb +64 -66
- data/app/views/admin/customers/index.html.haml +4 -7
- data/app/views/admin/order_items/index.html.haml +2 -4
- data/app/views/admin/orders/_form.html.haml +2 -2
- data/app/views/admin/orders/_form_mark_as_paid.html.haml +2 -2
- data/app/views/admin/orders/_form_note_internal.html.haml +1 -1
- data/app/views/admin/orders/_order_payment_details.html.haml +1 -1
- data/app/views/admin/orders/index.html.haml +4 -10
- data/app/views/admin/orders/mark_as_paid.html.haml +1 -1
- data/app/views/admin/orders/new.html.haml +1 -1
- data/app/views/admin/orders/show.html.haml +1 -1
- data/app/views/effective/carts/show.html.haml +2 -2
- data/app/views/effective/orders/_checkout_step1.html.haml +2 -2
- data/app/views/effective/orders/_order_note_fields.html.haml +1 -1
- data/app/views/effective/orders/_order_payment_details.html.haml +1 -1
- data/app/views/effective/orders/_order_terms_and_conditions_fields.html.haml +1 -1
- data/app/views/effective/orders/_order_user_fields.html.haml +1 -1
- data/app/views/effective/orders/checkout_step1.html.haml +1 -1
- data/app/views/effective/orders/checkout_step2.html.haml +1 -1
- data/app/views/effective/orders/cheque/pay_by_cheque.html.haml +1 -1
- data/app/views/effective/orders/declined.html.haml +1 -1
- data/app/views/effective/orders/index.html.haml +3 -3
- data/app/views/effective/orders/my_purchases.html.haml +1 -1
- data/app/views/effective/orders/my_sales.html.haml +1 -1
- data/app/views/effective/orders/purchased.html.haml +1 -1
- data/app/views/effective/orders/show.html.haml +1 -1
- data/app/views/effective/subscriptions/index.html.haml +4 -3
- data/app/views/effective/subscriptions/new.html.haml +1 -1
- data/app/views/effective/subscriptions/show.html.haml +3 -3
- data/config/effective_orders.rb +1 -1
- data/lib/effective_orders/version.rb +1 -1
- data/lib/generators/effective_orders/install_generator.rb +2 -2
- data/lib/generators/effective_orders/upgrade_from03x_generator.rb +1 -5
- data/lib/generators/effective_orders/upgrade_from1x_generator.rb +1 -5
- data/lib/generators/effective_orders/upgrade_price_column_generator.rb +1 -5
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19e07ec1d07242e5f32deffbf1781c2b5581892f
|
4
|
+
data.tar.gz: 6d3288fbd94d0a03062cce8c590a89aff3e7bdb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a6e170de89d924e91182974aab8c24927803eb5ab11600d5ecbf2c31a447ed41b52863abfed0db5a923a439ff593b3df5997338bdfa6959e7b9635e949e4b8d
|
7
|
+
data.tar.gz: 8ee0b8ad9be88093640859e682bf1ece228e291192ff3607cb0df8e12a6f3653474f6c021558b239967f02096da5f5e4aba485eafb436784c96b248bfd308d68
|
data/README.md
CHANGED
@@ -1114,9 +1114,6 @@ end
|
|
1114
1114
|
|
1115
1115
|
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
1116
1116
|
|
1117
|
-
Code and Effect is the product arm of [AgileStyle](http://www.agilestyle.com/), an Edmonton-based shop that specializes in building custom web applications with Ruby on Rails.
|
1118
|
-
|
1119
|
-
|
1120
1117
|
## Testing
|
1121
1118
|
|
1122
1119
|
Run tests by:
|
@@ -5,7 +5,7 @@ module Admin
|
|
5
5
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_customers] : EffectiveOrders.layout)
|
6
6
|
|
7
7
|
def index
|
8
|
-
@datatable = Effective::Datatables::Customers.new()
|
8
|
+
@datatable = Effective::Datatables::Customers.new()
|
9
9
|
@page_title = 'Customers'
|
10
10
|
|
11
11
|
EffectiveOrders.authorized?(self, :admin, :effective_orders)
|
@@ -5,7 +5,7 @@ module Admin
|
|
5
5
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_orders] : EffectiveOrders.layout)
|
6
6
|
|
7
7
|
def index
|
8
|
-
@datatable = Effective::Datatables::OrderItems.new()
|
8
|
+
@datatable = Effective::Datatables::OrderItems.new()
|
9
9
|
@page_title = 'Order Items'
|
10
10
|
|
11
11
|
EffectiveOrders.authorized?(self, :admin, :effective_orders)
|
@@ -5,7 +5,7 @@ module Admin
|
|
5
5
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_orders] : EffectiveOrders.layout)
|
6
6
|
|
7
7
|
def index
|
8
|
-
@datatable = Effective::Datatables::Orders.new()
|
8
|
+
@datatable = Effective::Datatables::Orders.new()
|
9
9
|
@page_title = 'Orders'
|
10
10
|
|
11
11
|
authorize_effective_order!
|
@@ -1,39 +1,37 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
default_order :email, :asc
|
1
|
+
module Effective
|
2
|
+
module Datatables
|
3
|
+
class Customers < Effective::Datatable
|
4
|
+
datatable do
|
5
|
+
default_order :email, :asc
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
table_column :id, visible: false
|
8
|
+
table_column(:email, column: 'users.email') { |user| mail_to user.email, user.email }
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
if EffectiveOrders.stripe_enabled
|
11
|
+
table_column :stripe_customer_id
|
12
|
+
table_column :stripe_active_card
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
if EffectiveOrders.stripe_connect_enabled
|
16
|
+
table_column :stripe_connect_access_token
|
17
|
+
end
|
19
18
|
|
20
|
-
|
19
|
+
table_column :subscription_types, column: 'subscription_types'
|
21
20
|
|
22
|
-
|
23
|
-
|
21
|
+
actions_column partial: 'admin/customers/actions'
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
def collection
|
25
|
+
Effective::Customer.customers.uniq
|
26
|
+
.joins(:user, :subscriptions)
|
27
|
+
.select('customers.*, users.email AS email')
|
28
|
+
.select("array_to_string(array(#{Effective::Subscription.purchased.select('subscriptions.stripe_plan_id').where('subscriptions.customer_id = customers.id').to_sql}), ' ,') AS subscription_types")
|
29
|
+
.group('customers.id, subscriptions.stripe_plan_id, users.email')
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
32
|
+
def search_column(collection, table_column, search_term)
|
33
|
+
return collection.where('subscriptions.stripe_plan_id ILIKE ?', "%#{search_term}%") if table_column[:name] == 'subscription_types'
|
34
|
+
super
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
@@ -1,101 +1,99 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
1
|
+
module Effective
|
2
|
+
module Datatables
|
3
|
+
class OrderItems < Effective::Datatable
|
4
|
+
datatable do
|
5
|
+
default_order :purchased_at, :desc
|
6
|
+
|
7
|
+
table_column(:purchased_at, type: :datetime, column: 'orders.purchased_at') do |order_item|
|
8
|
+
Time.at(order_item[:purchased_at]).in_time_zone if order_item[:purchased_at].present?
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
if EffectiveOrders.obfuscate_order_ids
|
15
|
-
table_column(:order, type: :obfuscated_id, sortable: false) do |order_item|
|
16
|
-
obfuscated_id = Effective::Order.obfuscate(order_item[:order_id])
|
17
|
-
link_to(obfuscated_id, (datatables_admin_path? ? effective_orders.admin_order_path(obfuscated_id) : effective_orders.order_path(obfuscated_id)))
|
18
|
-
end
|
19
|
-
else
|
20
|
-
table_column(:order, sortable: false) do |order_item|
|
21
|
-
link_to(order_item.to_param, (datatables_admin_path? ? effective_orders.admin_order_path(order_item.to_param) : effective_orders.order_path(order_item.to_param)))
|
22
|
-
end
|
23
|
-
end
|
11
|
+
table_column :id, visible: false
|
24
12
|
|
25
|
-
|
26
|
-
|
13
|
+
if EffectiveOrders.obfuscate_order_ids
|
14
|
+
table_column(:order, type: :obfuscated_id, sortable: false) do |order_item|
|
15
|
+
obfuscated_id = Effective::Order.obfuscate(order_item[:order_id])
|
16
|
+
link_to(obfuscated_id, (datatables_admin_path? ? effective_orders.admin_order_path(obfuscated_id) : effective_orders.order_path(obfuscated_id)))
|
27
17
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
(order_item[:buyer_name] || '').split('!!SEP!!').find(&:present?)
|
32
|
-
end
|
18
|
+
else
|
19
|
+
table_column(:order, sortable: false) do |order_item|
|
20
|
+
link_to(order_item.to_param, (datatables_admin_path? ? effective_orders.admin_order_path(order_item.to_param) : effective_orders.order_path(order_item.to_param)))
|
33
21
|
end
|
22
|
+
end
|
34
23
|
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
table_column :email, column: 'users.email', label: 'Buyer Email', if: proc { attributes[:user_id].blank? } do |order_item|
|
25
|
+
link_to order_item[:email], (edit_admin_user_path(order_item[:user_id]) rescue admin_user_path(order_item[:user_id]) rescue '#')
|
26
|
+
end
|
38
27
|
|
39
|
-
|
40
|
-
|
28
|
+
if EffectiveOrders.require_billing_address
|
29
|
+
table_column :buyer_name, sortable: false, label: 'Buyer Name', if: proc { attributes[:user_id].blank? } do |order_item|
|
30
|
+
(order_item[:buyer_name] || '').split('!!SEP!!').find(&:present?)
|
41
31
|
end
|
32
|
+
end
|
42
33
|
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
table_column :purchase_state, column: 'orders.purchase_state', filter: { type: :select, values: [%w(abandoned abandoned), [EffectiveOrders::PURCHASED, EffectiveOrders::PURCHASED], [EffectiveOrders::DECLINED, EffectiveOrders::DECLINED]], selected: EffectiveOrders::PURCHASED } do |order_item|
|
35
|
+
order_item[:purchase_state] || 'abandoned'
|
36
|
+
end
|
46
37
|
|
47
|
-
|
48
|
-
|
38
|
+
table_column :title do |order_item|
|
39
|
+
order_item.quantity == 1 ? order_item.title : "#{order_item.title} (#{order_item.quantity} purchased)"
|
49
40
|
end
|
50
41
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
.select('order_items.*, orders.*, users.email AS email')
|
55
|
-
.select("#{query_subtotal} AS subtotal, #{query_tax} AS tax, #{query_total} AS total")
|
56
|
-
.group('order_items.id, orders.id, users.email')
|
42
|
+
table_column(:subtotal) { |order_item| price_to_currency(order_item[:subtotal].to_i) }
|
43
|
+
table_column(:tax) { |order_item| price_to_currency(order_item[:tax].to_i) }
|
44
|
+
table_column(:total) { |order_item| price_to_currency(order_item[:total].to_i) }
|
57
45
|
|
58
|
-
|
59
|
-
|
46
|
+
table_column :created_at, visible: false
|
47
|
+
table_column :updated_at, visible: false
|
48
|
+
end
|
60
49
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
50
|
+
def collection
|
51
|
+
collection = Effective::OrderItem.unscoped
|
52
|
+
.joins(order: :user)
|
53
|
+
.select('order_items.*, orders.*, users.email AS email')
|
54
|
+
.select("#{query_subtotal} AS subtotal, #{query_tax} AS tax, #{query_total} AS total")
|
55
|
+
.group('order_items.id, orders.id, users.email')
|
66
56
|
|
67
|
-
|
68
|
-
|
57
|
+
if EffectiveOrders.require_billing_address && defined?(EffectiveAddresses)
|
58
|
+
addresses_tbl = EffectiveAddresses.addresses_table_name
|
69
59
|
|
70
|
-
|
71
|
-
|
60
|
+
collection = collection
|
61
|
+
.joins("LEFT JOIN (SELECT addressable_id, string_agg(#{addresses_tbl}.full_name, '!!SEP!!') AS buyer_name FROM #{addresses_tbl} WHERE #{addresses_tbl}.category = 'billing' AND #{addresses_tbl}.addressable_type = 'Effective::Order' GROUP BY #{addresses_tbl}.addressable_id) #{addresses_tbl} ON orders.id = #{addresses_tbl}.addressable_id")
|
62
|
+
.group("#{addresses_tbl}.buyer_name")
|
63
|
+
.select("#{addresses_tbl}.buyer_name AS buyer_name")
|
72
64
|
end
|
73
65
|
|
74
|
-
|
75
|
-
|
76
|
-
end
|
66
|
+
attributes[:user_id].present? ? collection.where("#{EffectiveOrders.orders_table_name.to_s}.user_id = ?", attributes[:user_id]) : collection
|
67
|
+
end
|
77
68
|
|
78
|
-
|
79
|
-
|
80
|
-
|
69
|
+
def query_subtotal
|
70
|
+
'SUM(price * quantity)'
|
71
|
+
end
|
81
72
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
elsif table_column[:name] == 'purchase_state' && search_term == 'abandoned'
|
86
|
-
collection.where("#{EffectiveOrders.orders_table_name.to_s}.purchase_state IS NULL")
|
87
|
-
elsif table_column[:name] == 'subtotal'
|
88
|
-
collection.having("#{query_subtotal} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
89
|
-
elsif table_column[:name] == 'tax'
|
90
|
-
collection.having("#{query_tax} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
91
|
-
elsif table_column[:name] == 'total'
|
92
|
-
collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
93
|
-
else
|
94
|
-
super
|
95
|
-
end
|
96
|
-
end
|
73
|
+
def query_total
|
74
|
+
'SUM((price * quantity) + (CASE tax_exempt WHEN true THEN 0 ELSE ((price * quantity) * tax_rate) END))'
|
75
|
+
end
|
97
76
|
|
77
|
+
def query_tax
|
78
|
+
'(CASE tax_exempt WHEN true THEN 0 ELSE ((price * quantity) * tax_rate) END)'
|
98
79
|
end
|
80
|
+
|
81
|
+
def search_column(collection, table_column, search_term)
|
82
|
+
if table_column[:name] == 'order'
|
83
|
+
collection.where("#{EffectiveOrders.order_items_table_name.to_s}.order_id = ?", Effective::Order.deobfuscate(search_term))
|
84
|
+
elsif table_column[:name] == 'purchase_state' && search_term == 'abandoned'
|
85
|
+
collection.where("#{EffectiveOrders.orders_table_name.to_s}.purchase_state IS NULL")
|
86
|
+
elsif table_column[:name] == 'subtotal'
|
87
|
+
collection.having("#{query_subtotal} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
88
|
+
elsif table_column[:name] == 'tax'
|
89
|
+
collection.having("#{query_tax} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
90
|
+
elsif table_column[:name] == 'total'
|
91
|
+
collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
92
|
+
else
|
93
|
+
super
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
99
97
|
end
|
100
98
|
end
|
101
99
|
end
|
@@ -1,92 +1,90 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
default_order :created_at, :desc
|
1
|
+
module Effective
|
2
|
+
module Datatables
|
3
|
+
class Orders < Effective::Datatable
|
4
|
+
datatable do
|
5
|
+
default_order :created_at, :desc
|
7
6
|
|
8
|
-
|
7
|
+
table_column :purchased_at
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
table_column :id, label: 'ID' do |order|
|
10
|
+
link_to order.to_param, effective_orders.admin_order_path(order)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Don't display email or buyer_name column if this is for a specific user
|
14
|
+
if attributes[:user_id].blank?
|
15
|
+
table_column :email, column: 'users.email', label: 'Buyer Email' do |order|
|
16
|
+
link_to order.user.email, (edit_admin_user_path(order.user) rescue admin_user_path(order.user) rescue '#')
|
12
17
|
end
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
link_to order.user.email, (edit_admin_user_path(order.user) rescue admin_user_path(order.user) rescue '#')
|
19
|
+
if EffectiveOrders.use_address_full_name
|
20
|
+
table_column :buyer_name, column: 'addresses.full_name' do |order|
|
21
|
+
order.billing_address.try(:full_name)
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
elsif # Not using address full name
|
26
|
-
table_column :buyer_name, column: 'users.*' do |order|
|
27
|
-
order.user.to_s
|
28
|
-
end
|
24
|
+
elsif # Not using address full name
|
25
|
+
table_column :buyer_name, column: 'users.*' do |order|
|
26
|
+
order.user.to_s
|
29
27
|
end
|
30
28
|
end
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
if EffectiveOrders.require_shipping_address
|
37
|
-
table_column :shipping_address
|
38
|
-
end
|
31
|
+
if EffectiveOrders.require_billing_address
|
32
|
+
table_column :billing_address
|
33
|
+
end
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
if EffectiveOrders.require_shipping_address
|
36
|
+
table_column :shipping_address
|
37
|
+
end
|
43
38
|
|
44
|
-
|
39
|
+
table_column :purchase_state, label: 'State', filter: { values: purchase_state_filter_values } do |order|
|
40
|
+
order.purchase_state || 'abandoned'
|
41
|
+
end
|
45
42
|
|
46
|
-
|
47
|
-
table_column :tax, as: :price
|
43
|
+
table_column :order_items, column: 'order_items.title', filter: :string
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
end
|
45
|
+
table_column :subtotal, as: :price
|
46
|
+
table_column :tax, as: :price
|
52
47
|
|
53
|
-
|
48
|
+
table_column :tax_rate, visible: false do |order|
|
49
|
+
tax_rate_to_percentage(order.tax_rate)
|
50
|
+
end
|
54
51
|
|
55
|
-
|
56
|
-
table_column :payment_card, label: 'Card'
|
52
|
+
table_column :total, as: :price
|
57
53
|
|
58
|
-
|
59
|
-
|
60
|
-
table_column :note_internal, visible: false
|
54
|
+
table_column :payment_provider, label: 'Provider', visible: false, filter: { values: ['nil'] + (EffectiveOrders.payment_providers + EffectiveOrders.other_payment_providers).sort }
|
55
|
+
table_column :payment_card, label: 'Card'
|
61
56
|
|
62
|
-
|
63
|
-
|
57
|
+
table_column :note, visible: false
|
58
|
+
table_column :note_to_buyer, visible: false
|
59
|
+
table_column :note_internal, visible: false
|
64
60
|
|
65
|
-
|
66
|
-
|
61
|
+
table_column :created_at, visible: false
|
62
|
+
table_column :updated_at, visible: false
|
67
63
|
|
68
|
-
|
69
|
-
|
70
|
-
.joins(:user)
|
71
|
-
.includes(:addresses)
|
72
|
-
.includes(:user)
|
73
|
-
.includes(:order_items)
|
64
|
+
actions_column partial: 'admin/orders/actions'
|
65
|
+
end
|
74
66
|
|
75
|
-
|
76
|
-
|
77
|
-
|
67
|
+
def collection
|
68
|
+
collection = Effective::Order.unscoped
|
69
|
+
.joins(:user)
|
70
|
+
.includes(:addresses)
|
71
|
+
.includes(:user)
|
72
|
+
.includes(:order_items)
|
78
73
|
|
79
|
-
|
74
|
+
if EffectiveOrders.orders_collection_scope.respond_to?(:call)
|
75
|
+
collection = EffectiveOrders.orders_collection_scope.call(collection)
|
80
76
|
end
|
81
77
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
]
|
89
|
-
|
78
|
+
attributes[:user_id].present? ? collection.where(user_id: attributes[:user_id]) : collection
|
79
|
+
end
|
80
|
+
|
81
|
+
def purchase_state_filter_values
|
82
|
+
[
|
83
|
+
%w(abandoned nil),
|
84
|
+
[EffectiveOrders::PURCHASED, EffectiveOrders::PURCHASED],
|
85
|
+
[EffectiveOrders::DECLINED, EffectiveOrders::DECLINED],
|
86
|
+
[EffectiveOrders::PENDING, EffectiveOrders::PENDING]
|
87
|
+
]
|
90
88
|
end
|
91
89
|
end
|
92
90
|
end
|
@@ -1,12 +1,9 @@
|
|
1
|
-
%
|
1
|
+
%h1.effective-admin-heading= @page_title
|
2
2
|
|
3
|
-
%p.text-right
|
3
|
+
%p.text-right.effective-admin-actions
|
4
|
+
= link_to 'Stripe Dashboard: Customers', 'https://manage.stripe.com/customers', :class => 'btn btn-primary'
|
4
5
|
|
5
|
-
- if @datatable.
|
6
|
-
%p Please install #{link_to 'effective_datatables', 'https://github.com/code-and-effect/effective_datatables'} to see this page.
|
7
|
-
- elsif @datatable.present?
|
6
|
+
- if @datatable.present?
|
8
7
|
= render_datatable @datatable
|
9
8
|
- else
|
10
9
|
%p There are no customers present
|
11
|
-
|
12
|
-
%p.text-right= link_to 'Stripe Dashboard: Customers', 'https://manage.stripe.com/customers', :class => 'btn btn-primary'
|
@@ -1,8 +1,6 @@
|
|
1
|
-
%
|
1
|
+
%h1.effective-admin-heading= @page_title
|
2
2
|
|
3
|
-
- if @datatable.
|
4
|
-
%p Please install #{link_to 'effective_datatables', 'https://github.com/code-and-effect/effective_datatables'} to see this page.
|
5
|
-
- elsif @datatable.present?
|
3
|
+
- if @datatable.present?
|
6
4
|
= render_datatable @datatable
|
7
5
|
- else
|
8
6
|
%p There are no order items present
|
@@ -8,7 +8,7 @@
|
|
8
8
|
as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
9
9
|
collection: @users || User.all.to_a.sort { |user1, user2| user1.to_s <=> user2.to_s }
|
10
10
|
|
11
|
-
%
|
11
|
+
%h2 Order Items
|
12
12
|
.order_items
|
13
13
|
- f.object.order_items.build unless f.object.order_items.present?
|
14
14
|
= f.simple_fields_for :order_items do |order_item|
|
@@ -23,7 +23,7 @@
|
|
23
23
|
value: (f.object.send_payment_request_to_buyer.nil? ? EffectiveOrders.mailer[:send_payment_request_to_buyer] : f.object.send_payment_request_to_buyer?)
|
24
24
|
|
25
25
|
.effective-order-internal-note
|
26
|
-
%
|
26
|
+
%h2 Internal Note
|
27
27
|
= f.input :note_internal, label: false, hint: 'For internal admin use only. This note will never be displayed to the buyer.'
|
28
28
|
|
29
29
|
= render partial: '/admin/orders/order_actions', locals: { order: @order, form: f, f: f }
|
@@ -1,5 +1,5 @@
|
|
1
1
|
= simple_form_for [:admin, order], (EffectiveOrders.admin_simple_form_options || {}).merge(url: effective_orders.mark_as_paid_admin_order_path(order), method: :post) do |f|
|
2
|
-
%
|
2
|
+
%h2 Payment Details
|
3
3
|
|
4
4
|
- if order.purchased?
|
5
5
|
.alert.alert-warning Warning: This order has already been purchased
|
@@ -26,7 +26,7 @@
|
|
26
26
|
value: (f.object.send_mark_as_paid_email_to_buyer.nil? ? EffectiveOrders.mailer[:send_order_receipts_when_mark_as_paid_by_admin] : f.object.send_mark_as_paid_email_to_buyer?)
|
27
27
|
|
28
28
|
.effective-order-note-to-buyer
|
29
|
-
%
|
29
|
+
%h2 Note to Buyer
|
30
30
|
= f.input :note_to_buyer, label: false, hint: 'This is displayed to the buyer on all order receipts.'
|
31
31
|
|
32
32
|
= render partial: '/admin/orders/order_actions', locals: { order: @order, form: f, f: f }
|
@@ -1,5 +1,5 @@
|
|
1
1
|
.effective-order-internal-note-form
|
2
|
-
%
|
2
|
+
%h2 Internal Note
|
3
3
|
|
4
4
|
= simple_form_for [:admin, order], (EffectiveOrders.admin_simple_form_options || {}).merge(url: effective_orders.admin_order_path(order)) do |f|
|
5
5
|
= f.input :note_internal, label: false, hint: 'For internal admin use only. This note will never be displayed to the buyer.'
|
@@ -1,15 +1,9 @@
|
|
1
|
-
%
|
1
|
+
%h1.effective-admin-heading= @page_title
|
2
2
|
|
3
|
-
%p.text-right.effective-
|
3
|
+
%p.text-right.effective-admin-actions
|
4
|
+
= link_to 'New Order', effective_orders.new_admin_order_path, class: 'btn btn-primary'
|
4
5
|
|
5
|
-
- if @datatable.
|
6
|
-
%p Please install #{link_to 'effective_datatables', 'https://github.com/code-and-effect/effective_datatables'} to see this page.
|
7
|
-
- elsif @datatable.present?
|
6
|
+
- if @datatable.present?
|
8
7
|
= render_datatable @datatable
|
9
8
|
- else
|
10
9
|
%p There are no orders present
|
11
|
-
|
12
|
-
- if @datatable.present?
|
13
|
-
%p.text-right= link_to 'New Order', effective_orders.new_admin_order_path, :class => 'btn btn-primary'
|
14
|
-
|
15
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
%
|
1
|
+
%h1.effective-heading= @page_title
|
2
2
|
|
3
3
|
- if @cart.empty?
|
4
4
|
%p Your cart is empty.
|
@@ -10,7 +10,7 @@
|
|
10
10
|
= render partial: '/effective/carts/cart_actions', locals: { cart: @cart }
|
11
11
|
|
12
12
|
- if @pending_orders.present?
|
13
|
-
%
|
13
|
+
%h2 Pending Orders
|
14
14
|
= render_orders(@pending_orders)
|
15
15
|
|
16
16
|
- if EffectiveOrders.show_order_history_button
|
@@ -17,14 +17,14 @@
|
|
17
17
|
.row
|
18
18
|
- if EffectiveOrders.require_billing_address
|
19
19
|
%div{class: "col-sm-#{12 / num_addresses}"}
|
20
|
-
%
|
20
|
+
%h2 Billing Address
|
21
21
|
= effective_address_fields(f, :billing_address)
|
22
22
|
- if f.object.user.respond_to?(:billing_address=)
|
23
23
|
= f.input :save_billing_address, as: :boolean, label: 'Save as my default billing address', required: false
|
24
24
|
|
25
25
|
- if EffectiveOrders.require_shipping_address
|
26
26
|
%div{class: "col-sm-#{12 / num_addresses}"}
|
27
|
-
%
|
27
|
+
%h2 Shipping Address
|
28
28
|
= effective_address_fields(f, :shipping_address)
|
29
29
|
- if f.object.user.respond_to?(:shipping_address=)
|
30
30
|
= f.input :save_shipping_address, as: :boolean, label: 'Save as my default shipping address', required: false
|
@@ -1,12 +1,12 @@
|
|
1
|
-
%
|
1
|
+
%h1.effective-heading= @page_title
|
2
2
|
|
3
|
-
%
|
3
|
+
%h2 Pending Orders
|
4
4
|
- if @pending_orders.present?
|
5
5
|
= render_orders(@pending_orders)
|
6
6
|
- else
|
7
7
|
%p You have no pending orders.
|
8
8
|
|
9
|
-
%
|
9
|
+
%h2 Purchased Orders
|
10
10
|
- if @orders.present?
|
11
11
|
= render_orders(@orders)
|
12
12
|
- else
|
@@ -1,4 +1,7 @@
|
|
1
|
-
%
|
1
|
+
%h1.effective-heading= @page_title
|
2
|
+
|
3
|
+
%p.text-right.effective-actions
|
4
|
+
= link_to 'New Subscription', effective_orders.new_subscription_path, class: 'btn btn-primary'
|
2
5
|
|
3
6
|
- if @subscriptions.present?
|
4
7
|
%p You have the following subscriptions:
|
@@ -17,5 +20,3 @@
|
|
17
20
|
|
18
21
|
- else
|
19
22
|
%p You have no subscriptions
|
20
|
-
|
21
|
-
%p.text-right= link_to 'New Subscription', effective_orders.new_subscription_path
|
@@ -1,4 +1,4 @@
|
|
1
|
-
%
|
1
|
+
%h1.effective-heading
|
2
2
|
= @plan.name
|
3
3
|
Subscription
|
4
4
|
details
|
@@ -24,7 +24,7 @@
|
|
24
24
|
%th Current Period End
|
25
25
|
%td= Time.zone.at(@stripe_subscription.current_period_end).strftime("%d-%b-%Y")
|
26
26
|
|
27
|
-
%
|
27
|
+
%h2= "#{@plan.interval.chomp('ly')}ly Invoices"
|
28
28
|
|
29
29
|
%table.table
|
30
30
|
%thead
|
@@ -44,6 +44,6 @@
|
|
44
44
|
= Time.zone.at(invoice.lines.first.period.end).strftime("%d-%b-%Y")
|
45
45
|
%td= price_to_currency(invoice.total)
|
46
46
|
|
47
|
-
%
|
47
|
+
%h2 Cancel Subscription
|
48
48
|
|
49
49
|
= link_to 'Unsubscribe', effective_orders.subscription_path(@plan.id), :data => {:method => :delete, :confirm => 'This will cancel your subscription. Are you sure? This cannot be undone.', :disable_with => 'Unsubscribing...'}
|
data/config/effective_orders.rb
CHANGED
@@ -30,7 +30,7 @@ EffectiveOrders.setup do |config|
|
|
30
30
|
#
|
31
31
|
# Or disable the check completely:
|
32
32
|
# config.authorization_method = false
|
33
|
-
config.authorization_method = Proc.new { |controller, action, resource|
|
33
|
+
config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCanCan
|
34
34
|
|
35
35
|
# Skip automatically mounting the EffectiveOrders engine
|
36
36
|
config.skip_mount_engine = false
|
@@ -3,7 +3,7 @@ module EffectiveOrders
|
|
3
3
|
class InstallGenerator < Rails::Generators::Base
|
4
4
|
include Rails::Generators::Migration
|
5
5
|
|
6
|
-
desc
|
6
|
+
desc 'Creates an EffectiveOrders initializer in your application.'
|
7
7
|
|
8
8
|
source_root File.expand_path('../../templates', __FILE__)
|
9
9
|
|
@@ -16,7 +16,7 @@ module EffectiveOrders
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def install_effective_addresses
|
19
|
-
run
|
19
|
+
run 'rails generate effective_addresses:install'
|
20
20
|
end
|
21
21
|
|
22
22
|
def copy_initializer
|
@@ -24,11 +24,7 @@ module EffectiveOrders
|
|
24
24
|
@subscriptions_table_name = ':' + EffectiveOrders.subscriptions_table_name.to_s
|
25
25
|
@products_table_name = ':' + EffectiveOrders.products_table_name.to_s
|
26
26
|
|
27
|
-
migration_template '
|
28
|
-
end
|
29
|
-
|
30
|
-
def show_readme
|
31
|
-
readme "README" if behavior == :invoke
|
27
|
+
migration_template ('../' * 3) + 'db/upgrade/02_upgrade_effective_orders_from03x.rb.erb', 'db/migrate/upgrade_effective_orders_from03x.rb'
|
32
28
|
end
|
33
29
|
end
|
34
30
|
end
|
@@ -20,11 +20,7 @@ module EffectiveOrders
|
|
20
20
|
@subscriptions_table_name = ':' + EffectiveOrders.subscriptions_table_name.to_s
|
21
21
|
@products_table_name = ':' + EffectiveOrders.products_table_name.to_s
|
22
22
|
|
23
|
-
migration_template '
|
24
|
-
end
|
25
|
-
|
26
|
-
def show_readme
|
27
|
-
readme 'README' if behavior == :invoke
|
23
|
+
migration_template ('../' * 3) + 'db/upgrade/03_upgrade_effective_orders_from1x.rb.erb', 'db/migrate/upgrade_effective_orders_from1x.rb'
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
@@ -23,11 +23,7 @@ module EffectiveOrders
|
|
23
23
|
@table = table.to_s.downcase
|
24
24
|
@column = column.to_s.downcase
|
25
25
|
|
26
|
-
migration_template '
|
27
|
-
end
|
28
|
-
|
29
|
-
def show_readme
|
30
|
-
readme "README" if behavior == :invoke
|
26
|
+
migration_template ('../' * 3) + 'db/upgrade/upgrade_price_column_on_table.rb.erb', "db/migrate/upgrade_price_column_on_#{table}.rb"
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|
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: 2.
|
4
|
+
version: 2.2.0
|
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: 2016-
|
11
|
+
date: 2016-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.6.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: effective_datatables
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.0.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.0.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: stripe-ruby-mock
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|