effective_orders 6.18.2 → 6.18.4

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: 30573ea76732efc461d77ac72855675f2a8de7010a81e9d651fafaceb86c75c5
4
- data.tar.gz: 605bb5659cb3b7faf9e0940ed59367b3abfc09535f9f42dcb4048594f1408c09
3
+ metadata.gz: 6d30ecbd0854168592005b06f14661ded4e48e61a8b4b4a181e652c0c3826cbc
4
+ data.tar.gz: 42506cd1c6268406fa3e7cb8802799905d5e10fc0ace73fd4982c7f8500cb9de
5
5
  SHA512:
6
- metadata.gz: 4f14a09c4ea459f96eb727ac1b7bd8249e1fd42f087a1afca09e3c5705837ddb5ff7b859ab81e654a1e1607f5e4875a82ae8df58c846b50cef79b0296ce9e809
7
- data.tar.gz: c2863834450dad29c443746f3dc4c0db11115ffb03796dd4e35d99d707e12bc81c15cc7d609625dd9ae222f42e276e8d8aa046c089fb0572b66862efa23ceb61
6
+ metadata.gz: bc88b76583abd395fda539b6a237218f3e625fc88f83c878b0d0d71e114a2002c701aaf574bee9cc179a15fd6d24a9291a642bf66c407c8e729a5783a4fc0595
7
+ data.tar.gz: 215adf0b221c134a2925c52ed4312ed1daec375cd0977db3a82464fe35e7bc9dff5c16e613c635faf7191a42398c856a3d9b72eb3cba5ea2085525377109a5d6
@@ -154,12 +154,14 @@ module Effective
154
154
  scope :pending_refunds, -> { not_purchased.where('total < ?', 0) }
155
155
 
156
156
  scope :delayed, -> { where(delayed_payment: true).where.not(delayed_payment_date: nil) }
157
+ scope :delayed_payment_provider, -> { where(payment_provider: EffectiveOrders.delayed_providers) }
157
158
  scope :delayed_payment_date_past, -> { delayed.where(arel_table[:delayed_payment_date].lteq(Time.zone.today)) }
158
159
  scope :delayed_payment_date_upcoming, -> { delayed.where(arel_table[:delayed_payment_date].gt(Time.zone.today)) }
159
160
 
160
161
  # Used by the rake effective_orders:purchase_delayed_orders task
161
162
  scope :delayed_ready_to_purchase, -> {
162
- delayed.deferred.delayed_payment_date_past.where(delayed_payment_purchase_ran_at: nil)
163
+ delayed.deferred.delayed_payment_provider.delayed_payment_date_past
164
+ .where(delayed_payment_purchase_ran_at: nil).where.not(delayed_payment_intent: nil)
163
165
  }
164
166
 
165
167
  # effective_reports
@@ -196,7 +198,8 @@ module Effective
196
198
  validates :delayed_payment_date, presence: true, if: -> { delayed_payment? }
197
199
  validates :delayed_payment_date, absence: true, unless: -> { delayed_payment? }
198
200
 
199
- with_options(if: -> { delayed? && deferred? }) do
201
+ # deluxe_delayed
202
+ with_options(if: -> { delayed? && deferred? && delayed_payment_provider? }) do
200
203
  validates :delayed_payment_intent, presence: { message: 'please provide your card information' }
201
204
  validates :delayed_payment_total, presence: true
202
205
  end
@@ -248,7 +251,7 @@ module Effective
248
251
  validates :payment_provider, presence: true
249
252
 
250
253
  validate do
251
- unless EffectiveOrders.deferred_providers.include?(payment_provider) || EffectiveOrders.delayed_providers.include?(payment_provider)
254
+ unless deferred_payment_provider? || delayed_payment_provider?
252
255
  errors.add(:payment_provider, "unknown deferred payment provider")
253
256
  end
254
257
  end
@@ -546,6 +549,14 @@ module Effective
546
549
  def refund?
547
550
  total.to_i < 0
548
551
  end
552
+
553
+ def delayed_payment_provider?
554
+ payment_provider.present? && EffectiveOrders.delayed_providers.include?(payment_provider)
555
+ end
556
+
557
+ def deferred_payment_provider?
558
+ payment_provider.present? && EffectiveOrders.deferred_providers.include?(payment_provider)
559
+ end
549
560
 
550
561
  # A new order is created.
551
562
  # If the delayed_payment and delayed_payment date are set, it's a delayed order
@@ -558,6 +569,7 @@ module Effective
558
569
  def delayed_ready_to_purchase?
559
570
  return false unless delayed?
560
571
  return false unless deferred?
572
+ return false unless delayed_payment_provider?
561
573
  return false unless delayed_payment_intent.present?
562
574
  return false if delayed_payment_date_upcoming?
563
575
  return false if delayed_payment_purchase_ran_at.present? # We ran before and probably failed
@@ -566,7 +578,7 @@ module Effective
566
578
  end
567
579
 
568
580
  def delayed_payment_info
569
- return unless delayed? && deferred?
581
+ return unless delayed? && deferred? && delayed_payment_provider?
570
582
  return unless delayed_payment_date_upcoming?
571
583
 
572
584
  "Your #{delayed_payment_method} will be charged $#{'%0.2f' % total_to_f} on #{delayed_payment_date.strftime('%F')}"
@@ -796,6 +808,11 @@ module Effective
796
808
  deferred_by: (deferred_by.presence || current_user)
797
809
  )
798
810
 
811
+ # Went from delayed to cheque
812
+ if delayed_payment? && !delayed_payment_provider?
813
+ assign_attributes(delayed_payment: false, delayed_payment_date: nil, delayed_payment_intent: nil, delayed_payment_total: nil)
814
+ end
815
+
799
816
  if current_user&.email.present?
800
817
  assign_attributes(email: current_user.email)
801
818
  end
@@ -12,6 +12,10 @@
12
12
  - if EffectiveOrders.delayed? && order.delayed_payment_date_upcoming?
13
13
  = render partial: '/effective/orders/delayed/form', locals: provider_locals
14
14
 
15
+ - if EffectiveOrders.deferred? && !controller_path.include?('admin/') && !local_assigns[:skip_deferred]
16
+ %p.my-4.text-center - or -
17
+ = render partial: '/effective/orders/deferred/form', locals: provider_locals
18
+
15
19
  - elsif EffectiveOrders.free? && order.free?
16
20
  = render partial: '/effective/orders/free/form', locals: provider_locals
17
21
 
@@ -41,8 +45,8 @@
41
45
  %p.my-4.text-center - or -
42
46
  = render partial: '/effective/orders/deferred/form', locals: provider_locals
43
47
 
44
- - if EffectiveResources.authorized?(controller, :admin, :effective_orders) && controller_path.include?('admin/') && order.user != current_user
45
- - if EffectiveOrders.delayed? && order.delayed? && order.deferred?
48
+ - if EffectiveResources.authorized?(controller, :admin, :effective_orders) && controller_path.include?('admin/')
49
+ - if EffectiveOrders.delayed? && order.delayed? && order.deferred? && order.delayed_payment_provider?
46
50
  .effective-order-admin-purchase-actions
47
51
  = render partial: '/effective/orders/delayed/form_purchase', locals: provider_locals
48
52
 
@@ -7,7 +7,7 @@
7
7
  %tbody
8
8
  %tr
9
9
  %td
10
- - if order.delayed?
10
+ - if order.delayed? && order.delayed_payment_provider?
11
11
  %p Your #{order.delayed_payment_method} will be charged on #{order.delayed_payment_date.strftime('%F')}
12
12
  - else
13
13
  %p Waiting for payment by #{order.payment_provider}.
@@ -17,7 +17,7 @@
17
17
 
18
18
  - provider_locals = { order: order, deferred_url: deferred_url, declined_url: declined_url }
19
19
 
20
- - if order.deferred? && order.delayed?
20
+ - if order.deferred? && order.delayed? && order.delayed_payment_provider?
21
21
  %p Your existing #{order.delayed_payment_method} will be charged on the payment date.
22
22
 
23
23
  = collapse('Change my card info') do
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.18.2'.freeze
2
+ VERSION = '6.18.4'.freeze
3
3
  end
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: 6.18.2
4
+ version: 6.18.4
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: 2025-01-06 00:00:00.000000000 Z
11
+ date: 2025-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails