effective_memberships 0.17.2 → 0.17.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: 5e2e3a9a54270eaf14471e05b279d68d6f6d67238daf4b016fa70681c82d07a4
4
- data.tar.gz: 8e344f17e247d18db2e9a5c276f4124d3eeff041a1761ef49906d2cd75bdec21
3
+ metadata.gz: 702306099757c4fc797be8baaab6e90a8f122b1b21ee2d45975c0e9e204c77a9
4
+ data.tar.gz: 1ddd79323d0835c87d7625be41b3fa17548f617b06223d655dac3fbf978b03b3
5
5
  SHA512:
6
- metadata.gz: b8eff0a5c66e4b2e0d59024c4e686cbf2a0ca264df522064c5074c89b8fd911d4c14be2732e0ea677a1e9998a36a2d9674acf70ccb1393ca74f7a1a1e6ce3c8a
7
- data.tar.gz: c4190c54eff0c58c6b1234f5f739d1b131c0dcc90cba603f1708a55a0dac9c224eec0ca0be8964b3bdae09cddcab32322adeeb4789792487b737fdb17b41caad
6
+ metadata.gz: c740293acf21b1f6c31e3c617e0c0a3c76918d7203c29b001b84de562240d1ae2a803bd7743eab552fdedc684626a5841b60e69a5a3e7b8e93d84687a5f08cc1
7
+ data.tar.gz: 7dc911eab9b73239a5944bdae2b5ac3593aa069c46e89cee575efc6686e611dfbbee6d4b0b1a175f4362fbd93ae2e1ab7175ad8a6e10c5c6cc923109d0155f50
@@ -48,6 +48,7 @@ module EffectiveMembershipsFeePayment
48
48
 
49
49
  # CPD Step
50
50
  attr_accessor :declare_cpd
51
+ attr_accessor :skip_cpd_validation
51
52
 
52
53
  # Declarations Step
53
54
  attr_accessor :declare_code_of_ethics
@@ -127,11 +128,11 @@ module EffectiveMembershipsFeePayment
127
128
  # CPD step
128
129
  with_options(if: -> { current_step == :cpd }) do
129
130
  validates :declare_cpd, acceptance: true
131
+ end
130
132
 
131
- validate do
132
- if (cpd_cycles = cpd_uncompleted_cpd_cycles).present?
133
- self.errors.add(:base, "Please complete #{cpd_cycles.map(&:to_s).to_sentence} to continue")
134
- end
133
+ validate(if: -> { current_step == :cpd && !skip_cpd_validation }) do
134
+ if (cpd_cycles = cpd_uncompleted_cpd_cycles).present?
135
+ self.errors.add(:base, "Please complete #{cpd_cycles.map(&:to_s).to_sentence} to continue")
135
136
  end
136
137
  end
137
138
 
@@ -172,6 +173,11 @@ module EffectiveMembershipsFeePayment
172
173
  end
173
174
  end
174
175
 
176
+ def can_visit_step?(step)
177
+ return (step == :submitted) if was_submitted?
178
+ can_revisit_completed_steps(step)
179
+ end
180
+
175
181
  # All Fees and Orders
176
182
  # Overriding acts_as_purchasable_wizard
177
183
  def submit_fees
@@ -246,12 +252,30 @@ module EffectiveMembershipsFeePayment
246
252
  end
247
253
 
248
254
  def cpd_required_cpd_cycles
249
- date = submitted_at || Time.zone.now
255
+ @cpd_required_cpd_cycles ||= begin
256
+ date = submitted_at || Time.zone.now
257
+
258
+ cpd_cycles = [] # Return value
259
+
260
+ # The current and previous cycle
261
+ current = EffectiveCpd.current_cpd_cycle(date: date)
262
+ previous = EffectiveCpd.previous_cpd_cycle(date: date)
250
263
 
251
- [
252
- (EffectiveCpd.previous_cpd_cycle(date: date) if cpd_requirement.to_s.include?('previous')),
253
- (EffectiveCpd.current_cpd_cycle(date: date) if cpd_requirement.to_s.include?('current'))
254
- ].compact
264
+ if current.present? && cpd_requirement.to_s.include?('current')
265
+ cpd_cycles << current
266
+ end
267
+
268
+ # Only include if they were a member during the previous period
269
+ if previous.present? && cpd_requirement.to_s.include?('previous')
270
+ period = EffectiveMemberships.Registrar.period(date: previous.end_at&.advance(months: -1) || current&.start_at&.advance(months: -1) || previous.start_at.advance(months: 1))
271
+ renewal_date = EffectiveMemberships.Registrar.renewal_fee_date(date: period)
272
+ membership_history = owner.membership_history_on(renewal_date.advance(days: -1))
273
+
274
+ cpd_cycles << previous if membership_history.present? && !membership_history.removed?
275
+ end
276
+
277
+ cpd_cycles
278
+ end
255
279
  end
256
280
 
257
281
  def cpd_completed_cpd_cycles
@@ -432,6 +432,13 @@ module EffectiveMembershipsOwner
432
432
  history
433
433
  end
434
434
 
435
+ def membership_category_start_on(category: :current)
436
+ category = membership&.categories&.first if category == :current
437
+ raise('expected a category') unless category.present?
438
+
439
+ membership_histories.find { |history| history.membership_category_ids.include?(category.id) }&.start_on || membership&.joined_on
440
+ end
441
+
435
442
  def membership_history_on(date)
436
443
  raise('expected a date') unless date.respond_to?(:strftime)
437
444
  membership_histories.find { |history| (history.start_on..history.end_on).cover?(date) } # Ruby 2.6 supports endless ranges
@@ -103,6 +103,7 @@ module EffectiveMembershipsRegistrar
103
103
  end
104
104
 
105
105
  # This is only used for a form collection on admin memberships
106
+ # And now for ASPB applicant reinstatement fees
106
107
  def periods(from:, to: nil)
107
108
  to ||= Time.zone.now
108
109
 
@@ -69,5 +69,13 @@ module Effective
69
69
  assign_attributes(statuses: statuses.map(&:to_s), status_ids: statuses.map(&:id))
70
70
  end
71
71
 
72
+ def start_period
73
+ EffectiveMemberships.Registrar.period(date: start_on)
74
+ end
75
+
76
+ def end_period
77
+ EffectiveMemberships.Registrar.period(date: end_on)
78
+ end
79
+
72
80
  end
73
81
  end
@@ -4,12 +4,12 @@
4
4
  = card(et('effective_cpd.name')) do
5
5
  = render('cpd_requirements', applicant: resource)
6
6
 
7
- = card('All ' + cpd_statements_label) do
8
- = render('effective/wizard_steps/cpd_statements', resource: resource)
9
-
10
7
  = card('Requirements') do
11
8
  = render('effective/wizard_steps/cpd_requirements', resource: resource)
12
9
 
10
+ = card('All ' + cpd_statements_label) do
11
+ = render('effective/wizard_steps/cpd_statements', resource: resource)
12
+
13
13
  = card do
14
14
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
15
15
  = f.hidden_field :id
@@ -1,3 +1,3 @@
1
1
  = wizard_card(fee_payment) do
2
- = render('effective/wizard_steps/cpd_statements', resource: fee_payment)
3
2
  = render('effective/wizard_steps/cpd_requirements', resource: fee_payment)
3
+ = render('effective/wizard_steps/cpd_statements', resource: fee_payment)
@@ -4,12 +4,12 @@
4
4
  = card(et('effective_cpd.name')) do
5
5
  = render('cpd_requirements', fee_payment: resource)
6
6
 
7
- = card('All ' + cpd_statements_label) do
8
- = render('effective/wizard_steps/cpd_statements', resource: resource)
9
-
10
7
  = card('Requirements') do
11
8
  = render('effective/wizard_steps/cpd_requirements', resource: resource)
12
9
 
10
+ = card('All ' + cpd_statements_label) do
11
+ = render('effective/wizard_steps/cpd_statements', resource: resource)
12
+
13
13
  = card do
14
14
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
15
15
  = f.hidden_field :id
@@ -17,4 +17,7 @@
17
17
  - f.object.declare_cpd = true if f.object.has_completed_step?(:cpd)
18
18
  = render('effective/wizard_steps/cpd_fields', f: f)
19
19
 
20
+ - if Rails.env.development? || Rails.env.test?
21
+ = f.check_box :skip_cpd_validation, label: "Yes, skip the :cpd step validation (development and test mode only)"
22
+
20
23
  = f.save 'Save and Continue'
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.17.2'
2
+ VERSION = '0.17.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_memberships
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.2
4
+ version: 0.17.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: 2023-05-04 00:00:00.000000000 Z
11
+ date: 2023-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails