effective_orders 5.1.7 → 5.1.11

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: 642b6831172be548e28cec2adf8c2f13f75ec9ef9af0e1cb15ee48cb763e3edc
4
- data.tar.gz: ce4111bbaf7d8fb7a50e16c7ff8a0a43ae412586d2c7063a9c6e910d1337fbc4
3
+ metadata.gz: d4ceb232058ad48722e375f9ada63ee99219ca2c6e4171ebc4be851dc5218518
4
+ data.tar.gz: a7ec1aabca5e20e22d834a6d9bca6a3efc277f2b2aabc03f888d274145fbaa80
5
5
  SHA512:
6
- metadata.gz: a7e2f6adabe417e43819f95c46e12dcc2c36680c82bedc870041a7665a700428428888927eb35b1dca18ab89d3d695b03183edc3cb35be3e1406f3befa0eee80
7
- data.tar.gz: 5650b3ed6960e16d3c630be6697ab9fe69084122a543f2cbbfec875a6defa3fefeb0bb19655affcaadbb4b15e074d5191579aead15107a91f447b401ae31f2aa
6
+ metadata.gz: d04a7b6902627945ecfae1c56b2133a3dba96b586a6f8eea8b61327de03c84c6e6cddbd374eff1b21d0030625014c5ab0471fb96ea7a37058373853d5be189c4
7
+ data.tar.gz: 95d763d0f61864d12fc6fde4a27f884af573ac218ea0f4947f7c00e8410308c6fd42d996519eb4b5872d19d79c67ca6ce68c5be1316468be451cf96a5f721213
@@ -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()
@@ -334,6 +335,10 @@ module Effective
334
335
  state == EffectiveOrders::DECLINED
335
336
  end
336
337
 
338
+ def abandoned?
339
+ state == EffectiveOrders::ABANDONED
340
+ end
341
+
337
342
  def purchasables
338
343
  order_items.map { |order_item| order_item.purchasable }
339
344
  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?
@@ -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.7'.freeze
2
+ VERSION = '5.1.11'.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.7
4
+ version: 5.1.11
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-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails