effective_orders 5.1.6 → 5.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/order.rb +23 -2
- data/app/views/effective/orders/_order_actions.html.haml +1 -1
- data/app/views/effective/orders/_order_notes.html.haml +2 -2
- data/app/views/effective/orders/mark_as_paid/_form.html.haml +8 -3
- data/config/routes.rb +1 -1
- data/lib/effective_orders/version.rb +1 -1
- data/lib/effective_orders.rb +10 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a31f4212c1ca7b711c0d7d03b69e58c6f1e0f77511883fa78409622323367062
|
4
|
+
data.tar.gz: b79a13299a5ab09053ce2350f38195c6dd1eb5daf2e6bb7eda235ee521b78c39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2068342ba84af239527321d6d566c1cd81cad00e91076dafbde3e77c02c491b4f8320d622b2144ec79b875db135da434e35604b7fa9af23e709ac0516990bd39
|
7
|
+
data.tar.gz: 7ac19a161ebafaa92c463ebbc36d0a825c99eb4a8ccd20d5bd0d797fd91443413cb6187abe4a50820d8bdf6d565e8232e74caf788a9a7448c1ca27c9e25e1910
|
@@ -72,7 +72,7 @@ module Effective
|
|
72
72
|
before_validation { assign_user_address }
|
73
73
|
|
74
74
|
before_validation(if: -> { confirmed_checkout }) do
|
75
|
-
|
75
|
+
assign_attributes(state: EffectiveOrders::CONFIRMED) if pending?
|
76
76
|
end
|
77
77
|
|
78
78
|
before_save(if: -> { state_was == EffectiveOrders::PURCHASED }) do
|
@@ -143,6 +143,7 @@ module Effective
|
|
143
143
|
scope :confirmed, -> { where(state: EffectiveOrders::CONFIRMED) }
|
144
144
|
scope :deferred, -> { where(state: EffectiveOrders::DEFERRED) }
|
145
145
|
scope :declined, -> { where(state: EffectiveOrders::DECLINED) }
|
146
|
+
scope :abandoned, -> { where(state: EffectiveOrders::ABANDONED) }
|
146
147
|
scope :refunds, -> { purchased.where('total < ?', 0) }
|
147
148
|
|
148
149
|
# Effective::Order.new()
|
@@ -203,9 +204,21 @@ module Effective
|
|
203
204
|
# Duplicate an existing order
|
204
205
|
self.note_to_buyer ||= item.note_to_buyer
|
205
206
|
self.note_internal ||= item.note_internal
|
207
|
+
self.cc ||= item.cc
|
206
208
|
|
207
209
|
item.order_items.select { |oi| oi.purchasable.kind_of?(Effective::Product) }.map do |oi|
|
208
|
-
|
210
|
+
purchasable = oi.purchasable
|
211
|
+
|
212
|
+
product = Effective::Product.new(name: purchasable.purchasable_name, price: purchasable.price, tax_exempt: purchasable.tax_exempt)
|
213
|
+
|
214
|
+
# Copy over any extended attributes that may have been created
|
215
|
+
atts = purchasable.dup.attributes.except('name', 'price', 'tax_exempt', 'purchased_order_id').compact
|
216
|
+
|
217
|
+
atts.each do |k, v|
|
218
|
+
next unless product.respond_to?("#{k}=") && product.respond_to?(k)
|
219
|
+
product.send("#{k}=", v) if product.send(k).blank?
|
220
|
+
end
|
221
|
+
|
209
222
|
Effective::CartItem.new(quantity: oi.quantity, purchasable: product)
|
210
223
|
end
|
211
224
|
else
|
@@ -283,6 +296,10 @@ module Effective
|
|
283
296
|
[card, '-', last4].compact.join(' ')
|
284
297
|
end
|
285
298
|
|
299
|
+
def duplicate
|
300
|
+
Effective::Order.new(self)
|
301
|
+
end
|
302
|
+
|
286
303
|
# For moneris and moneris_checkout. Just a unique value.
|
287
304
|
def transaction_id
|
288
305
|
[to_param, billing_name.to_s.parameterize.presence, Time.zone.now.to_i].compact.join('-')
|
@@ -318,6 +335,10 @@ module Effective
|
|
318
335
|
state == EffectiveOrders::DECLINED
|
319
336
|
end
|
320
337
|
|
338
|
+
def abandoned?
|
339
|
+
state == EffectiveOrders::ABANDONED
|
340
|
+
end
|
341
|
+
|
321
342
|
def purchasables
|
322
343
|
order_items.map { |order_item| order_item.purchasable }
|
323
344
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
- if order.purchased?
|
6
6
|
= link_to 'E-mail Receipt', effective_orders.send_buyer_receipt_order_path(order),
|
7
7
|
class: 'btn btn-secondary',
|
8
|
-
data: { confirm: "Send receipt to #{order.emails_send_to}?" }
|
8
|
+
data: { method: :post, confirm: "Send receipt to #{order.emails_send_to}?" }
|
9
9
|
|
10
10
|
- if order.persisted? && EffectiveResources.authorized?(controller, :admin, :effective_orders)
|
11
11
|
- if order.pending? || order.confirmed? || order.deferred?
|
@@ -1,9 +1,14 @@
|
|
1
1
|
.card
|
2
2
|
.card-body
|
3
|
-
%h2
|
3
|
+
%h2
|
4
|
+
Admin:
|
5
|
+
= order.refund? ? 'Complete Refund' : 'Mark as Paid'
|
4
6
|
|
5
7
|
= effective_form_with(model: order, url: effective_orders.mark_as_paid_order_path(order), method: :post) do |f|
|
6
|
-
|
8
|
+
- if order.refund?
|
9
|
+
= f.hidden_field :purchased_at, value: Time.zone.now
|
10
|
+
- else
|
11
|
+
= f.date_field :purchased_at, required: true
|
7
12
|
|
8
13
|
= f.select :payment_provider, EffectiveOrders.payment_providers, required: true
|
9
14
|
|
@@ -21,4 +26,4 @@
|
|
21
26
|
|
22
27
|
= f.text_area :note_to_buyer, hint: 'This message will be displayed on the receipt.'
|
23
28
|
|
24
|
-
= f.submit order_checkout_label(:
|
29
|
+
= f.submit 'Admin: ' + order_checkout_label(order.refund? ? :refund : :mark_as_paid)
|
data/config/routes.rb
CHANGED
data/lib/effective_orders.rb
CHANGED
@@ -10,7 +10,16 @@ module EffectiveOrders
|
|
10
10
|
DEFERRED = 'deferred' # Deferred providers. Cheque or Phone was selected.
|
11
11
|
PURCHASED = 'purchased' # Purchased by provider
|
12
12
|
DECLINED = 'declined' # Declined by provider
|
13
|
-
|
13
|
+
ABANDONED = 'abandoned' # Not set by this gem. Can be set outside it.
|
14
|
+
|
15
|
+
STATES = {
|
16
|
+
PENDING => PENDING,
|
17
|
+
CONFIRMED => CONFIRMED,
|
18
|
+
DEFERRED => DEFERRED,
|
19
|
+
PURCHASED => PURCHASED,
|
20
|
+
DECLINED => DECLINED,
|
21
|
+
ABANDONED => ABANDONED
|
22
|
+
}
|
14
23
|
|
15
24
|
# Subscription statuses (as per stripe)
|
16
25
|
ACTIVE = 'active'
|
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.1.
|
4
|
+
version: 5.1.10
|
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: 2021-09-
|
11
|
+
date: 2021-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|