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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '063584ca12ed4cb46363a9c7c99f729889bf536eb0a1afb6021e04f07349532b'
4
- data.tar.gz: 313908b8ff6797d96c7139a3598b6790a3fda9fb358e69a240e0ccb5afcd8569
3
+ metadata.gz: a31f4212c1ca7b711c0d7d03b69e58c6f1e0f77511883fa78409622323367062
4
+ data.tar.gz: b79a13299a5ab09053ce2350f38195c6dd1eb5daf2e6bb7eda235ee521b78c39
5
5
  SHA512:
6
- metadata.gz: 71a032b3e32b4387801d3630e58df4ee9b91f890a0d87e42c1c4eacb5cb49875e7494316089c01d9d9bdf8a10e246d09caa8d4d2bb400897221661957fc63034
7
- data.tar.gz: 7149e03e2c5f5f830a53f235eafd6c712213d5dd6eb4958554d752e7f8e51d124188cebe432284a8ddde462e2fd5ff7ec21999a00465220fbc9d4cb5f5a84a08
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
- self.state = EffectiveOrders::CONFIRMED if pending?
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
- product = Effective::Product.new(name: oi.purchasable.purchasable_name, price: oi.purchasable.price, tax_exempt: oi.purchasable.tax_exempt)
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?
@@ -11,7 +11,7 @@
11
11
  %tbody
12
12
  %tr
13
13
  - if order.note.present?
14
- %td= order.note
14
+ %td= simple_format(order.note)
15
15
 
16
16
  - if order.note_to_buyer.present?
17
- %td= order.note_to_buyer
17
+ %td= simple_format(order.note_to_buyer)
@@ -1,9 +1,14 @@
1
1
  .card
2
2
  .card-body
3
- %h2 Admin: Mark as Paid
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
- = f.date_field :purchased_at, required: true
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(:mark_as_paid), center: true
29
+ = f.submit 'Admin: ' + order_checkout_label(order.refund? ? :refund : :mark_as_paid)
data/config/routes.rb CHANGED
@@ -5,7 +5,7 @@ EffectiveOrders::Engine.routes.draw do
5
5
  get :purchased
6
6
  get :deferred
7
7
  get :declined
8
- get :send_buyer_receipt
8
+ post :send_buyer_receipt
9
9
 
10
10
  post :free
11
11
  post :mark_as_paid
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.1.6'.freeze
2
+ VERSION = '5.1.10'.freeze
3
3
  end
@@ -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
- STATES = { PENDING => PENDING, CONFIRMED => CONFIRMED, DEFERRED => DEFERRED, PURCHASED => PURCHASED, DECLINED => DECLINED }
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.6
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-07 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails