effective_memberships 0.17.6 → 0.17.8

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: d142c13f7d68942b383fff9bc314047b153de3be9cb0c04bb8af51eff8318d40
4
- data.tar.gz: 51a2c27f121dce157be9c241a49f74c1b40956fd24e2b1b4dec63e640c31fd61
3
+ metadata.gz: 02b881930550198b6c2e18381683543910d16534b7766768661eb4f91cf96214
4
+ data.tar.gz: e30e3b80c39e484178561cd7aba32e4157c735d831afb80ca16758ca748c9479
5
5
  SHA512:
6
- metadata.gz: f024d0dd50619988dd4c01a118b99187b17472db7dc822b1e05ddb0967381824c0096be348ec2d50861e2ac7ef214f74f5c6c956148420ad29c56a819f3e9a3e
7
- data.tar.gz: 27373898ff7749494413ac78ba8946870d4b5b428df8ca4f3699ead53c00f6678d8c1ff7551d7e26dc91d6c1f915e5254fff3c3932cabb29a5c5ff51c426b3b2
6
+ metadata.gz: 95040d97dfc5aadc8816a2fb6cc2111336306df360a05622386a9db87848a12921449970c9f8f63b5a4ffdd5e54b6a5cced0b7c4cef59e188c850f6ded76dc59
7
+ data.tar.gz: 15fc30fe1419f2c9443e19d07620b63180195995472b5fb86040ac4d1e46eadc906ff07b70fb3356b1c42ace9870e523c3afaf0cbd62b41724208e22e1b1c3c4
@@ -64,7 +64,13 @@ module Admin
64
64
  membership.owner.try(:addresses).try(:first).try(:postal_code)
65
65
  end
66
66
 
67
- actions_col
67
+ actions_col do |membership|
68
+ if membership.owner_type.include?('Organization')
69
+ dropdown_link_to 'Show', "/admin/organizations/#{membership.owner.to_param}/edit#tab-membership", 'data-turbolinks': false
70
+ elsif membership.owner_type.include?('User')
71
+ dropdown_link_to 'Show', "/admin/users/#{membership.owner.to_param}/edit#tab-membership", 'data-turbolinks': false
72
+ end
73
+ end
68
74
  end
69
75
 
70
76
  collection do
@@ -251,6 +251,23 @@ module EffectiveMembershipsApplicant
251
251
  validates :category, presence: true
252
252
  end
253
253
 
254
+ # Select Step - Check for expired reclassification or reinstatement dates
255
+ validate(if: -> { current_step == :select && owner.present? && applicant_type.present? && category.present? }) do
256
+ # Dates
257
+ today = (created_at || Time.zone.now).beginning_of_day
258
+
259
+ reclassification_expires_on = owner.reclassification_expires_on(from: from_category, to: category)
260
+ reinstatement_expires_on = owner.reinstatement_expires_on(from: from_status)
261
+
262
+ if reclassification? && reclassification_expires_on.present? && reclassification_expires_on <= today
263
+ errors.add(:base, "Your ability to apply for reclassification expired on #{reclassification_expires_on.strftime('%F')}. Please contact us for assistance.")
264
+ end
265
+
266
+ if reinstatement? && reinstatement_expires_on.present? && reinstatement_expires_on <= today
267
+ errors.add(:base, "Your ability to apply for reinstatement expired on #{reinstatement_expires_on.strftime('%F')}. Please contact us for assistance.")
268
+ end
269
+ end
270
+
254
271
  # They can checkout with outstanding fees
255
272
  # validate(if: -> { current_step == :select && owner.present? }) do
256
273
  # self.errors.add(:base, 'may not have outstanding fees') if owner.outstanding_fee_payment_fees.present?
@@ -313,4 +313,8 @@ module EffectiveMembershipsCategory
313
313
  nil
314
314
  end
315
315
 
316
+ def reclassification_expires_in
317
+ nil # 2.years
318
+ end
319
+
316
320
  end
@@ -137,6 +137,44 @@ module EffectiveMembershipsOwner
137
137
  removed_membership_history.start_on if membership_removed?
138
138
  end
139
139
 
140
+ # Checked by the applicant on the select step
141
+ def reclassification_expires_on(from: nil, to: nil)
142
+ return unless membership.present?
143
+
144
+ # User/owner might respond to this
145
+ date = try(:admin_reclassification_expires_on)
146
+ return date if date.present?
147
+
148
+ # When we last reclassified to our current category
149
+ history = last_membership_history(category: membership.membership_categories.first)
150
+ reclassified_on = (history&.start_on || membership.registration_on || membership.joined_on)
151
+
152
+ # Otherwise consider the membership categories
153
+ expires_on = membership.categories.select { |category| category.reclassification_expires_in.present? }.map do |category|
154
+ reclassified_on + category.reclassification_expires_in
155
+ end.min
156
+
157
+ expires_on
158
+ end
159
+
160
+ def reinstatement_expires_on(from: nil)
161
+ return unless membership_removed?
162
+
163
+ # User/owner might respond to this
164
+ date = try(:admin_reinstatement_expires_on)
165
+ return date if date.present?
166
+
167
+ # When we were removed
168
+ removed_on = removed_membership_history.start_on
169
+
170
+ # Consider any membership statuses that have reinstatement expires in
171
+ expires_on = removed_membership_history.membership_statuses.select { |status| status.reinstatement_expires_in.present? }.map do |status|
172
+ removed_on + status.reinstatement_expires_in
173
+ end.min
174
+
175
+ expires_on
176
+ end
177
+
140
178
  # The membership history that is removed. Has exit statuses that may affect reinstatement fees.
141
179
  def removed_membership_history
142
180
  membership_histories.reverse.find { |history| history.removed? } if membership_removed?
@@ -444,6 +482,14 @@ module EffectiveMembershipsOwner
444
482
  membership_histories.find { |history| (history.start_on..history.end_on).cover?(date) } # Ruby 2.6 supports endless ranges
445
483
  end
446
484
 
485
+ def first_membership_history(category: nil)
486
+ membership_histories.find { |history| category.blank? || history.membership_category_ids.include?(category.id) }
487
+ end
488
+
489
+ def last_membership_history(category: nil)
490
+ membership_histories.reverse.find { |history| category.blank? || history.membership_category_ids.include?(category.id) }
491
+ end
492
+
447
493
  # Point out busted data
448
494
  def membership_history_errors
449
495
  return unless membership.present?
@@ -76,9 +76,8 @@ module EffectiveMembershipsStatus
76
76
  title == 'Not In Good Standing'
77
77
  end
78
78
 
79
- # Used for Apply to Join Reinstatement
80
- def reinstatable?
81
- true
79
+ def reinstatement_expires_in
80
+ nil # 2.years
82
81
  end
83
82
 
84
83
  end
@@ -18,6 +18,9 @@ module Effective
18
18
  timestamps
19
19
  end
20
20
 
21
+ # TODO: Rename categories to be category_toses
22
+ # And membreship_categories below should be called categories
23
+
21
24
  serialize :categories, Array
22
25
  serialize :category_ids, Array
23
26
 
@@ -9,6 +9,8 @@
9
9
 
10
10
  = f.static_field :current_action, label: 'Current Membership' do
11
11
  = membership.to_s
12
+ = render('effective/memberships/reclassification', user: membership.owner)
13
+ = render('effective/memberships/reinstatement', user: membership.owner)
12
14
 
13
15
  = f.check_box :current_action, label: 'Yes, update membership information'
14
16
 
@@ -0,0 +1,15 @@
1
+ %h2= et(EffectiveMemberships.MembershipCard)
2
+
3
+ - membership = current_user.membership
4
+ - card = EffectiveMemberships.MembershipCard.new(membership: membership)
5
+
6
+ - if membership.present? && EffectiveResources.authorized?(self, :show, card)
7
+ %p
8
+ Your membership card for
9
+ = membership.owner.to_s
10
+ = membership.categories.to_sentence
11
+ is available for download
12
+
13
+ %p= link_to "Download #{et(EffectiveMemberships.MembershipCard)}", effective_memberships.membership_card_membership_path(membership, format: :pdf), class: 'btn btn-primary'
14
+ - else
15
+ %p You don't have a membership card. When you do, we'll show it here.
@@ -33,11 +33,14 @@
33
33
  - if membership.not_in_good_standing?
34
34
  %p Your membership is Not In Good Standing because of unpurchased fees or dues. Please purchase these dues or contact us.
35
35
 
36
+ - if membership.present?
37
+ = render('effective/memberships/reclassification', user: current_user)
38
+
36
39
  - if current_user.membership_removed?
37
40
  %p Your membership was removed on #{current_user.membership_removed_on.strftime('%F')}.
38
41
 
39
42
  - if current_user.reinstatement_membership_history.present?
40
- %p You may Apply for Reinstatement to #{current_user.reinstatement_membership_category} by clicking the Apply to Join button below and then complete the wizard.
43
+ = render('effective/memberships/reinstatement', user: current_user)
41
44
 
42
45
  - if membership_organizations.present?
43
46
  %p You are a representative for #{pluralize(membership_organizations.length, 'member organization')}.
@@ -0,0 +1,14 @@
1
+ - if user.membership.present?
2
+ - now = Time.zone.now.beginning_of_day
3
+ - applicants = user.applicants.select { |applicant| applicant.in_progress? }
4
+
5
+ - if applicants.blank?
6
+ - expires_on = user.reclassification_expires_on
7
+ - category = user.membership.categories.to_sentence
8
+
9
+ - if expires_on.blank?
10
+ - # Nothing to do
11
+ - elsif now < expires_on
12
+ %p You have until #{expires_on.strftime('%F')}, #{distance_of_time_in_words(now, expires_on)} from now, to Apply for Reclassification from #{category}.
13
+ - else
14
+ %p Your ability to Apply for Reclassification from #{category} expired on #{expires_on.strftime('%F')}.
@@ -0,0 +1,14 @@
1
+ - if user.reinstatement_membership_history.present?
2
+ - now = Time.zone.now.beginning_of_day
3
+ - applicants = user.applicants.select { |applicant| applicant.in_progress? }
4
+
5
+ - if applicants.blank?
6
+ - category = user.reinstatement_membership_category
7
+ - expires_on = user.reinstatement_expires_on
8
+
9
+ - if expires_on.blank?
10
+ - # Nothing to do
11
+ - elsif now < expires_on
12
+ %p You have until #{expires_on.strftime('%F')}, #{distance_of_time_in_words(now, expires_on)} from now, to Apply for Reinstatement to #{category}.
13
+ - else
14
+ %p Your ability to Apply for Reinstatement to #{category} expired on #{expires_on.strftime('%F')}.
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.17.6'
2
+ VERSION = '0.17.8'
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.6
4
+ version: 0.17.8
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-11 00:00:00.000000000 Z
11
+ date: 2023-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -515,6 +515,7 @@ files:
515
515
  - app/views/effective/fee_payments/summary.html.haml
516
516
  - app/views/effective/fees/_dashboard.html.haml
517
517
  - app/views/effective/fees/_fee.html.haml
518
+ - app/views/effective/membership_cards/_dashboard.html.haml
518
519
  - app/views/effective/membership_cards/index.html.haml
519
520
  - app/views/effective/membership_directory/_form.html.haml
520
521
  - app/views/effective/membership_directory/_layout.html.haml
@@ -524,6 +525,8 @@ files:
524
525
  - app/views/effective/membership_directory/show.html.haml
525
526
  - app/views/effective/memberships/_dashboard.html.haml
526
527
  - app/views/effective/memberships/_membership.html.haml
528
+ - app/views/effective/memberships/_reclassification.html.haml
529
+ - app/views/effective/memberships/_reinstatement.html.haml
527
530
  - app/views/effective/memberships_mailer/applicant_approved.liquid
528
531
  - app/views/effective/memberships_mailer/applicant_completed.liquid
529
532
  - app/views/effective/memberships_mailer/applicant_declined.liquid