effective_resources 2.20.6 → 2.21.0

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: 97928e9b633c9913eca0ee5b59dfa00f262e6737913de56fc418e806744d5b95
4
- data.tar.gz: e6a905802155572d02e9e8eded99c084511e84d051f07c7041cf1fe0a099840d
3
+ metadata.gz: 325c0f900b5e2d964f5d3bece938f7a936106d5545f7a4fa43ca84b078ad3662
4
+ data.tar.gz: c97aa499db357d7f0a897ffa2118d3c8939d8f97069ed40aba7f64c215cdfdcf
5
5
  SHA512:
6
- metadata.gz: ff222ec2cf0e39d721d08fcffe0c2da186370fc10d1dd062cdcf0f348d30a7e072ead4a963d950b44c274a0e824dd7504a5b661d4400b00e7abfd93396b638f7
7
- data.tar.gz: 429ff43ed3b1f2b09e93cc734c9b9d482271fa62df210663ce7e422ba785889777e222d571627cebde925db909de26004633208f7b00ec6753c18a8028241f85
6
+ metadata.gz: 0affaea2159469810208e0f19e4ff83dbec90c236702a6a5c32a95b2f45ee3522f65eac8aa39255951eace3d7765636ee525a2cb6f955ee7e6ff64c051aa288a
7
+ data.tar.gz: 55ef59912a00a3d643119e78ea9e79865807beb25c59b42a66ded59061405459e629e45e1227a33e1b7eb2f59f4758d1923ef6a1fd7337fc1f9b2754111549ed
@@ -26,6 +26,13 @@ module ActsAsPurchasableWizard
26
26
  self.errors.add(:base, "must have an email") unless owner.email.present?
27
27
  end
28
28
 
29
+ after_defer do |_|
30
+ raise('expected submit_order to be deferred') unless submit_order&.deferred?
31
+ before_submit_deferred!
32
+ submit_deferred!
33
+ after_submit_deferred!
34
+ end
35
+
29
36
  after_purchase do |_|
30
37
  raise('expected submit_order to be purchased') unless submit_order&.purchased?
31
38
  before_submit_purchased!
@@ -180,9 +187,34 @@ module ActsAsPurchasableWizard
180
187
  end
181
188
  end
182
189
 
190
+ # The historic way of handling a deferred order checkout is to return to the :checkout step and not call wizard submit!
191
+ # With effective_events date delayed payments, we do call wizard submit! and proceed to the :submitted step.
192
+
193
+ # False by default - do not call submit
194
+ def submit_wizard_on_deferred_order?
195
+ false
196
+ end
197
+
198
+ # Called automatically via after_defer hook above
199
+ def submit_deferred!
200
+ return unless submit_wizard_on_deferred_order?
201
+ return false if was_submitted?
202
+
203
+ wizard_steps[:checkout] = Time.zone.now
204
+ submit!
205
+ end
206
+
207
+ # A hook to extend
208
+ def before_submit_deferred!
209
+ end
210
+
211
+ def after_submit_deferred!
212
+ end
213
+
183
214
  # Called automatically via after_purchase hook above
215
+ # If previously submitted, possibly with deferred order, just save so any before_save or validate can run.
184
216
  def submit_purchased!
185
- return false if was_submitted?
217
+ return save! if was_submitted?
186
218
 
187
219
  wizard_steps[:checkout] = Time.zone.now
188
220
  submit!
@@ -198,7 +230,12 @@ module ActsAsPurchasableWizard
198
230
  # Draft -> Submitted requirements
199
231
  def submit!
200
232
  raise('already submitted') if was_submitted?
201
- raise('expected a purchased order') unless submit_order&.purchased?
233
+
234
+ if submit_wizard_on_deferred_order?
235
+ raise('expected a purchased or deferred order') unless (submit_order&.purchased? || submit_order&.deferred?)
236
+ else
237
+ raise('expected a purchased order') unless submit_order&.purchased?
238
+ end
202
239
 
203
240
  wizard_steps[:checkout] ||= Time.zone.now
204
241
  wizard_steps[:submitted] = Time.zone.now
@@ -113,7 +113,7 @@ module ActsAsWizard
113
113
 
114
114
  # For use in the summary partials. Does not include summary.
115
115
  def render_steps
116
- blacklist = [:start, :billing, :checkout, :submit, :submitted, :summary]
116
+ blacklist = [:start, :billing, :checkout, :submit, :submitted, :complete, :completed, :summary]
117
117
  ((required_steps | completed_steps) - blacklist).select { |step| has_completed_step?(step) }
118
118
  end
119
119
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.20.6'.freeze
2
+ VERSION = '2.21.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.20.6
4
+ version: 2.21.0
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: 2024-05-13 00:00:00.000000000 Z
11
+ date: 2024-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails