effective_memberships 0.1.3 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/admin/fee_payments_controller.rb +19 -0
- data/app/controllers/effective/applicant_references_controller.rb +2 -1
- data/app/controllers/effective/applicants_controller.rb +1 -1
- data/app/controllers/effective/fee_payments_controller.rb +6 -3
- data/app/datatables/admin/effective_fee_payments_datatable.rb +51 -0
- data/app/datatables/effective_applicants_datatable.rb +1 -1
- data/app/datatables/effective_fee_payments_datatable.rb +24 -0
- data/app/models/concerns/effective_memberships_applicant.rb +6 -1
- data/app/models/concerns/effective_memberships_fee_payment.rb +48 -3
- data/app/models/concerns/effective_memberships_owner.rb +22 -6
- data/app/views/admin/fee_payments/_fee_payment.html.haml +1 -0
- data/app/views/effective/fee_payments/_dashboard.html.haml +8 -0
- data/app/views/effective/fee_payments/_fee_payment.html.haml +1 -1
- data/app/views/effective/fee_payments/start.html.haml +19 -5
- data/config/routes.rb +1 -0
- data/db/migrate/01_create_effective_memberships.rb.erb +3 -0
- data/lib/effective_memberships/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b47c4f81099d5e4078814e9f04765ae8b2790ac3fe19ff0a0f5442e9e5f6475
|
4
|
+
data.tar.gz: 727b05c16923003822a9383d3cd3b8f582655cae1e769df98de0245bdd0dedd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc8454e6c624109974f4f6bbcb65a92a892a9a19ed72565fdc53414017d03a30de766b1609fff6b4dca89a3f93c8800502ba4841032860bf3733fedc9b01da56
|
7
|
+
data.tar.gz: 0db5f5f98ea6271c36fd09c2cd32a3f757ef55ca7cda4f2be130e12f0162aaa6474993062247ef02cdca3dfb1da4df1cc54dc5a3e32f91cf49c412a351de30db
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Admin
|
2
|
+
class FeePaymentsController < ApplicationController
|
3
|
+
before_action(:authenticate_user!) if defined?(Devise)
|
4
|
+
before_action { EffectiveResources.authorize!(self, :admin, :effective_memberships) }
|
5
|
+
|
6
|
+
include Effective::CrudController
|
7
|
+
|
8
|
+
resource_scope -> { EffectiveMemberships.FeePayment.deep.all }
|
9
|
+
datatable -> { Admin::EffectiveFeePaymentsDatatable.new }
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def permitted_params
|
14
|
+
model = (params.key?(:effective_applicant) ? :effective_fee_payment : :fee_payment)
|
15
|
+
params.require(model).permit!
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -24,8 +24,9 @@ module Effective
|
|
24
24
|
|
25
25
|
def permitted_params
|
26
26
|
permitted = params.require(:effective_applicant_reference).permit!.except(:token, :last_notified_at, :status, :status_steps)
|
27
|
+
authorized = current_user.effective_memberships_owners.include?(resource.applicant.owner) == false
|
27
28
|
|
28
|
-
if resource.submitted? && resource.applicant.was_submitted? &&
|
29
|
+
if resource.submitted? && resource.applicant.was_submitted? && authorized
|
29
30
|
permitted
|
30
31
|
else
|
31
32
|
permitted.except(:reservations, :reservations_reason, :work_history, :accept_declaration)
|
@@ -4,7 +4,7 @@ module Effective
|
|
4
4
|
|
5
5
|
include Effective::WizardController
|
6
6
|
|
7
|
-
resource_scope -> { EffectiveMemberships.Applicant.deep.where(owner: current_user.
|
7
|
+
resource_scope -> { EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owners) }
|
8
8
|
|
9
9
|
# Allow only 1 in-progress application at a time
|
10
10
|
before_action(only: [:new, :show], unless: -> { resource&.done? }) do
|
@@ -4,7 +4,7 @@ module Effective
|
|
4
4
|
|
5
5
|
include Effective::WizardController
|
6
6
|
|
7
|
-
resource_scope -> { EffectiveMemberships.FeePayment.deep.where(owner: current_user.
|
7
|
+
resource_scope -> { EffectiveMemberships.FeePayment.deep.where(owner: current_user.effective_memberships_owners) }
|
8
8
|
|
9
9
|
# Allow only 1 in-progress fee payment at a time
|
10
10
|
before_action(only: [:new, :show], unless: -> { resource&.done? }) do
|
@@ -16,12 +16,15 @@ module Effective
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
after_save do
|
20
|
+
flash.now[:success] = ''
|
21
|
+
end
|
22
|
+
|
19
23
|
private
|
20
24
|
|
21
25
|
def permitted_params
|
22
26
|
params.require(:fee_payment).permit!.except(
|
23
|
-
:
|
24
|
-
:submitted_at
|
27
|
+
:status, :status_steps, :wizard_steps, :submitted_at
|
25
28
|
)
|
26
29
|
end
|
27
30
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Admin
|
2
|
+
class EffectiveFeePaymentsDatatable < Effective::Datatable
|
3
|
+
filters do
|
4
|
+
scope :all
|
5
|
+
scope :in_progress, label: 'Open / Active'
|
6
|
+
scope :done, label: 'Done'
|
7
|
+
end
|
8
|
+
|
9
|
+
datatable do
|
10
|
+
order :id
|
11
|
+
col :id, visible: false
|
12
|
+
|
13
|
+
col :status
|
14
|
+
|
15
|
+
col :created_at, label: 'Created', as: :date, visible: false
|
16
|
+
col :updated_at, label: 'Updated', visible: false
|
17
|
+
|
18
|
+
col :period, visible: false
|
19
|
+
col :submitted_at, label: 'Submitted', visible: false, as: :date
|
20
|
+
|
21
|
+
col :owner
|
22
|
+
|
23
|
+
col :category, search: { collection: EffectiveMemberships.Category.all, polymorphic: false }
|
24
|
+
|
25
|
+
col :orders, visible: false
|
26
|
+
|
27
|
+
actions_col
|
28
|
+
end
|
29
|
+
|
30
|
+
collection do
|
31
|
+
fee_payments = EffectiveMemberships.FeePayment.deep.all
|
32
|
+
|
33
|
+
raise('expected an owner_id, not user_id') if attributes[:user_id].present?
|
34
|
+
|
35
|
+
if fee_payments == :in_progress && attributes[:owner_id].blank?
|
36
|
+
fee_payments = fee_payments.where.not(status: :draft)
|
37
|
+
end
|
38
|
+
|
39
|
+
if attributes[:owner_id].present?
|
40
|
+
fee_payments = fee_payments.where(owner_id: attributes[:owner_id])
|
41
|
+
end
|
42
|
+
|
43
|
+
if attributes[:except_id].present?
|
44
|
+
fee_payments = fee_payments.where.not(id: attributes[:except_id])
|
45
|
+
end
|
46
|
+
|
47
|
+
fee_payments
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -28,7 +28,7 @@ class EffectiveApplicantsDatatable < Effective::Datatable
|
|
28
28
|
end
|
29
29
|
|
30
30
|
collection do
|
31
|
-
EffectiveMemberships.Applicant.deep.where(owner: current_user.
|
31
|
+
EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owners)
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Dashboard Fee Payments
|
2
|
+
class EffectiveFeePaymentsDatatable < Effective::Datatable
|
3
|
+
datatable do
|
4
|
+
order :created_at
|
5
|
+
|
6
|
+
col :token, visible: false
|
7
|
+
col :created_at, visible: false
|
8
|
+
|
9
|
+
col :owner
|
10
|
+
col :status, visible: false
|
11
|
+
col :submitted_at, label: 'Submitted', as: :date
|
12
|
+
col :period, visible: false
|
13
|
+
|
14
|
+
col :orders, action: :show
|
15
|
+
|
16
|
+
actions_col(new: false)
|
17
|
+
end
|
18
|
+
|
19
|
+
collection do
|
20
|
+
EffectiveMemberships.FeePayment.deep.done
|
21
|
+
.where(owner: current_user.effective_memberships_owners)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -453,12 +453,17 @@ module EffectiveMembershipsApplicant
|
|
453
453
|
|
454
454
|
def find_or_build_submit_order
|
455
455
|
order = submit_order || orders.build(user: owner)
|
456
|
+
fees = submit_fees()
|
456
457
|
|
457
458
|
# Adds fees, but does not overwrite any existing price.
|
458
|
-
|
459
|
+
fees.each do |fee|
|
459
460
|
order.add(fee) unless order.purchasables.include?(fee)
|
460
461
|
end
|
461
462
|
|
463
|
+
order.purchasables.each do |purchasable|
|
464
|
+
order.remove(purchasable) unless fees.include?(purchasable)
|
465
|
+
end
|
466
|
+
|
462
467
|
# From Billing Step
|
463
468
|
order.billing_address = owner.billing_address if owner.billing_address.present?
|
464
469
|
|
@@ -50,10 +50,16 @@ module EffectiveMembershipsFeePayment
|
|
50
50
|
attr_accessor :declare_code_of_ethics
|
51
51
|
attr_accessor :declare_truth
|
52
52
|
|
53
|
+
# Throwaway
|
54
|
+
attr_accessor :upgrade, :downgrade
|
55
|
+
|
53
56
|
# Application Namespace
|
54
57
|
belongs_to :owner, polymorphic: true
|
55
58
|
accepts_nested_attributes_for :owner
|
56
59
|
|
60
|
+
belongs_to :user, polymorphic: true, optional: true
|
61
|
+
accepts_nested_attributes_for :user
|
62
|
+
|
57
63
|
# Like maybe optionally it makes sense.
|
58
64
|
belongs_to :category, polymorphic: true, optional: true
|
59
65
|
|
@@ -153,6 +159,41 @@ module EffectiveMembershipsFeePayment
|
|
153
159
|
owner&.outstanding_fee_payment_fees
|
154
160
|
end
|
155
161
|
|
162
|
+
def select!
|
163
|
+
reset!
|
164
|
+
end
|
165
|
+
|
166
|
+
def reset!
|
167
|
+
assign_attributes(wizard_steps: wizard_steps.slice(:start))
|
168
|
+
save!
|
169
|
+
end
|
170
|
+
|
171
|
+
# Work with effective_organizations
|
172
|
+
def organization!
|
173
|
+
if upgrade_individual_to_organization?
|
174
|
+
save!
|
175
|
+
update!(owner: owner.representatives.first.organization)
|
176
|
+
elsif downgrade_organization_to_individual?
|
177
|
+
save!
|
178
|
+
update!(owner: current_user)
|
179
|
+
else
|
180
|
+
save!
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def upgrade_individual_to_organization?
|
185
|
+
return false unless EffectiveResources.truthy?(upgrade)
|
186
|
+
return false unless owner.class.respond_to?(:effective_organizations_user?)
|
187
|
+
owner.representatives.any?(&:new_record?)
|
188
|
+
end
|
189
|
+
|
190
|
+
def downgrade_organization_to_individual?
|
191
|
+
return false unless EffectiveResources.truthy?(downgrade)
|
192
|
+
return false unless owner.class.respond_to?(:effective_organizations_organization?)
|
193
|
+
return false if current_user.blank?
|
194
|
+
owner.representatives.any?(&:marked_for_destruction?)
|
195
|
+
end
|
196
|
+
|
156
197
|
# All Fees and Orders
|
157
198
|
def submit_fees
|
158
199
|
fees
|
@@ -164,17 +205,22 @@ module EffectiveMembershipsFeePayment
|
|
164
205
|
|
165
206
|
# We take over the owner's outstanding fees.
|
166
207
|
def find_or_build_submit_fees
|
167
|
-
Array(outstanding_fees).each { |fee| fees << fee }
|
208
|
+
Array(outstanding_fees).each { |fee| fees << fee unless fees.include?(fee) }
|
168
209
|
submit_fees
|
169
210
|
end
|
170
211
|
|
171
212
|
def find_or_build_submit_order
|
172
213
|
order = submit_order || orders.build(user: owner)
|
214
|
+
fees = submit_fees()
|
173
215
|
|
174
|
-
|
216
|
+
fees.each do |fee|
|
175
217
|
order.add(fee) unless order.purchasables.include?(fee)
|
176
218
|
end
|
177
219
|
|
220
|
+
order.purchasables.each do |purchasable|
|
221
|
+
order.remove(purchasable) unless fees.include?(purchasable)
|
222
|
+
end
|
223
|
+
|
178
224
|
order.billing_address = owner.billing_address if owner.billing_address.present?
|
179
225
|
|
180
226
|
order
|
@@ -203,7 +249,6 @@ module EffectiveMembershipsFeePayment
|
|
203
249
|
save!
|
204
250
|
end
|
205
251
|
|
206
|
-
|
207
252
|
# Called automatically via after_purchase hook above
|
208
253
|
def submit_purchased!
|
209
254
|
return false if was_submitted?
|
@@ -22,17 +22,15 @@ module EffectiveMembershipsOwner
|
|
22
22
|
|
23
23
|
included do
|
24
24
|
# App scoped
|
25
|
-
has_many :applicants, as: :owner
|
26
|
-
has_many :fee_payments, as: :owner
|
25
|
+
has_many :applicants, -> { order(:id) }, inverse_of: :owner, as: :owner
|
26
|
+
has_many :fee_payments, -> { order(:id) }, inverse_of: :owner, as: :owner
|
27
27
|
|
28
28
|
# Effective scoped
|
29
29
|
has_many :fees, -> { order(:id) }, inverse_of: :owner, as: :owner, class_name: 'Effective::Fee', dependent: :nullify
|
30
30
|
accepts_nested_attributes_for :fees, reject_if: :all_blank, allow_destroy: true
|
31
31
|
|
32
32
|
has_many :orders, -> { order(:id) }, inverse_of: :user, as: :user, class_name: 'Effective::Order', dependent: :nullify
|
33
|
-
|
34
|
-
|
35
|
-
#accepts_nested_attributes_for :orders, reject_if: :all_blank, allow_destroy: true
|
33
|
+
accepts_nested_attributes_for :orders, reject_if: :all_blank, allow_destroy: true
|
36
34
|
|
37
35
|
has_one :membership, inverse_of: :owner, as: :owner, class_name: 'Effective::Membership'
|
38
36
|
accepts_nested_attributes_for :membership
|
@@ -48,7 +46,23 @@ module EffectiveMembershipsOwner
|
|
48
46
|
end
|
49
47
|
|
50
48
|
def effective_memberships_owner
|
51
|
-
|
49
|
+
raise('expected singular usage but there are more than one owner') if effective_memberships_owners.length > 1
|
50
|
+
effective_memberships_owners.first
|
51
|
+
end
|
52
|
+
|
53
|
+
def effective_memberships_owners
|
54
|
+
owners = users if respond_to?(:users) && users.any? { |user| user.class.respond_to?(:effective_memberships_owner?) }
|
55
|
+
owners = organizations if respond_to?(:organizations) && organizations.any? { |organization| organization.class.respond_to?(:effective_memberships_owner?) }
|
56
|
+
|
57
|
+
owners || [self]
|
58
|
+
end
|
59
|
+
|
60
|
+
def outstanding_fee_payment_owners
|
61
|
+
effective_memberships_owners.select { |owner| !owner.membership_fees_paid? }
|
62
|
+
end
|
63
|
+
|
64
|
+
def current_fee_payment_owner
|
65
|
+
outstanding_fee_payment_owners.first || self
|
52
66
|
end
|
53
67
|
|
54
68
|
def owner_label
|
@@ -163,6 +177,8 @@ module EffectiveMembershipsOwner
|
|
163
177
|
late_on: nil,
|
164
178
|
bad_standing_on: nil
|
165
179
|
)
|
180
|
+
|
181
|
+
fee
|
166
182
|
end
|
167
183
|
|
168
184
|
def build_renewal_fee(category:, period:, late_on:, bad_standing_on:)
|
@@ -0,0 +1 @@
|
|
1
|
+
= render 'effective/fee_payments/fee_payment', fee_payment: fee_payment
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- datatable = EffectiveResources.best('EffectiveFeePaymentsDatatable').new(self, namespace: :effective)
|
2
|
+
|
3
|
+
%h2 Fee Payments
|
4
|
+
|
5
|
+
- if datatable.present?
|
6
|
+
= render_simple_datatable(datatable)
|
7
|
+
- else
|
8
|
+
%p You have no past fee payments. When you do, we'll show them here.
|
@@ -3,4 +3,4 @@
|
|
3
3
|
- steps = fee_payment.required_steps - blacklist
|
4
4
|
|
5
5
|
- steps.select { |step| fee_payment.has_completed_step?(step) }.each do |partial|
|
6
|
-
= render "effective/fee_payments/#{partial}", fee_payment: fee_payment, step: partial
|
6
|
+
= render "effective/fee_payments/#{partial}", fee_payment: fee_payment, resource: fee_payment, step: partial
|
@@ -2,19 +2,33 @@
|
|
2
2
|
|
3
3
|
.card
|
4
4
|
.card-body
|
5
|
-
|
5
|
+
- current_owner = current_user.current_fee_payment_owner
|
6
|
+
|
7
|
+
%p Welcome #{current_owner}!
|
6
8
|
|
7
9
|
= render 'effective/fee_payments/content', resource: resource
|
8
10
|
|
9
|
-
- if
|
11
|
+
- if current_owner.membership_fees_paid?
|
10
12
|
%p You have no fees due at this time.
|
11
13
|
= link_to 'Home', root_path, class: 'btn btn-primary'
|
12
14
|
|
13
|
-
-
|
14
|
-
|
15
|
+
- else
|
16
|
+
- if resource.outstanding_fees.present?
|
17
|
+
%p You have the following fees due at this time:
|
18
|
+
= render_purchasables(resource.outstanding_fees)
|
19
|
+
- else
|
20
|
+
%p You have fees due. Please continue.
|
15
21
|
|
16
|
-
|
22
|
+
- resource.user = current_user
|
23
|
+
- resource.owner = current_owner
|
17
24
|
|
18
25
|
= effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
|
19
26
|
= f.hidden_field :id
|
27
|
+
|
28
|
+
= f.hidden_field :owner_type
|
29
|
+
= f.hidden_field :owner_id
|
30
|
+
|
31
|
+
= f.hidden_field :user_type
|
32
|
+
= f.hidden_field :user_id
|
33
|
+
|
20
34
|
= f.save 'Save and Continue'
|
data/config/routes.rb
CHANGED
@@ -26,6 +26,7 @@ EffectiveMemberships::Engine.routes.draw do
|
|
26
26
|
resources :applicant_course_areas, except: [:show]
|
27
27
|
resources :applicant_course_names, except: [:show]
|
28
28
|
|
29
|
+
resources :fee_payments, only: [:index, :show]
|
29
30
|
resources :registrar_actions, only: [:create]
|
30
31
|
end
|
31
32
|
|
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.1.
|
4
|
+
version: 0.1.7
|
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: 2021-12-
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- app/controllers/admin/applicant_course_names_controller.rb
|
215
215
|
- app/controllers/admin/applicants_controller.rb
|
216
216
|
- app/controllers/admin/categories_controller.rb
|
217
|
+
- app/controllers/admin/fee_payments_controller.rb
|
217
218
|
- app/controllers/admin/fees_controller.rb
|
218
219
|
- app/controllers/admin/registrar_actions_controller.rb
|
219
220
|
- app/controllers/effective/applicant_references_controller.rb
|
@@ -223,6 +224,7 @@ files:
|
|
223
224
|
- app/datatables/admin/effective_applicant_course_names_datatable.rb
|
224
225
|
- app/datatables/admin/effective_applicants_datatable.rb
|
225
226
|
- app/datatables/admin/effective_categories_datatable.rb
|
227
|
+
- app/datatables/admin/effective_fee_payments_datatable.rb
|
226
228
|
- app/datatables/admin/effective_fees_datatable.rb
|
227
229
|
- app/datatables/admin/effective_membership_histories_datatable.rb
|
228
230
|
- app/datatables/effective_applicant_courses_datatable.rb
|
@@ -230,6 +232,7 @@ files:
|
|
230
232
|
- app/datatables/effective_applicant_experiences_datatable.rb
|
231
233
|
- app/datatables/effective_applicant_references_datatable.rb
|
232
234
|
- app/datatables/effective_applicants_datatable.rb
|
235
|
+
- app/datatables/effective_fee_payments_datatable.rb
|
233
236
|
- app/helpers/effective_memberships_helper.rb
|
234
237
|
- app/mailers/effective/memberships_mailer.rb
|
235
238
|
- app/models/concerns/effective_memberships_applicant.rb
|
@@ -274,6 +277,7 @@ files:
|
|
274
277
|
- app/views/admin/categories/_form_fee_payment_content.html.haml
|
275
278
|
- app/views/admin/categories/_form_fee_payment_steps.html.haml
|
276
279
|
- app/views/admin/categories/_form_renewals.html.haml
|
280
|
+
- app/views/admin/fee_payments/_fee_payment.html.haml
|
277
281
|
- app/views/admin/fees/_fee.html.haml
|
278
282
|
- app/views/admin/fees/_form.html.haml
|
279
283
|
- app/views/admin/memberships/_status.html.haml
|
@@ -318,6 +322,7 @@ files:
|
|
318
322
|
- app/views/effective/applicants/submitted.html.haml
|
319
323
|
- app/views/effective/applicants/summary.html.haml
|
320
324
|
- app/views/effective/fee_payments/_content.html.haml
|
325
|
+
- app/views/effective/fee_payments/_dashboard.html.haml
|
321
326
|
- app/views/effective/fee_payments/_declarations.html.haml
|
322
327
|
- app/views/effective/fee_payments/_demographics.html.haml
|
323
328
|
- app/views/effective/fee_payments/_demographics_fields.html.haml
|