effective_memberships 0.16.0 → 0.16.1

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: 2724aef02cc204497fbe0fea92c61ca1b61cfb37ac49711dd80ca3627577d90d
4
- data.tar.gz: 46e0ac6f3754616c32c4d0bbbf581ae653ed90124e958e9d16ae512eff4e2a80
3
+ metadata.gz: f05f20be1f211e1d0a3d17270820752b3015ac6790c635c32973c6c928b2f1b1
4
+ data.tar.gz: b8273500b7e6af71968a2ed83195a5a380f0563ab2750c1b6a0624e87ec5c9e5
5
5
  SHA512:
6
- metadata.gz: 36111838c17b71691f8d16e2b4638d106823cb5b78d879c92b675f6d87a8241f3c5c8f42c92e39ce3fc7b45228875ffeb292aa30803836ec6dd28b8cdc8529f1
7
- data.tar.gz: 773521c071ea206c07191528a681cc79b5c22476d7158b98a7e4cd5e253a852d1307b0864244733be09d3ed9e15d2a31a0484a23e69e4d3f4d5a0cc944544a04
6
+ metadata.gz: c298a6e323ce94af492a00ed1aa8addfd1777a1b2023f7715f66d0231868e813d09f59b13adcb14d80da2519b3bf294b52c4eb68ff08c1c466d07a5b257c1ccd
7
+ data.tar.gz: c7bcfdb569352928092df90df69ec4fcd735354e71a68676721c139eb1f38b5f7bd0b874bdacadebb641309ff7c1cb425c570a31d806d9ffe227082650c5e7cf
@@ -30,7 +30,7 @@ module Admin
30
30
  col :user
31
31
  col :organization, visible: false
32
32
 
33
- col :applicant_type
33
+ col :applicant_type, search: EffectiveMemberships.Applicant.categories
34
34
  col :category, label: 'Applicant Category', search: { collection: EffectiveMemberships.Category.all, polymorphic: false }
35
35
  col :stream
36
36
  col :from_category, search: { collection: EffectiveMemberships.Category.all, polymorphic: false }
@@ -5,6 +5,7 @@ class EffectiveApplicantsDatatable < Effective::Datatable
5
5
 
6
6
  col :id, visible: false
7
7
 
8
+ col :applicant_type, label: 'Type'
8
9
  col :category, label: 'Category'
9
10
  col :status, search: effective_memberships_status_collection()
10
11
 
@@ -24,7 +24,7 @@ module EffectiveMembershipsApplicant
24
24
  # Apply for Reinstatement - Must have a removed membership. Membership history.
25
25
 
26
26
  def categories
27
- ['Apply to Join', 'Apply to Reclassify', 'Apply for Reinstatement']
27
+ ['Apply to Join', 'Apply to Reclassify', 'Apply for Resignation', 'Apply for Reinstatement']
28
28
  end
29
29
 
30
30
  def transcripts_statuses
@@ -54,6 +54,7 @@ module EffectiveMembershipsApplicant
54
54
  demographics: 'Demographics', # Individual only. Users fields.
55
55
  organization: 'Organization', # Organization only. Organization fields.
56
56
  reinstatement: 'Reinstatement', # Apply for Reinstatement only
57
+ resignation: 'Resignation', # Apply for Resignation only
57
58
  education: 'Education',
58
59
  course_amounts: 'Courses',
59
60
  equivalences: 'Equivalent Memberships',
@@ -89,6 +90,9 @@ module EffectiveMembershipsApplicant
89
90
  # Reinstatements Step
90
91
  attr_accessor :declare_reinstatement
91
92
 
93
+ # Resignations Step
94
+ attr_accessor :declare_resignation
95
+
92
96
  # CPD Step
93
97
  attr_accessor :declare_cpd
94
98
 
@@ -375,6 +379,11 @@ module EffectiveMembershipsApplicant
375
379
  validates :declare_reinstatement, acceptance: true
376
380
  end
377
381
 
382
+ # Resignations step
383
+ with_options(if: -> { current_step == :resignation }) do
384
+ validates :declare_resignation, acceptance: true
385
+ end
386
+
378
387
  # Admin Approve
379
388
  validate(if: -> { approved_membership_date.present? }) do
380
389
  if approved_membership_date.to_date > Time.zone.now.to_date
@@ -405,17 +414,25 @@ module EffectiveMembershipsApplicant
405
414
  def default_applicant_required_steps
406
415
  return self.class.test_required_steps if Rails.env.test? && self.class.test_required_steps.present?
407
416
 
408
- # All required
417
+ # All required steps
409
418
  required_steps = self.class.required_wizard_steps
410
419
 
411
- # Based on current applicant
412
- applicant_steps = self.class.all_wizard_steps if category.blank?
413
- applicant_steps ||= (reinstatement? ? category.applicant_reinstatement_wizard_steps : category.applicant_wizard_steps)
420
+ # The applicant steps
421
+ applicant_steps = if category.blank?
422
+ self.class.all_wizard_steps
423
+ elsif reinstatement?
424
+ category.applicant_reinstatement_wizard_steps
425
+ elsif resignation?
426
+ category.applicant_resignation_wizard_steps
427
+ else
428
+ category.applicant_wizard_steps
429
+ end
414
430
 
415
431
  # Sanity check
416
432
  applicant_steps.delete(:stamp) unless apply_to_join?
417
433
  applicant_steps.delete(:organization) unless category&.organization?
418
434
  applicant_steps.delete(:reinstatement) unless reinstatement?
435
+ applicant_steps.delete(:resignation) unless resignation?
419
436
 
420
437
  # change_wizard_steps is defined in effective_resources acts_as_wizard
421
438
  applicant_steps = change_wizard_steps(applicant_steps)
@@ -459,6 +476,8 @@ module EffectiveMembershipsApplicant
459
476
 
460
477
  def applicant_fee_price
461
478
  return category.applicant_reinstatement_fee if reinstatement?
479
+ return category.applicant_resignation_fee if resignation?
480
+
462
481
  applicant_fee_category.applicant_fee
463
482
  end
464
483
 
@@ -541,9 +560,13 @@ module EffectiveMembershipsApplicant
541
560
 
542
561
  # Instance Methods
543
562
  def to_s
544
- return 'New Applicant' if applicant_type.blank? || category.blank? || owner.blank?
545
-
546
- "#{owner} - #{applicant_type} to #{category}"
563
+ if applicant_type.blank? || category.blank? || owner.blank?
564
+ 'New Applicant'
565
+ elsif resignation?
566
+ "#{owner} - #{applicant_type}"
567
+ else
568
+ "#{owner} - #{applicant_type} to #{category}"
569
+ end
547
570
  end
548
571
 
549
572
  def owner
@@ -566,6 +589,10 @@ module EffectiveMembershipsApplicant
566
589
  applicant_type == 'Apply to Reclassify'
567
590
  end
568
591
 
592
+ def resignation?
593
+ applicant_type == 'Apply for Resignation'
594
+ end
595
+
569
596
  def reinstatement?
570
597
  applicant_type == 'Apply for Reinstatement'
571
598
  end
@@ -632,6 +659,8 @@ module EffectiveMembershipsApplicant
632
659
  ['Apply for Reinstatement', 'Apply to Join']
633
660
  elsif owner.membership.blank? || owner.membership.categories.blank?
634
661
  ['Apply to Join']
662
+ elsif all_steps.include?(:resignation)
663
+ ['Apply to Reclassify', 'Apply for Resignation']
635
664
  else
636
665
  ['Apply to Reclassify']
637
666
  end
@@ -706,6 +735,7 @@ module EffectiveMembershipsApplicant
706
735
  end
707
736
 
708
737
  def applicant_references_required?
738
+ return false if resignation? || reinstatement?
709
739
  min_applicant_references > 0
710
740
  end
711
741
 
@@ -715,6 +745,7 @@ module EffectiveMembershipsApplicant
715
745
  end
716
746
 
717
747
  def applicant_endorsements_required?
748
+ return false if resignation? || reinstatement?
718
749
  min_applicant_endorsements > 0
719
750
  end
720
751
 
@@ -729,6 +760,7 @@ module EffectiveMembershipsApplicant
729
760
  end
730
761
 
731
762
  def transcripts_required?
763
+ return false if resignation? || reinstatement?
732
764
  required_steps.include?(:transcripts)
733
765
  end
734
766
 
@@ -886,6 +918,7 @@ module EffectiveMembershipsApplicant
886
918
  end
887
919
 
888
920
  def to_status
921
+ return EffectiveMemberships.Registrar.resigned_status! if resignation?
889
922
  nil
890
923
  end
891
924
 
@@ -919,6 +952,12 @@ module EffectiveMembershipsApplicant
919
952
  date: approved_membership_date.presence, # Set by the Admin Process form, or nil
920
953
  number: approved_membership_number.presence # Set by the Admin Process form, or nil
921
954
  )
955
+ elsif resignation?
956
+ EffectiveMemberships.Registrar.remove!(
957
+ owner,
958
+ statuses: to_status,
959
+ date: approved_membership_date.presence # Set by the Admin Process form, or nil
960
+ )
922
961
  elsif reinstatement?
923
962
  # No status
924
963
  EffectiveMemberships.Registrar.reinstate!(
@@ -224,6 +224,15 @@ module EffectiveMembershipsCategory
224
224
  (Array(self[:applicant_wizard_steps]) - [nil, '']).map(&:to_sym)
225
225
  end
226
226
 
227
+ # Apply for Resignation
228
+ def applicant_resignation_wizard_steps
229
+ [:resignation]
230
+ end
231
+
232
+ def applicant_resignation_fee
233
+ 0
234
+ end
235
+
227
236
  # Apply for Reinstatement
228
237
  def applicant_reinstatement_wizard_steps
229
238
  [:reinstatement]
@@ -51,7 +51,15 @@ module EffectiveMembershipsRegistrar
51
51
  end
52
52
 
53
53
  def not_in_good_standing_status!
54
- EffectiveMemberships.Status.where(title: 'Not In Good Standing').first!
54
+ not_in_good_standing_status.first!
55
+ end
56
+
57
+ def resigned_status
58
+ EffectiveMemberships.Status.where(title: 'Resigned')
59
+ end
60
+
61
+ def resigned_status!
62
+ resigned_status.first!
55
63
  end
56
64
 
57
65
  # These two could be overridden if we do non 1-year periods
@@ -1,38 +1,43 @@
1
1
  = effective_form_with(model: [:admin, applicant], engine: true) do |f|
2
- %p The #{applicant} will be <strong>approved</strong> to the following membership category:
2
+ - owner = f.object.owner
3
3
 
4
- - categories = EffectiveMemberships.Category.all
5
- = f.select :category_id, categories, label: 'Approve to'
4
+ - if f.object.resignation?
5
+ %p The #{applicant} will be <strong>approved</strong>
6
+ %p Their membership will be removed and they will be marked as resigned.
6
7
 
7
- - reinstatement = applicant.owner.reinstatement_membership_history if applicant.reinstatement?
8
+ - elsif f.object.reinstatement?
9
+ - reinstatement = applicant.owner.reinstatement_membership_history
8
10
 
9
- %p
10
- - if applicant.owner.membership&.number_was.present?
11
- The member will keep their existing membership number: #{applicant.owner.membership.number_was}.
12
- - elsif applicant.reinstatement? && reinstatement&.number.present?
13
- The member will keep their previous membership number: #{reinstatement.number}.
14
- - else
15
- - number = EffectiveMemberships.Registrar.next_membership_number(applicant.owner, to: applicant.category)
11
+ %p The #{applicant} will be <strong>approved</strong>
12
+ %p Their membership will be reinstated and they will regain the following category, number and status:
16
13
 
17
- - if number.present?
14
+ %ul
15
+ %li Category: #{reinstatement.membership_categories.to_sentence}
16
+ %li Number: #{reinstatement.number}
17
+ %li Status: #{badges(reinstatement.membership_statuses).presence || 'None'}
18
+
19
+ - else
20
+ %p The #{applicant} will be <strong>approved</strong> to the following membership category:
21
+ = f.select :category_id, EffectiveMemberships.Category.all, label: 'Approve to'
22
+
23
+ %p
24
+ - if owner.membership&.number_was.present?
25
+ They will keep their existing membership number: #{applicant.owner.membership.number_was}.
26
+ - elsif (number = EffectiveMemberships.Registrar.next_membership_number(applicant.owner, to: applicant.category)).present?
18
27
  = f.text_field :approved_membership_number, hint: "leave blank to assign the next number: #{number || 'none'}."
19
28
  - else
20
29
  No membership number will be assigned.
21
30
 
22
- - if applicant.reinstatement? && reinstatement.present?
23
- %p The member will be reinstated with their previous status: #{badges(reinstatement.membership_statuses) || 'None'}.
24
-
25
- = render('admin/applicants/fees_approve', f: f, applicant: applicant)
26
-
27
- %p The following unpurchased fees will be deleted:
28
- - outstanding_fee_payment_fees = applicant.owner.outstanding_fee_payment_fees
31
+ - unless f.object.resignation?
32
+ = render('admin/applicants/fees_approve', f: f, applicant: applicant)
29
33
 
30
- %ul
31
- - outstanding_fee_payment_fees.each do |fee|
32
- %li= fee
34
+ %p The following unpurchased fees will be deleted:
35
+ %ul
36
+ - applicant.owner.outstanding_fee_payment_fees.each do |fee|
37
+ %li= fee
33
38
 
34
- - if outstanding_fee_payment_fees.blank?
35
- %li None
39
+ - if applicant.owner.outstanding_fee_payment_fees.blank?
40
+ %li None
36
41
 
37
42
  %h3 Email to send
38
43
  - email_templates = applicant.approve_email_templates
@@ -3,7 +3,7 @@
3
3
  %tbody
4
4
  %tr
5
5
  %td= icon('check')
6
- %td Yes, I am applying to reinstate from #{applicant.from_status || applicant.from_category}.
6
+ %td Yes, I am applying for reinstatement to #{applicant.from_status || applicant.from_category}
7
7
  %tr
8
8
  %td= icon('check')
9
9
  %td Yes, I have read, understand and agree to the reinstatement declaration
@@ -0,0 +1 @@
1
+ = f.check_box :declare_reinstatement, label: "Yes, I am applying for reinstatement to #{f.object.category}"
@@ -0,0 +1,6 @@
1
+ = wizard_card(applicant) do
2
+ %table.table.table-sm
3
+ %tbody
4
+ %tr
5
+ %td= icon('check')
6
+ %td Yes, I am applying for resignation from #{applicant.category}
@@ -8,8 +8,6 @@
8
8
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
9
9
  = f.hidden_field :id
10
10
 
11
- = render_if_exists("effective/applicants/reinstatement_fields", f: f)
12
-
13
- = f.check_box :declare_reinstatement, label: 'Yes, I accept and agree to the above'
11
+ = render("effective/applicants/reinstatement_fields", f: f)
14
12
 
15
13
  = f.save 'Save and Continue'
@@ -0,0 +1,15 @@
1
+ = render 'layout' do
2
+ = render 'effective/applicants/content', resource: resource
3
+
4
+ - completed = resource.has_completed_step?(:resignation)
5
+ - resource.declare_resignation = completed
6
+
7
+ = card do
8
+ = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
9
+ = f.hidden_field :id
10
+
11
+ = render_if_exists("effective/applicants/resignation_fields", f: f)
12
+
13
+ = f.check_box :declare_resignation, label: "Yes, I am applying for resignation from #{f.object.category}"
14
+
15
+ = f.save 'Save and Continue'
@@ -0,0 +1,4 @@
1
+ - membership = f.object.owner.membership
2
+
3
+ %p Apply for Resignation from #{membership.category}.
4
+ = f.hidden_field :category_id, value: membership.category.id
@@ -25,19 +25,26 @@
25
25
  = render('effective/applicants/select/apply_to_reclassify', f: f)
26
26
  = render('effective/applicants/select/categories', f: f, categories: categories - [existing_category])
27
27
 
28
+ - elsif applicant_types == ['Apply for Resignation']
29
+ = render('effective/applicants/select/apply_for_resignation', f: f)
30
+
28
31
  - else
29
32
  = f.select :applicant_type, applicant_types, label: 'Apply to...'
30
33
 
31
- - if applicant_types.include?('Apply for Reinstatement')
32
- = f.show_if :applicant_type, 'Apply for Reinstatement' do
33
- = f.hidden_field :category_id, value: reinstatement_category.id
34
- = render('effective/applicants/select/apply_for_reinstatement', f: f)
35
-
36
34
  - if applicant_types.include?('Apply to Join')
37
35
  = f.show_if :applicant_type, 'Apply to Join' do
38
36
  = render('effective/applicants/select/apply_to_join', f: f)
39
37
  = render('effective/applicants/select/categories', f: f, categories: categories)
40
38
 
39
+ - if applicant_types.include?('Apply for Resignation')
40
+ = f.show_if :applicant_type, 'Apply for Resignation' do
41
+ = render('effective/applicants/select/apply_for_resignation', f: f)
42
+
43
+ - if applicant_types.include?('Apply for Reinstatement')
44
+ = f.show_if :applicant_type, 'Apply for Reinstatement' do
45
+ = f.hidden_field :category_id, value: reinstatement_category.id
46
+ = render('effective/applicants/select/apply_for_reinstatement', f: f)
47
+
41
48
  - if applicant_types.include?('Apply to Reclassify')
42
49
  = f.show_if :applicant_type, 'Apply to Reclassify' do
43
50
  = render('effective/applicants/select/apply_to_reclassify', f: f)
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.16.0'
2
+ VERSION = '0.16.1'
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.16.0
4
+ version: 0.16.1
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-04-21 00:00:00.000000000 Z
11
+ date: 2023-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -456,6 +456,8 @@ files:
456
456
  - app/views/effective/applicants/_references.html.haml
457
457
  - app/views/effective/applicants/_references_requirements.html.haml
458
458
  - app/views/effective/applicants/_reinstatement.html.haml
459
+ - app/views/effective/applicants/_reinstatement_fields.html.haml
460
+ - app/views/effective/applicants/_resignation.html.haml
459
461
  - app/views/effective/applicants/_select.html.haml
460
462
  - app/views/effective/applicants/_select_organization.html.haml
461
463
  - app/views/effective/applicants/_stamp.html.haml
@@ -476,8 +478,10 @@ files:
476
478
  - app/views/effective/applicants/organization.html.haml
477
479
  - app/views/effective/applicants/references.html.haml
478
480
  - app/views/effective/applicants/reinstatement.html.haml
481
+ - app/views/effective/applicants/resignation.html.haml
479
482
  - app/views/effective/applicants/select.html.haml
480
483
  - app/views/effective/applicants/select/_apply_for_reinstatement.html.haml
484
+ - app/views/effective/applicants/select/_apply_for_resignation.html.haml
481
485
  - app/views/effective/applicants/select/_apply_to_join.html.haml
482
486
  - app/views/effective/applicants/select/_apply_to_reclassify.html.haml
483
487
  - app/views/effective/applicants/select/_categories.html.haml