effective_orders 4.4.1 → 4.4.2
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/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/controllers/effective/concerns/purchase.rb +30 -7
- data/app/controllers/effective/orders_controller.rb +9 -18
- data/app/controllers/effective/providers/cheque.rb +7 -24
- data/app/controllers/effective/providers/mark_as_paid.rb +2 -2
- data/app/controllers/effective/providers/phone.rb +22 -0
- data/app/datatables/{effective_customers_datatable.rb → admin/effective_customers_datatable.rb} +1 -1
- data/app/datatables/admin/effective_orders_datatable.rb +100 -0
- data/app/datatables/effective_orders_datatable.rb +24 -44
- data/app/helpers/effective_orders_helper.rb +6 -6
- data/app/helpers/effective_subscriptions_helper.rb +0 -2
- data/app/mailers/effective/orders_mailer.rb +1 -0
- data/app/models/effective/order.rb +27 -2
- data/app/views/admin/orders/_datatable_actions.html.haml +18 -0
- data/app/views/effective/orders/_checkout_step2.html.haml +4 -6
- data/app/views/effective/orders/_datatable_actions.html.haml +2 -0
- data/app/views/effective/orders/_fields.html.haml +2 -2
- data/app/views/effective/orders/{_order_note_fields.html.haml → _fields_note.html.haml} +0 -0
- data/app/views/effective/orders/{_order_terms_and_conditions_fields.html.haml → _fields_terms.html.haml} +0 -0
- data/app/views/effective/orders/_order.html.haml +2 -1
- data/app/views/effective/orders/_order_actions.html.haml +1 -1
- data/app/views/effective/orders/_order_deferred.html.haml +9 -0
- data/app/views/effective/orders/_order_header.html.haml +4 -1
- data/app/views/effective/orders/_order_items.html.haml +12 -3
- data/app/views/effective/orders/_order_notes.html.haml +2 -0
- data/app/views/effective/orders/_order_payment.html.haml +24 -0
- data/app/views/effective/orders/cheque/_form.html.haml +3 -4
- data/app/views/effective/orders/declined.html.haml +0 -2
- data/app/views/effective/orders/deferred.html.haml +13 -0
- data/app/views/effective/orders/deferred/_form.html.haml +16 -0
- data/app/views/effective/orders/index.html.haml +1 -10
- data/app/views/effective/orders/mark_as_paid/_form.html.haml +1 -3
- data/app/views/effective/orders/phone/_form.html.haml +4 -0
- data/app/views/effective/orders/pretend/_form.html.haml +3 -0
- data/app/views/effective/orders/stripe/_form.html.haml +2 -2
- data/config/effective_orders.rb +13 -3
- data/config/routes.rb +3 -1
- data/lib/effective_orders.rb +21 -6
- data/lib/effective_orders/version.rb +1 -1
- metadata +13 -8
- data/app/datatables/effective_order_items_datatable.rb +0 -99
- data/app/views/admin/orders/_actions.html.haml +0 -22
- data/app/views/effective/orders/_order_payment_details.html.haml +0 -18
- data/app/views/effective/orders/cheque/pay_by_cheque.html.haml +0 -7
data/config/effective_orders.rb
CHANGED
@@ -163,11 +163,12 @@ EffectiveOrders.setup do |config|
|
|
163
163
|
#######################################
|
164
164
|
|
165
165
|
# Cheque
|
166
|
+
# This is an deferred payment
|
166
167
|
config.cheque = false
|
167
168
|
|
168
169
|
# config.cheque = {
|
169
|
-
# confirm: '
|
170
|
-
#
|
170
|
+
# confirm: 'Proceed with pay by cheque?',
|
171
|
+
# success: 'Thank you! You have indicated that this order will be purchased by cheque. Please send us a cheque and a copy of this invoice at your earliest convenience.'
|
171
172
|
# }
|
172
173
|
|
173
174
|
# Moneris
|
@@ -216,11 +217,20 @@ EffectiveOrders.setup do |config|
|
|
216
217
|
# }
|
217
218
|
# end
|
218
219
|
|
220
|
+
# Phone
|
221
|
+
# This is an deferred payment
|
222
|
+
config.phone = false
|
223
|
+
|
224
|
+
# config.phone = {
|
225
|
+
# confirm: 'Proceed with pay by phone?',
|
226
|
+
# success: 'Thank you! You have indicated that this order will be purchased by phone. Please give us a call at your earliest convenience.'
|
227
|
+
# }
|
228
|
+
|
219
229
|
|
220
230
|
# Refunds
|
221
231
|
# This does not issue a refund with the payment processor at all.
|
222
232
|
# Instead, we mark the order as purchased, create a refund object to track it, and
|
223
|
-
# send an email to
|
233
|
+
# send an email to mailer[:admin_email] with instructions to issue a refund
|
224
234
|
config.refund = false
|
225
235
|
|
226
236
|
# config.refund = {
|
data/config/routes.rb
CHANGED
@@ -3,12 +3,14 @@ EffectiveOrders::Engine.routes.draw do
|
|
3
3
|
resources :orders, except: [:destroy] do
|
4
4
|
member do
|
5
5
|
get :purchased
|
6
|
+
get :deferred
|
6
7
|
get :declined
|
7
8
|
get :send_buyer_receipt
|
8
9
|
|
9
10
|
post :free if EffectiveOrders.free?
|
10
11
|
post :mark_as_paid if EffectiveOrders.mark_as_paid?
|
11
|
-
post :
|
12
|
+
post :cheque if EffectiveOrders.cheque?
|
13
|
+
post :phone if EffectiveOrders.phone?
|
12
14
|
post :pretend if EffectiveOrders.pretend?
|
13
15
|
post :refund if EffectiveOrders.refund?
|
14
16
|
post :stripe if EffectiveOrders.stripe?
|
data/lib/effective_orders.rb
CHANGED
@@ -3,12 +3,13 @@ require 'effective_orders/engine'
|
|
3
3
|
require 'effective_orders/version'
|
4
4
|
|
5
5
|
module EffectiveOrders
|
6
|
-
PENDING = 'pending'.freeze
|
7
|
-
CONFIRMED = 'confirmed'.freeze
|
8
|
-
|
9
|
-
|
6
|
+
PENDING = 'pending'.freeze # New orders are created in a pending state
|
7
|
+
CONFIRMED = 'confirmed'.freeze # Once the order has passed checkout step 1
|
8
|
+
DEFERRED = 'deferred'.freeze # Deferred providers. Cheque or Phone was selected.
|
9
|
+
PURCHASED = 'purchased'.freeze # Purchased by provider
|
10
|
+
DECLINED = 'declined'.freeze # Declined by provider
|
10
11
|
|
11
|
-
STATES = { PENDING => PENDING, CONFIRMED => CONFIRMED, PURCHASED => PURCHASED, DECLINED => DECLINED }
|
12
|
+
STATES = { PENDING => PENDING, CONFIRMED => CONFIRMED, DEFERRED => DEFERRED, PURCHASED => PURCHASED, DECLINED => DECLINED }
|
12
13
|
|
13
14
|
# Subscription statuses (as per stripe)
|
14
15
|
ACTIVE = 'active'.freeze
|
@@ -58,6 +59,7 @@ module EffectiveOrders
|
|
58
59
|
mattr_accessor :cheque
|
59
60
|
mattr_accessor :moneris
|
60
61
|
mattr_accessor :paypal
|
62
|
+
mattr_accessor :phone
|
61
63
|
mattr_accessor :refund
|
62
64
|
mattr_accessor :stripe
|
63
65
|
mattr_accessor :subscriptions # Stripe subscriptions
|
@@ -101,6 +103,10 @@ module EffectiveOrders
|
|
101
103
|
free_enabled == true
|
102
104
|
end
|
103
105
|
|
106
|
+
def self.deferred?
|
107
|
+
deferred_providers.present?
|
108
|
+
end
|
109
|
+
|
104
110
|
def self.mark_as_paid?
|
105
111
|
mark_as_paid_enabled == true
|
106
112
|
end
|
@@ -113,6 +119,10 @@ module EffectiveOrders
|
|
113
119
|
paypal.kind_of?(Hash)
|
114
120
|
end
|
115
121
|
|
122
|
+
def self.phone?
|
123
|
+
phone.kind_of?(Hash)
|
124
|
+
end
|
125
|
+
|
116
126
|
def self.pretend?
|
117
127
|
pretend_enabled == true
|
118
128
|
end
|
@@ -140,11 +150,12 @@ module EffectiveOrders
|
|
140
150
|
# The Effective::Order.payment_provider value must be in this collection
|
141
151
|
def self.payment_providers
|
142
152
|
[
|
143
|
-
('cheque' if cheque?
|
153
|
+
('cheque' if cheque?),
|
144
154
|
('credit card' if mark_as_paid?),
|
145
155
|
('free' if free?),
|
146
156
|
('moneris' if moneris?),
|
147
157
|
('paypal' if paypal?),
|
158
|
+
('phone' if phone?),
|
148
159
|
('pretend' if pretend?),
|
149
160
|
('refund' if refund?),
|
150
161
|
('stripe' if stripe?),
|
@@ -153,6 +164,10 @@ module EffectiveOrders
|
|
153
164
|
].compact
|
154
165
|
end
|
155
166
|
|
167
|
+
def self.deferred_providers
|
168
|
+
[('cheque' if cheque?), ('phone' if phone?)].compact
|
169
|
+
end
|
170
|
+
|
156
171
|
def self.can_skip_checkout_step1?
|
157
172
|
return false if require_billing_address
|
158
173
|
return false if require_shipping_address
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
@@ -138,13 +138,14 @@ files:
|
|
138
138
|
- app/controllers/effective/providers/mark_as_paid.rb
|
139
139
|
- app/controllers/effective/providers/moneris.rb
|
140
140
|
- app/controllers/effective/providers/paypal.rb
|
141
|
+
- app/controllers/effective/providers/phone.rb
|
141
142
|
- app/controllers/effective/providers/pretend.rb
|
142
143
|
- app/controllers/effective/providers/refund.rb
|
143
144
|
- app/controllers/effective/providers/stripe.rb
|
144
145
|
- app/controllers/effective/subscripter_controller.rb
|
145
146
|
- app/controllers/effective/webhooks_controller.rb
|
146
|
-
- app/datatables/effective_customers_datatable.rb
|
147
|
-
- app/datatables/
|
147
|
+
- app/datatables/admin/effective_customers_datatable.rb
|
148
|
+
- app/datatables/admin/effective_orders_datatable.rb
|
148
149
|
- app/datatables/effective_orders_datatable.rb
|
149
150
|
- app/helpers/effective_carts_helper.rb
|
150
151
|
- app/helpers/effective_orders_helper.rb
|
@@ -170,7 +171,7 @@ files:
|
|
170
171
|
- app/views/admin/customers/index.html.haml
|
171
172
|
- app/views/admin/customers/show.html.haml
|
172
173
|
- app/views/admin/order_items/index.html.haml
|
173
|
-
- app/views/admin/orders/
|
174
|
+
- app/views/admin/orders/_datatable_actions.html.haml
|
174
175
|
- app/views/admin/orders/_form.html.haml
|
175
176
|
- app/views/admin/orders/_form_note_internal.html.haml
|
176
177
|
- app/views/admin/orders/_order_actions.html.haml
|
@@ -190,21 +191,24 @@ files:
|
|
190
191
|
- app/views/effective/orders/_checkout_actions.html.haml
|
191
192
|
- app/views/effective/orders/_checkout_step1.html.haml
|
192
193
|
- app/views/effective/orders/_checkout_step2.html.haml
|
194
|
+
- app/views/effective/orders/_datatable_actions.html.haml
|
193
195
|
- app/views/effective/orders/_fields.html.haml
|
196
|
+
- app/views/effective/orders/_fields_note.html.haml
|
197
|
+
- app/views/effective/orders/_fields_terms.html.haml
|
194
198
|
- app/views/effective/orders/_order.html.haml
|
195
199
|
- app/views/effective/orders/_order_actions.html.haml
|
200
|
+
- app/views/effective/orders/_order_deferred.html.haml
|
196
201
|
- app/views/effective/orders/_order_footer.html.haml
|
197
202
|
- app/views/effective/orders/_order_header.html.haml
|
198
203
|
- app/views/effective/orders/_order_items.html.haml
|
199
|
-
- app/views/effective/orders/_order_note_fields.html.haml
|
200
204
|
- app/views/effective/orders/_order_notes.html.haml
|
201
|
-
- app/views/effective/orders/
|
205
|
+
- app/views/effective/orders/_order_payment.html.haml
|
202
206
|
- app/views/effective/orders/_order_shipping.html.haml
|
203
|
-
- app/views/effective/orders/_order_terms_and_conditions_fields.html.haml
|
204
207
|
- app/views/effective/orders/_orders_table.html.haml
|
205
208
|
- app/views/effective/orders/cheque/_form.html.haml
|
206
|
-
- app/views/effective/orders/cheque/pay_by_cheque.html.haml
|
207
209
|
- app/views/effective/orders/declined.html.haml
|
210
|
+
- app/views/effective/orders/deferred.html.haml
|
211
|
+
- app/views/effective/orders/deferred/_form.html.haml
|
208
212
|
- app/views/effective/orders/edit.html.haml
|
209
213
|
- app/views/effective/orders/free/_form.html.haml
|
210
214
|
- app/views/effective/orders/index.html.haml
|
@@ -212,6 +216,7 @@ files:
|
|
212
216
|
- app/views/effective/orders/moneris/_form.html.haml
|
213
217
|
- app/views/effective/orders/new.html.haml
|
214
218
|
- app/views/effective/orders/paypal/_form.html.haml
|
219
|
+
- app/views/effective/orders/phone/_form.html.haml
|
215
220
|
- app/views/effective/orders/pretend/_form.html.haml
|
216
221
|
- app/views/effective/orders/purchased.html.haml
|
217
222
|
- app/views/effective/orders/refund/_form.html.haml
|
@@ -1,99 +0,0 @@
|
|
1
|
-
class EffectiveOrderItemsDatatable < Effective::Datatable
|
2
|
-
datatable do
|
3
|
-
order :purchased_at, :desc
|
4
|
-
|
5
|
-
col(:purchased_at, sql_column: 'orders.purchased_at') do |order_item|
|
6
|
-
Time.at(order_item[:purchased_at]).in_time_zone if order_item[:purchased_at].present?
|
7
|
-
end
|
8
|
-
|
9
|
-
col :id, visible: false
|
10
|
-
|
11
|
-
col :order
|
12
|
-
|
13
|
-
# if effectiveorders.obfuscate_order_ids
|
14
|
-
# col(:order, type: :obfuscated_id) 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)))
|
17
|
-
# end
|
18
|
-
# else
|
19
|
-
# col(:order) 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)))
|
21
|
-
# end
|
22
|
-
# end
|
23
|
-
|
24
|
-
unless attributes[:user_id]
|
25
|
-
col :email, sql_column: 'users.email', label: 'Buyer Email' do |order_item|
|
26
|
-
link_to order_item[:email], (edit_admin_user_path(order_item[:user_id]) rescue admin_user_path(order_item[:user_id]) rescue '#')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# if EffectiveOrders.billing_address && attributes[:user_id].blank?
|
31
|
-
# col :buyer_name, sort: false, label: 'Buyer Name' do |order_item|
|
32
|
-
# (order_item[:buyer_name] || '').split('!!SEP!!').find(&:present?)
|
33
|
-
# end
|
34
|
-
# end
|
35
|
-
|
36
|
-
col :state, sql_column: 'orders.state', search: { collection: [%w(abandoned abandoned), [EffectiveOrders::PURCHASED, EffectiveOrders::PURCHASED], [EffectiveOrders::DECLINED, EffectiveOrders::DECLINED]], selected: EffectiveOrders::PURCHASED } do |order_item|
|
37
|
-
order_item[:state] || 'abandoned'
|
38
|
-
end
|
39
|
-
|
40
|
-
col :name do |order_item|
|
41
|
-
order_item.quantity == 1 ? order_item.name : "#{order_item.name} (#{order_item.quantity} purchased)"
|
42
|
-
end
|
43
|
-
|
44
|
-
# col :subtotal, as: :price
|
45
|
-
# col :tax, as: :price
|
46
|
-
# col :total, as: :price
|
47
|
-
|
48
|
-
col :created_at, visible: false
|
49
|
-
col :updated_at, visible: false
|
50
|
-
end
|
51
|
-
|
52
|
-
collection do
|
53
|
-
collection = Effective::OrderItem.unscoped
|
54
|
-
.joins(order: :user)
|
55
|
-
.select('order_items.*, orders.*, users.email AS email')
|
56
|
-
.select("#{query_subtotal} AS subtotal, #{query_tax} AS tax, #{query_total} AS total")
|
57
|
-
.group('order_items.id, orders.id, users.email')
|
58
|
-
|
59
|
-
if EffectiveOrders.billing_address && defined?(EffectiveAddresses)
|
60
|
-
addresses_tbl = EffectiveAddresses.addresses_table_name
|
61
|
-
|
62
|
-
collection = collection
|
63
|
-
.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")
|
64
|
-
.group("#{addresses_tbl}.buyer_name")
|
65
|
-
.select("#{addresses_tbl}.buyer_name AS buyer_name")
|
66
|
-
end
|
67
|
-
|
68
|
-
attributes[:user_id].present? ? collection.where("#{EffectiveOrders.orders_table_name.to_s}.user_id = ?", attributes[:user_id]) : collection
|
69
|
-
end
|
70
|
-
|
71
|
-
def query_subtotal
|
72
|
-
'SUM(price * quantity)'
|
73
|
-
end
|
74
|
-
|
75
|
-
def query_total
|
76
|
-
'SUM((price * quantity) + (CASE tax_exempt WHEN true THEN 0 ELSE ((price * quantity) * tax_rate) END))'
|
77
|
-
end
|
78
|
-
|
79
|
-
def query_tax
|
80
|
-
'(CASE tax_exempt WHEN true THEN 0 ELSE ((price * quantity) * tax_rate) END)'
|
81
|
-
end
|
82
|
-
|
83
|
-
# def search_column(collection, table_column, search_term)
|
84
|
-
# if table_column[:name] == 'order'
|
85
|
-
# collection.where("#{EffectiveOrders.order_items_table_name.to_s}.order_id = ?", Effective::Order.deobfuscate(search_term))
|
86
|
-
# elsif table_column[:name] == 'state' && search_term == 'abandoned'
|
87
|
-
# collection.where("#{EffectiveOrders.orders_table_name.to_s}.state IS NULL")
|
88
|
-
# elsif table_column[:name] == 'subtotal'
|
89
|
-
# collection.having("#{query_subtotal} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
90
|
-
# elsif table_column[:name] == 'tax'
|
91
|
-
# collection.having("#{query_tax} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
92
|
-
# elsif table_column[:name] == 'total'
|
93
|
-
# collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
94
|
-
# else
|
95
|
-
# super
|
96
|
-
# end
|
97
|
-
# end
|
98
|
-
|
99
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
= dropdown(variation: :dropleft) do
|
2
|
-
- if datatable.admin_namespace?
|
3
|
-
= dropdown_link_to 'View', effective_orders.admin_order_path(order)
|
4
|
-
|
5
|
-
- if order.purchased? == false
|
6
|
-
= dropdown_link_to 'Edit', effective_orders.edit_admin_order_path(order)
|
7
|
-
|
8
|
-
- if order.purchased?
|
9
|
-
= dropdown_link_to 'Email receipt to buyer', effective_orders.send_buyer_receipt_order_path(order),
|
10
|
-
data: { confirm: "Send receipt to #{order.user.email}?" }
|
11
|
-
|
12
|
-
- if order.pending? || order.confirmed?
|
13
|
-
= dropdown_link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
|
14
|
-
data: { method: :post, confirm: "Send request for payment to #{order.user.email}?" }
|
15
|
-
|
16
|
-
= dropdown_link_to 'Admin: Checkout', effective_orders.checkout_admin_order_path(order)
|
17
|
-
|
18
|
-
= dropdown_link_to "Delete #{order}", effective_orders.admin_order_path(order),
|
19
|
-
data: { method: :delete, confirm: "Really delete #{order}?" }
|
20
|
-
|
21
|
-
- else
|
22
|
-
= dropdown_link_to 'View', effective_orders.order_path(order)
|
@@ -1,18 +0,0 @@
|
|
1
|
-
- if order.purchased? && EffectiveOrders.authorized?(controller, :show, :payment_details)
|
2
|
-
.effective-order-payment-details
|
3
|
-
%h2 Payment Details
|
4
|
-
%table.table
|
5
|
-
%tbody
|
6
|
-
%tr
|
7
|
-
%td Provider
|
8
|
-
%td= order.payment_provider
|
9
|
-
%tr
|
10
|
-
%td Card
|
11
|
-
%td
|
12
|
-
= payment_card_label(order.payment_card)
|
13
|
-
= (order.payment['f4l4'] rescue nil)
|
14
|
-
|
15
|
-
%tr
|
16
|
-
%td Purchased at
|
17
|
-
%td= order.purchased_at.strftime('%F %H:%M')
|
18
|
-
|