effective_orders 5.6.0 → 5.7.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10e6548b3a84173f5f3f45a9affc25399639d63ede24fe528ff209713567dee5
|
4
|
+
data.tar.gz: 54a7feb0ef6f669ab1d2fe01e5ec2b0097bde754653575c40b7806ce9ca26ddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea11b4ac3dfe6d4091a89761fbc434367c432b91ee0ae2e2f18b8d2fc79672e26a1488123f4214589ed1b7be8f2229b41d6df362c73a60d379dacd83f268f91d
|
7
|
+
data.tar.gz: 18632a2434b9081cad43dac618ce37785ac0fe1aa6a2770e09df9ce6a0e016f66c70b31f8b8d8db99a6920f04a3f7634524bcee1e13a1473acce6b4b7bb17c3b
|
@@ -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
|
@@ -34,7 +34,7 @@ module Effective
|
|
34
34
|
|
35
35
|
# This method is called in a before_validation in order.assign_order_totals()
|
36
36
|
def assign_purchasable_attributes
|
37
|
-
assign_attributes(name: purchasable.
|
37
|
+
assign_attributes(name: purchasable.purchasable_name, price: purchasable.price, tax_exempt: purchasable.tax_exempt) if purchasable
|
38
38
|
end
|
39
39
|
|
40
40
|
def build_purchasable(atts = {})
|
@@ -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.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: 2022-05-
|
11
|
+
date: 2022-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|