effective_memberships 0.17.2 → 0.17.3

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: 172faa35356355bd3a8d6f2bd51a4d1ec26cac9b58c617713b972096c32ec42d
4
+ data.tar.gz: fa370c75fcf09fd03134451dc3ffeefb3bd3b0b9032392fb4e9a17c364f810a0
5
5
  SHA512:
6
- metadata.gz: b8eff0a5c66e4b2e0d59024c4e686cbf2a0ca264df522064c5074c89b8fd911d4c14be2732e0ea677a1e9998a36a2d9674acf70ccb1393ca74f7a1a1e6ce3c8a
7
- data.tar.gz: c4190c54eff0c58c6b1234f5f739d1b131c0dcc90cba603f1708a55a0dac9c224eec0ca0be8964b3bdae09cddcab32322adeeb4789792487b737fdb17b41caad
6
+ metadata.gz: 1853d32c2a951cc21b34ee224007bed5ca1af849027f3ac398cd99a77c9397e4cc8cce59ba7e26c23ffd4cb006676933a7a208a95b2c55a9f3b48ff0b6218db8
7
+ data.tar.gz: a5a8f725ca25361aa8424108fc59c4aff507367a895c0f99f94ecdbce30117a6d77049facf8ba255fdacef68a555c5c87172f8c72ca1bc1304f4183fe66362f2
@@ -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
@@ -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.3'
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.3
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-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -574,7 +574,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
574
574
  - !ruby/object:Gem::Version
575
575
  version: '0'
576
576
  requirements: []
577
- rubygems_version: 3.1.2
577
+ rubygems_version: 3.0.8
578
578
  signing_key:
579
579
  specification_version: 4
580
580
  summary: Manage your professional association online. Membership categories, applications