effective_orders 4.4.3 → 4.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/orders_controller.rb +4 -4
- data/app/controllers/effective/concerns/purchase.rb +2 -2
- data/app/controllers/effective/orders_controller.rb +1 -1
- data/app/datatables/admin/effective_orders_datatable.rb +3 -3
- data/app/mailers/effective/orders_mailer.rb +3 -3
- data/app/models/effective/order.rb +17 -2
- data/app/models/effective/order_item.rb +2 -2
- data/app/views/admin/orders/_datatable_actions.html.haml +2 -2
- data/app/views/admin/orders/_form.html.haml +7 -3
- data/app/views/admin/orders/_order_item_fields.html.haml +4 -4
- data/app/views/effective/orders/_order_actions.html.haml +2 -2
- data/app/views/effective/orders/_order_shipping.html.haml +10 -2
- data/app/views/effective/orders_mailer/refund_notification_to_admin.html.haml +1 -1
- data/db/migrate/01_create_effective_orders.rb.erb +3 -1
- data/lib/effective_orders.rb +1 -1
- data/lib/effective_orders/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1c9cb84422232f69446f9612ffa08cebcdc62b85430377f42a7da21c716d10e
|
4
|
+
data.tar.gz: c72f1703bc93f608862bd55b093fb3fe0d2e239b5030ab43ccd90df616c7ed89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e28e1ffc282e08b81a2f85407fb084d4117ed0744a55f7b85e78c1dbe62711f04c80d6aee7cc814e4b1ef167edf4d21da88232a1b07023dc6af2f8ec8af1bce2
|
7
|
+
data.tar.gz: ed68a2d78bcae4af39223adb8ec445f9d7ccbc61a891717018e166021fa0f5f9ed193aba08c265cc998335438acf05b58f3619d82529233530e366488493d60e
|
@@ -43,7 +43,7 @@ module Admin
|
|
43
43
|
@order.pending!
|
44
44
|
|
45
45
|
message = 'Successfully created order'
|
46
|
-
message << ". A request for payment has been sent to #{@order.
|
46
|
+
message << ". A request for payment has been sent to #{@order.emails_send_to}" if @order.send_payment_request_to_buyer?
|
47
47
|
flash[:success] = message
|
48
48
|
|
49
49
|
redirect_to(admin_redirect_path) and return
|
@@ -149,7 +149,7 @@ module Admin
|
|
149
149
|
authorize_effective_order!
|
150
150
|
|
151
151
|
if @order.send_payment_request_to_buyer!
|
152
|
-
flash[:success] = "A request for payment has been sent to #{@order.
|
152
|
+
flash[:success] = "A request for payment has been sent to #{@order.emails_send_to}"
|
153
153
|
else
|
154
154
|
flash[:danger] = 'Unable to send payment request'
|
155
155
|
end
|
@@ -179,8 +179,8 @@ module Admin
|
|
179
179
|
private
|
180
180
|
|
181
181
|
def order_params
|
182
|
-
params.require(:effective_order).permit(:user_id, :
|
183
|
-
:note_internal, :note_to_buyer,
|
182
|
+
params.require(:effective_order).permit(:user_id, :cc,
|
183
|
+
:send_payment_request_to_buyer, :note_internal, :note_to_buyer,
|
184
184
|
:payment_provider, :payment_card, :payment, :send_mark_as_paid_email_to_buyer,
|
185
185
|
order_items_attributes: [
|
186
186
|
:quantity, :_destroy, purchasable_attributes: [
|
@@ -13,7 +13,7 @@ module Effective
|
|
13
13
|
|
14
14
|
if flash[:success].blank?
|
15
15
|
if EffectiveOrders.mailer[:send_order_receipt_to_buyer] && email
|
16
|
-
flash[:success] = "Payment successful! A receipt has been sent to #{@order.
|
16
|
+
flash[:success] = "Payment successful! A receipt has been sent to #{@order.emails_send_to}"
|
17
17
|
else
|
18
18
|
flash[:success] = "Payment successful! An email receipt has not been sent."
|
19
19
|
end
|
@@ -36,7 +36,7 @@ module Effective
|
|
36
36
|
|
37
37
|
if flash[:success].blank?
|
38
38
|
if email
|
39
|
-
flash[:success] = "Deferred payment created! A request for payment has been sent to #{@order.
|
39
|
+
flash[:success] = "Deferred payment created! A request for payment has been sent to #{@order.emails_send_to}"
|
40
40
|
else
|
41
41
|
flash[:success] = "Deferred payment created!"
|
42
42
|
end
|
@@ -110,7 +110,7 @@ module Effective
|
|
110
110
|
EffectiveOrders.authorize!(self, :show, @order)
|
111
111
|
|
112
112
|
if @order.send_order_receipt_to_buyer!
|
113
|
-
flash[:success] = "A receipt has been sent to #{@order.
|
113
|
+
flash[:success] = "A receipt has been sent to #{@order.emails_send_to}"
|
114
114
|
else
|
115
115
|
flash[:danger] = "Unable to send receipt."
|
116
116
|
end
|
@@ -39,10 +39,12 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
|
|
39
39
|
|
40
40
|
if attributes[:user_id].blank?
|
41
41
|
col :user
|
42
|
-
col 'user.email', visible: false
|
43
42
|
col :billing_name, visible: false
|
43
|
+
col :email, visible: false
|
44
44
|
end
|
45
45
|
|
46
|
+
col :cc, visible: false
|
47
|
+
|
46
48
|
if EffectiveOrders.billing_address
|
47
49
|
col :billing_address, visible: false
|
48
50
|
end
|
@@ -86,8 +88,6 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
|
|
86
88
|
|
87
89
|
if attributes[:user_id].present?
|
88
90
|
scope = scope.where(user: user)
|
89
|
-
else
|
90
|
-
scope = scope.joins(:user)
|
91
91
|
end
|
92
92
|
|
93
93
|
scope
|
@@ -24,7 +24,7 @@ module Effective
|
|
24
24
|
|
25
25
|
@subject = subject_for(@order, :order_receipt_to_buyer, "Order Receipt: ##{@order.to_param}")
|
26
26
|
|
27
|
-
mail(to: @order.
|
27
|
+
mail(to: @order.email, cc: @order.cc, subject: @subject)
|
28
28
|
end
|
29
29
|
|
30
30
|
# This is sent when an admin creates a new order or /admin/orders/new
|
@@ -38,7 +38,7 @@ module Effective
|
|
38
38
|
|
39
39
|
@subject = subject_for(@order, :payment_request_to_buyer, "Request for Payment: Invoice ##{@order.to_param}")
|
40
40
|
|
41
|
-
mail(to: @order.
|
41
|
+
mail(to: @order.email, cc: @order.cc, subject: @subject)
|
42
42
|
end
|
43
43
|
|
44
44
|
# This is sent when someone chooses to Pay by Cheque
|
@@ -50,7 +50,7 @@ module Effective
|
|
50
50
|
|
51
51
|
@subject = subject_for(@order, :pending_order_invoice_to_buyer, "Pending Order: ##{@order.to_param}")
|
52
52
|
|
53
|
-
mail(to: @order.
|
53
|
+
mail(to: @order.email, cc: @order.cc, subject: @subject)
|
54
54
|
end
|
55
55
|
|
56
56
|
# This is sent to admin when someone Accepts Refund
|
@@ -42,9 +42,11 @@ module Effective
|
|
42
42
|
# note_to_buyer :text # From admin to buyer
|
43
43
|
# note_internal :text # Internal admin only
|
44
44
|
#
|
45
|
-
# billing_name :string
|
46
|
-
#
|
45
|
+
# billing_name :string # name of buyer
|
46
|
+
# email :string # same as user.email
|
47
|
+
# cc :string # can be set by admin
|
47
48
|
#
|
49
|
+
# payment :text # serialized hash containing all the payment details.
|
48
50
|
# payment_provider :string
|
49
51
|
# payment_card :string
|
50
52
|
#
|
@@ -60,6 +62,7 @@ module Effective
|
|
60
62
|
|
61
63
|
before_validation { assign_order_totals }
|
62
64
|
before_validation { assign_billing_name }
|
65
|
+
before_validation { assign_email }
|
63
66
|
before_validation { assign_last_address }
|
64
67
|
|
65
68
|
before_validation(if: -> { confirmed_checkout }) do
|
@@ -68,6 +71,9 @@ module Effective
|
|
68
71
|
|
69
72
|
# Order validations
|
70
73
|
validates :user_id, presence: true
|
74
|
+
validates :email, presence: true, email: true # email and cc validators are from effective_resources
|
75
|
+
validates :cc, email_cc: true
|
76
|
+
|
71
77
|
validates :order_items, presence: { message: 'No items are present. Please add additional items.' }
|
72
78
|
validates :state, inclusion: { in: EffectiveOrders::STATES.keys }
|
73
79
|
validates :subtotal, presence: true
|
@@ -411,6 +417,11 @@ module Effective
|
|
411
417
|
true
|
412
418
|
end
|
413
419
|
|
420
|
+
# Doesn't control anything. Purely for the flash messaging
|
421
|
+
def emails_send_to
|
422
|
+
[email, cc.presence].compact.to_sentence
|
423
|
+
end
|
424
|
+
|
414
425
|
def send_order_receipts!
|
415
426
|
send_order_receipt_to_admin! if EffectiveOrders.mailer[:send_order_receipt_to_admin]
|
416
427
|
send_order_receipt_to_buyer! if EffectiveOrders.mailer[:send_order_receipt_to_buyer]
|
@@ -470,6 +481,10 @@ module Effective
|
|
470
481
|
self.billing_name = [(billing_address.full_name.presence if billing_address.present?), (user.to_s.presence)].compact.first
|
471
482
|
end
|
472
483
|
|
484
|
+
def assign_email
|
485
|
+
self.email = user&.email
|
486
|
+
end
|
487
|
+
|
473
488
|
def assign_last_address
|
474
489
|
return unless user.present?
|
475
490
|
return unless (EffectiveOrders.billing_address || EffectiveOrders.shipping_address)
|
@@ -20,8 +20,8 @@ module Effective
|
|
20
20
|
validates :price, presence: true
|
21
21
|
validates :tax_exempt, inclusion: { in: [true, false] }
|
22
22
|
|
23
|
-
scope :
|
24
|
-
scope :
|
23
|
+
scope :purchased, -> { where(order_id: Effective::Order.purchased) }
|
24
|
+
scope :purchased_by, lambda { |user| where(order_id: Effective::Order.purchased_by(user)) }
|
25
25
|
|
26
26
|
def to_s
|
27
27
|
(quantity || 0) > 1 ? "#{quantity}x #{name}" : name
|
@@ -6,11 +6,11 @@
|
|
6
6
|
|
7
7
|
- if order.purchased?
|
8
8
|
= dropdown_link_to 'Email receipt to buyer', effective_orders.send_buyer_receipt_order_path(order),
|
9
|
-
data: { confirm: "Send receipt to #{order.
|
9
|
+
data: { confirm: "Send receipt to #{order.emails_send_to}?" }
|
10
10
|
|
11
11
|
- if order.pending? || order.confirmed? || order.deferred?
|
12
12
|
= dropdown_link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
|
13
|
-
data: { method: :post, confirm: "Send request for payment to #{order.
|
13
|
+
data: { method: :post, confirm: "Send request for payment to #{order.emails_send_to}?" }
|
14
14
|
|
15
15
|
= dropdown_link_to 'Admin: Checkout', effective_orders.checkout_admin_order_path(order)
|
16
16
|
|
@@ -1,20 +1,24 @@
|
|
1
1
|
= effective_form_with(model: [:admin, order], url: (order.persisted? ? effective_orders.admin_order_path(order) : effective_orders.admin_orders_path)) do |f|
|
2
2
|
- if f.object.new_record?
|
3
|
-
= f.select :user_id, @users || User.all.to_a.sort { |user1, user2| user1.to_s <=> user2.to_s },
|
3
|
+
= f.select :user_id, @users || User.all.to_a.sort { |user1, user2| user1.to_s <=> user2.to_s },
|
4
|
+
label: 'Buyer', required: true, hint: 'The user that should purchase this order.'
|
5
|
+
|
6
|
+
= f.cc_field :cc, hint: "Cc the above on any emailed receipts or payment requests."
|
4
7
|
|
5
8
|
%h2 Order Items
|
6
9
|
.order_items
|
7
10
|
- f.object.order_items.build unless f.object.order_items.present?
|
11
|
+
|
8
12
|
= f.fields_for :order_items, f.object.order_items do |order_item|
|
9
13
|
= render 'order_item_fields', f: order_item
|
10
14
|
|
11
15
|
.links
|
12
|
-
= link_to_add_association
|
16
|
+
= link_to_add_association (icon('plus') + 'Add item'), f, :order_items, class: 'btn btn-secondary', partial: 'order_item_fields'
|
13
17
|
|
14
18
|
%hr
|
15
19
|
|
16
20
|
= f.check_box :send_payment_request_to_buyer,
|
17
|
-
label: 'Yes, send a payment request email to the buyer.',
|
21
|
+
label: 'Yes, send a payment request email to the buyer and any cc.',
|
18
22
|
value: (f.object.send_payment_request_to_buyer.nil? ? EffectiveOrders.mailer[:send_payment_request_to_buyer] : f.object.send_payment_request_to_buyer?)
|
19
23
|
|
20
24
|
.row
|
@@ -1,7 +1,7 @@
|
|
1
1
|
.nested-fields.order-item
|
2
2
|
.row.align-items-center
|
3
3
|
= f.fields_for :purchasable, (f.object.purchasable || Effective::Product.new) do |pf|
|
4
|
-
.col-md-
|
4
|
+
.col-md-2= f.number_field :quantity, input_html: { value: f.object.quantity || 1, min: 1 }
|
5
5
|
.col-md-4= pf.text_field :name, maxlength: 255
|
6
6
|
.col-md-2= pf.price_field :price
|
7
7
|
|
@@ -9,6 +9,6 @@
|
|
9
9
|
.col-md-2= pf.text_field :qb_item_name, maxlength: 255, label: 'Quickbooks Item'
|
10
10
|
|
11
11
|
.col-md-2.mt-4= pf.check_box :tax_exempt, label: "Tax Exempt", title: 'When checked, tax will not be applied to this item'
|
12
|
-
.col-md-1
|
13
|
-
= link_to_remove_association(f, 'data-confirm': '
|
14
|
-
= icon('
|
12
|
+
.col-md-1
|
13
|
+
= link_to_remove_association(f, 'data-confirm': 'Remove?') do
|
14
|
+
= icon('trash-2', class: 'text-danger')
|
@@ -5,13 +5,13 @@
|
|
5
5
|
- if order.purchased?
|
6
6
|
= link_to 'Email receipt to buyer', effective_orders.send_buyer_receipt_order_path(order),
|
7
7
|
class: 'btn btn-secondary',
|
8
|
-
data: { confirm: "Send receipt to #{order.
|
8
|
+
data: { confirm: "Send receipt to #{order.emails_send_to}?" }
|
9
9
|
|
10
10
|
- if order.persisted? && EffectiveOrders.authorized?(controller, :admin, :effective_orders)
|
11
11
|
- if order.pending? || order.confirmed? || order.deferred?
|
12
12
|
= link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
|
13
13
|
class: 'btn btn-secondary',
|
14
|
-
data: { method: :post, confirm: "Send request for payment to #{order.
|
14
|
+
data: { method: :post, confirm: "Send request for payment to #{order.emails_send_to}?" }
|
15
15
|
|
16
16
|
= link_to 'Delete', effective_orders.admin_order_path(order),
|
17
17
|
class: 'btn btn-danger',
|
@@ -14,8 +14,16 @@
|
|
14
14
|
%br
|
15
15
|
|
16
16
|
- if order.billing_address.present?
|
17
|
-
= render partial: 'effective/addresses/address',
|
18
|
-
|
17
|
+
= render partial: 'effective/addresses/address', locals: { address: order.billing_address }
|
18
|
+
%br
|
19
|
+
|
20
|
+
= mail_to(order.email)
|
21
|
+
|
22
|
+
- if order.cc.present?
|
23
|
+
%br
|
24
|
+
Cc:
|
25
|
+
- order.cc.split(',').each do |email|
|
26
|
+
= mail_to(email)
|
19
27
|
|
20
28
|
- if order.shipping_address.present?
|
21
29
|
%td
|
data/lib/effective_orders.rb
CHANGED
@@ -88,7 +88,7 @@ module EffectiveOrders
|
|
88
88
|
|
89
89
|
def self.permitted_params
|
90
90
|
[
|
91
|
-
:note, :terms_and_conditions, :confirmed_checkout,
|
91
|
+
:cc, :note, :terms_and_conditions, :confirmed_checkout,
|
92
92
|
billing_address: EffectiveAddresses.permitted_params,
|
93
93
|
shipping_address: EffectiveAddresses.permitted_params,
|
94
94
|
subscripter: [:stripe_plan_id, :stripe_token]
|