effective_orders 5.1.8 → 5.1.12

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: a32c61a739e40a41c7af3d4de0f254f8f1bf0aa673de5c98d82b404f700f1616
4
- data.tar.gz: 53f2b2f8e550b45e16fc1b844f6a8ebc30336d3ee10e3ac493a3cd4de07d9b85
3
+ metadata.gz: 436e77b078b12d2931ad0bf50e1f8572bfb6dca3cc7b021e0a867660ddd327c2
4
+ data.tar.gz: 128a0aece9b52ec31d4e5ff31ddd6a66f5179aeb7078542a5a5561d662745ebd
5
5
  SHA512:
6
- metadata.gz: dc2ee60878dc3c1cb2f2f81d86462f5aae9cca2297c1e2859ef90af51ebe9f511d3db580cfd0eddbb5d788f97ff84d2f467e7b65e5dc988d03b060148f3b09a5
7
- data.tar.gz: caf788b76fb2affe7ee4d5229d95c9fb62a2da798b1a7a3d981b38f9b8ba8d66f415fdefe8b3560220f3ce8441507a0273897785054e2721dbaa17bead649577
6
+ metadata.gz: 9b567e4f3078270590a92a12c4f27326a9c525b30e3ec8b2ed9ab31bc7d34f48b0fbab6a9ba0be8d00da8fd132b5d8032072b58e8c20da74f1e9b4017601b848
7
+ data.tar.gz: 0127161fde74a4fb97aec8c54ade566fed751e5bfd49f9d694b6a18d64d27bdd020a4106399c11121f1a661e9f127c56368a3771c977586cdf55b542147ffa5e
@@ -43,7 +43,7 @@ module Effective
43
43
  @order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param))
44
44
  @user = @order.user
45
45
 
46
- @subject = subject_for(@order, :payment_request_to_buyer, "Request for Payment: Invoice ##{@order.to_param}")
46
+ @subject = subject_for(@order, :payment_request_to_buyer, "Payment request - Order ##{@order.to_param}")
47
47
 
48
48
  mail({to: @order.email, cc: @order.cc, subject: @subject}.compact)
49
49
  end
@@ -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()
@@ -264,14 +265,30 @@ module Effective
264
265
  end
265
266
 
266
267
  def label
267
- if refund?
268
- "Refund"
268
+ if refund? && purchased?
269
+ 'Refund'
269
270
  elsif purchased?
270
- "Receipt"
271
- elsif pending?
272
- "Pending Order"
271
+ 'Receipt'
272
+ elsif refund? && (pending? || confirmed?)
273
+ 'Pending Refund'
274
+ elsif (pending? || confirmed?)
275
+ 'Pending Order'
273
276
  else
274
- "Order"
277
+ 'Order'
278
+ end
279
+ end
280
+
281
+ def total_label
282
+ if refund? && purchased?
283
+ 'Total Paid'
284
+ elsif purchased?
285
+ 'Total Paid'
286
+ elsif refund? && (pending? || confirmed?)
287
+ 'Total Due'
288
+ elsif (pending? || confirmed?)
289
+ 'Total Due'
290
+ else
291
+ 'Total'
275
292
  end
276
293
  end
277
294
 
@@ -334,6 +351,10 @@ module Effective
334
351
  state == EffectiveOrders::DECLINED
335
352
  end
336
353
 
354
+ def abandoned?
355
+ state == EffectiveOrders::ABANDONED
356
+ end
357
+
337
358
  def purchasables
338
359
  order_items.map { |order_item| order_item.purchasable }
339
360
  end
@@ -6,7 +6,7 @@
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.emails_send_to}?" }
9
+ data: { method: :post, 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),
@@ -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?
@@ -62,11 +62,6 @@
62
62
  %th.download
63
63
 
64
64
  %th.total
65
- - if order.pending?
66
- Amount Due
67
- - elsif order.purchased?
68
- Amount Paid
69
- - else
70
- Total
65
+ = order.total_label
71
66
 
72
67
  %td.price.total-price= price_to_currency(order.total)
@@ -5,7 +5,10 @@
5
5
  = order.refund? ? 'Complete Refund' : 'Mark as Paid'
6
6
 
7
7
  = effective_form_with(model: order, url: effective_orders.mark_as_paid_order_path(order), method: :post) do |f|
8
- = 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
9
12
 
10
13
  = f.select :payment_provider, EffectiveOrders.payment_providers, required: true
11
14
 
@@ -23,4 +26,4 @@
23
26
 
24
27
  = f.text_area :note_to_buyer, hint: 'This message will be displayed on the receipt.'
25
28
 
26
- = f.submit order_checkout_label(order.refund? ? :refund : :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.8'.freeze
2
+ VERSION = '5.1.12'.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.8
4
+ version: 5.1.12
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-09 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails