effective_orders 5.6.1 → 5.7.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed47eb29f0eb40e2b50f31007a7c7d27c01a0d511e2b5a0de59c4677a2d19c3
|
4
|
+
data.tar.gz: c9f86388847d98ff584118155e14cf783431be89a4a18d8b81d8ea8446c44d10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a654abd31e39c1e933136279289b77ba9b8afe33c56f3d5b745d73c9c85e15c0316d597a25093a0b987bcb135b1e9c4ca7d37719db3615f9a0718f25fc7adc39
|
7
|
+
data.tar.gz: b67584c4477f8012fd50f988e535a22591bd52a38d76e5db065ce68f3bc279ab11bdd9436ba86b0153e637788c9667895ac0ff93a7bc975d1d0842693fcbfb50
|
@@ -82,7 +82,7 @@ module Effective
|
|
82
82
|
self.state = EffectiveOrders::CONFIRMED if pending? && confirmed_checkout
|
83
83
|
end
|
84
84
|
|
85
|
-
with_options(unless: -> {
|
85
|
+
with_options(unless: -> { done? }) do
|
86
86
|
before_validation { assign_email }
|
87
87
|
before_validation { assign_user_address }
|
88
88
|
before_validation { assign_billing_name }
|
@@ -105,7 +105,7 @@ module Effective
|
|
105
105
|
|
106
106
|
validate(unless: -> { (free? && EffectiveOrders.free?) || (refund? && EffectiveOrders.refund?) }) do
|
107
107
|
if total.present? && total < EffectiveOrders.minimum_charge
|
108
|
-
|
108
|
+
errors.add(:total, "must be $#{'%0.2f' % (EffectiveOrders.minimum_charge.to_i / 100.0)} or more. Please add additional items.")
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -139,7 +139,7 @@ module Effective
|
|
139
139
|
validates :payment_provider, presence: true
|
140
140
|
|
141
141
|
validate do
|
142
|
-
|
142
|
+
errors.add(:payment_provider, "unknown deferred payment provider") unless EffectiveOrders.deferred_providers.include?(payment_provider)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
@@ -147,6 +147,10 @@ module Effective
|
|
147
147
|
raise EffectiveOrders::AlreadyPurchasedException.new('cannot unpurchase an order') unless purchased?
|
148
148
|
end
|
149
149
|
|
150
|
+
before_save(if: -> { done? }) do
|
151
|
+
raise('cannot change total of a purchased order') if changes[:total].present?
|
152
|
+
end
|
153
|
+
|
150
154
|
# Effective::Order.new()
|
151
155
|
# Effective::Order.new(Product.first)
|
152
156
|
# Effective::Order.new(current_cart)
|
@@ -390,7 +394,7 @@ module Effective
|
|
390
394
|
end
|
391
395
|
|
392
396
|
def done?
|
393
|
-
purchased? || declined?
|
397
|
+
persisted? && (purchased? || declined?)
|
394
398
|
end
|
395
399
|
|
396
400
|
# A custom order is one that was created by an admin
|
@@ -641,7 +645,6 @@ module Effective
|
|
641
645
|
EffectiveOrders.send_email(:refund_notification_to_admin, self) if purchased? && refund?
|
642
646
|
end
|
643
647
|
|
644
|
-
|
645
648
|
protected
|
646
649
|
|
647
650
|
def get_tax_rate
|
@@ -666,11 +669,11 @@ module Effective
|
|
666
669
|
end
|
667
670
|
|
668
671
|
def assign_billing_name
|
669
|
-
self.billing_name
|
672
|
+
self.billing_name = billing_address.try(:full_name).presence || user.to_s.presence
|
670
673
|
end
|
671
674
|
|
672
675
|
def assign_email
|
673
|
-
self.email
|
676
|
+
self.email = user.email if user.try(:email).present?
|
674
677
|
end
|
675
678
|
|
676
679
|
def assign_user_address
|
@@ -690,9 +693,9 @@ module Effective
|
|
690
693
|
# This overwrites the prices, taxes, etc on every save.
|
691
694
|
def assign_order_totals
|
692
695
|
# Copies prices from purchasable into order items
|
693
|
-
present_order_items.each { |oi| oi.assign_purchasable_attributes
|
696
|
+
present_order_items.each { |oi| oi.assign_purchasable_attributes }
|
694
697
|
|
695
|
-
#
|
698
|
+
# Sum of order item subtotals
|
696
699
|
subtotal = present_order_items.map { |oi| oi.subtotal }.sum
|
697
700
|
|
698
701
|
self.subtotal = subtotal
|
@@ -1,8 +1,9 @@
|
|
1
1
|
= effective_form_with(model: [:admin, order], engine: true) do |f|
|
2
2
|
= f.hidden_field :user_type, value: (f.object.user || current_user).class.name
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
= f.select :user_id, current_user.class.all, label: 'Buyer', required: true,
|
5
|
+
ajax_url: effective_resources.users_admin_select2_ajax_index_path,
|
6
|
+
hint: 'The user that should purchase this order.'
|
6
7
|
|
7
8
|
= f.email_cc_field :cc, hint: "Cc the above on any emailed receipts or payment requests."
|
8
9
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
%h1.effective-admin-heading= @page_title
|
2
2
|
|
3
|
-
|
3
|
+
- if @order.custom_order? && @order.in_progress?
|
4
|
+
= render 'effective/orders/order_actions', order: @order
|
4
5
|
|
5
|
-
- if @order.custom_order?
|
6
6
|
.mb-4
|
7
7
|
= collapse('show order') do
|
8
8
|
= render 'effective/orders/order', order: @order, no_order_actions: true
|
@@ -10,4 +10,6 @@
|
|
10
10
|
= render 'admin/orders/form', order: @order
|
11
11
|
|
12
12
|
- else
|
13
|
+
- # Same as the show action
|
13
14
|
= render 'effective/orders/order', order: @order
|
15
|
+
= render 'admin/orders/form_note_internal', order: @order
|
@@ -7,17 +7,18 @@
|
|
7
7
|
class: 'btn btn-secondary',
|
8
8
|
data: { method: :post, confirm: "Send receipt to #{order.emails_send_to}?" }
|
9
9
|
|
10
|
-
- if
|
11
|
-
- if
|
12
|
-
|
10
|
+
- if controller_path.include?('admin/') && (EffectiveResources.authorized?(controller, :admin, :effective_orders) rescue false)
|
11
|
+
- if order.persisted? && order.in_progress?
|
12
|
+
- if params[:action] == 'show'
|
13
|
+
= link_to('Edit', effective_orders.edit_admin_order_path(order), class: 'btn btn-primary')
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
- if params[:action] == 'edit'
|
16
|
+
= link_to('Show', effective_orders.admin_order_path(order), class: 'btn btn-primary')
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
= link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
|
19
|
+
class: 'btn btn-secondary',
|
20
|
+
data: { method: :post, confirm: "Send request for payment to #{order.emails_send_to}?" }
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
= link_to 'Delete', effective_orders.admin_order_path(order),
|
23
|
+
class: 'btn btn-danger',
|
24
|
+
data: { method: :delete, confirm: "Really delete #{order}?" }
|
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: 5.
|
4
|
+
version: 5.7.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: 2022-
|
11
|
+
date: 2022-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|