effective_memberships 0.4.6 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/memberships_controller.rb +1 -1
- data/app/datatables/admin/effective_organizations_datatable.rb +1 -1
- data/app/models/concerns/effective_memberships_organization.rb +5 -0
- data/app/models/concerns/effective_memberships_owner.rb +18 -2
- data/app/models/concerns/effective_memberships_registrar.rb +31 -30
- data/app/models/concerns/effective_memberships_user.rb +5 -0
- data/app/models/effective/membership.rb +40 -3
- data/app/models/effective/membership_history.rb +2 -0
- data/app/views/admin/fee_payments/_fee_payment.html.haml +4 -0
- data/app/views/admin/fees/_form.html.haml +2 -3
- data/app/views/admin/memberships/_form_membership.html.haml +1 -1
- data/app/views/admin/users/_col.html.haml +12 -0
- data/app/views/effective/fee_payments/_orders.html.haml +1 -1
- data/lib/effective_memberships/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60e4351c09c9d070ea622ed6e7770df2f14d53e177a4ea74e04294d00b91af6f
|
4
|
+
data.tar.gz: 65436fdfda6a93aa08e1846d44b13131eedcc9d92e5831742dd6892d5ed87a32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bffdf6c0614f8f36ee84b38426b1a8ea9aae37a7b1385fe9ce746584196bb043d2c835f1414942f8dc504b53090e6725649657fe348feab736a9b00453aa13c7
|
7
|
+
data.tar.gz: 845130d67ea3500c634f2f9c96684af9ca1785dc50133ac94efda8087cb80e2e50bf05ea071540106d7d0250c557a0267ead9ed5b3ea2f98ca59cb99858b197a
|
@@ -5,7 +5,7 @@ module Admin
|
|
5
5
|
|
6
6
|
include Effective::CrudController
|
7
7
|
|
8
|
-
submit :
|
8
|
+
submit :revise, 'Update Membership',
|
9
9
|
success: -> { "#{resource.owner} has been successfully updated. Please double check the membership history is correct" },
|
10
10
|
redirect: -> { admin_owners_path(resource) }
|
11
11
|
|
@@ -63,7 +63,7 @@ module Admin
|
|
63
63
|
end
|
64
64
|
|
65
65
|
collection do
|
66
|
-
EffectiveMemberships.Organization.deep.left_joins(:membership).includes(membership: :membership_categories)
|
66
|
+
EffectiveMemberships.Organization.deep.left_joins(:membership).includes(:addresses, membership: :membership_categories)
|
67
67
|
end
|
68
68
|
|
69
69
|
def categories
|
@@ -62,6 +62,11 @@ module EffectiveMembershipsOrganization
|
|
62
62
|
scope :deep, -> { includes(:representatives) }
|
63
63
|
scope :sorted, -> { order(:title) }
|
64
64
|
|
65
|
+
scope :membership_applying, -> {
|
66
|
+
applicants = EffectiveMemberships.Applicant.all
|
67
|
+
without_role(:member).where(id: applicants.select(:organization_id))
|
68
|
+
}
|
69
|
+
|
65
70
|
validates :title, presence: true, uniqueness: true
|
66
71
|
validates :email, presence: true
|
67
72
|
end
|
@@ -37,6 +37,22 @@ module EffectiveMembershipsOwner
|
|
37
37
|
accepts_nested_attributes_for :membership_histories
|
38
38
|
|
39
39
|
scope :members, -> { joins(:membership) }
|
40
|
+
|
41
|
+
scope :membership_removed, -> {
|
42
|
+
removed = Effective::MembershipHistory.removed.where(owner_type: name)
|
43
|
+
without_role(:member).where(id: removed.select(:owner_id))
|
44
|
+
}
|
45
|
+
|
46
|
+
scope :membership_bad_standing, -> {
|
47
|
+
bad_standing = Effective::Membership.where(bad_standing: true).where(owner_type: name)
|
48
|
+
where(id: bad_standing.select(:owner_id))
|
49
|
+
}
|
50
|
+
|
51
|
+
scope :membership_renewed_this_period, -> {
|
52
|
+
with_paid_fees_through = Effective::Membership.with_paid_fees_through.where(owner_type: name)
|
53
|
+
where(id: with_paid_fees_through.select(:owner_id))
|
54
|
+
}
|
55
|
+
|
40
56
|
end
|
41
57
|
|
42
58
|
def assign_member_role
|
@@ -181,8 +197,8 @@ module EffectiveMembershipsOwner
|
|
181
197
|
# Build the renewal fee
|
182
198
|
fee ||= fees.build()
|
183
199
|
|
184
|
-
late_on ||= EffectiveMemberships.Registrar.late_fee_date(period: period)
|
185
|
-
bad_standing_on ||= EffectiveMemberships.Registrar.bad_standing_date(period: period)
|
200
|
+
late_on ||= EffectiveMemberships.Registrar.late_fee_date(period: period) if category.create_late_fees?
|
201
|
+
bad_standing_on ||= EffectiveMemberships.Registrar.bad_standing_date(period: period) if category.create_bad_standing?
|
186
202
|
|
187
203
|
fee.assign_attributes(
|
188
204
|
fee_type: 'Renewal',
|
@@ -284,52 +284,53 @@ module EffectiveMembershipsRegistrar
|
|
284
284
|
retval
|
285
285
|
end
|
286
286
|
|
287
|
-
|
288
287
|
# This is intended to be run once per day in a rake task
|
289
288
|
# rake effective_memberships:create_fees
|
290
289
|
# Create Renewal and Late fees
|
291
|
-
def create_fees!(period: nil
|
292
|
-
# The current period, based on Time.zone.now
|
290
|
+
def create_fees!(period: nil)
|
293
291
|
period ||= current_period
|
294
|
-
|
295
|
-
bad_standing_on ||= bad_standing_date(period: period)
|
292
|
+
memberships = Effective::Membership.deep.with_unpaid_fees_through(period)
|
296
293
|
|
297
294
|
# Create Renewal Fees
|
298
|
-
|
299
|
-
|
300
|
-
existing = membership.owner.membership_period_fee(category: category, period: period, except: 'Renewal')
|
301
|
-
next if existing.present? # This might be an existing Prorated fee
|
295
|
+
memberships.find_each { |membership| create_renewal_fees!(membership, period: period) }
|
296
|
+
GC.start
|
302
297
|
|
303
|
-
|
304
|
-
|
305
|
-
|
298
|
+
# Create Late Fees
|
299
|
+
memberships.find_each { |membership| create_late_fees!(membership, period: period) }
|
300
|
+
GC.start
|
306
301
|
|
307
|
-
|
302
|
+
# Update Membership Status - Assign In Bad Standing
|
303
|
+
memberships.find_each { |membership| update_membership_status!(membership, period: period) }
|
304
|
+
GC.start
|
308
305
|
|
309
|
-
|
310
|
-
|
311
|
-
end
|
306
|
+
true
|
307
|
+
end
|
312
308
|
|
313
|
-
|
309
|
+
def create_renewal_fees!(membership, period:)
|
310
|
+
membership.categories.select(&:create_renewal_fees?).map do |category|
|
311
|
+
existing = membership.owner.membership_period_fee(category: category, period: period, except: 'Renewal')
|
312
|
+
next if existing.present? # This might be an existing Prorated fee
|
314
313
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
fee = membership.owner.build_late_fee(category: category, period: period)
|
319
|
-
next if fee.blank? || fee.purchased?
|
314
|
+
fee = membership.owner.build_renewal_fee(category: category, period: period)
|
315
|
+
raise("expected build_renewal_fee to return a fee for period #{period}") unless fee.kind_of?(Effective::Fee)
|
316
|
+
next if fee.purchased?
|
320
317
|
|
321
|
-
|
322
|
-
end
|
323
|
-
end
|
318
|
+
puts("Created renewal fee for #{membership.owner}") if fee.new_record? && !Rails.env.test?
|
324
319
|
|
325
|
-
|
320
|
+
fee.save!
|
321
|
+
end
|
322
|
+
end
|
326
323
|
|
327
|
-
|
328
|
-
|
329
|
-
membership.owner.
|
324
|
+
def create_late_fees!(membership, period:)
|
325
|
+
membership.categories.select(&:create_late_fees?).map do |category|
|
326
|
+
fee = membership.owner.build_late_fee(category: category, period: period)
|
327
|
+
next if fee.blank? || fee.purchased?
|
328
|
+
fee.save!
|
330
329
|
end
|
330
|
+
end
|
331
331
|
|
332
|
-
|
332
|
+
def update_membership_status!(membership, period: nil)
|
333
|
+
membership.owner.update_membership_status!
|
333
334
|
end
|
334
335
|
|
335
336
|
# Called in the after_purchase of fee payment
|
@@ -27,6 +27,11 @@ module EffectiveMembershipsUser
|
|
27
27
|
class_name: 'Effective::Representative', inverse_of: :user, dependent: :delete_all
|
28
28
|
|
29
29
|
accepts_nested_attributes_for :representatives, allow_destroy: true
|
30
|
+
|
31
|
+
scope :membership_applying, -> {
|
32
|
+
applicants = EffectiveMemberships.Applicant.all
|
33
|
+
without_role(:member).where(id: applicants.select(:user_id))
|
34
|
+
}
|
30
35
|
end
|
31
36
|
|
32
37
|
# Instance Methods
|
@@ -38,8 +38,9 @@ module Effective
|
|
38
38
|
}
|
39
39
|
|
40
40
|
scope :with_unpaid_fees_through, -> (period = nil) {
|
41
|
-
where(arel_table[:
|
42
|
-
.or(where(fees_paid_period: nil))
|
41
|
+
joined = where(arel_table[:joined_on].lt(period || EffectiveMemberships.Registrar.current_period))
|
42
|
+
unpaid = where(arel_table[:fees_paid_period].lt(period || EffectiveMemberships.Registrar.current_period)).or(where(fees_paid_period: nil))
|
43
|
+
joined.merge(unpaid)
|
43
44
|
}
|
44
45
|
|
45
46
|
before_validation do
|
@@ -119,7 +120,24 @@ module Effective
|
|
119
120
|
end
|
120
121
|
|
121
122
|
def fees_paid?
|
122
|
-
|
123
|
+
paid_fees_through?(EffectiveMemberships.Registrar.current_period)
|
124
|
+
end
|
125
|
+
|
126
|
+
def paid_fees_through?(period = nil)
|
127
|
+
period ||= EffectiveMemberships.Registrar.current_period
|
128
|
+
|
129
|
+
return false if fees_paid_period.blank?
|
130
|
+
fees_paid_period >= period
|
131
|
+
end
|
132
|
+
|
133
|
+
def unpaid_fees_through?(period = nil)
|
134
|
+
period ||= EffectiveMemberships.Registrar.current_period
|
135
|
+
|
136
|
+
return false if joined_on.blank?
|
137
|
+
return false unless joined_on < period
|
138
|
+
|
139
|
+
return true if fees_paid_period.blank?
|
140
|
+
fees_paid_period < period
|
123
141
|
end
|
124
142
|
|
125
143
|
def change_fees_paid_period
|
@@ -127,6 +145,10 @@ module Effective
|
|
127
145
|
end
|
128
146
|
|
129
147
|
def change_fees_paid_period=(date)
|
148
|
+
if date.blank?
|
149
|
+
return assign_attributes(fees_paid_period: nil, fees_paid_through_period: nil)
|
150
|
+
end
|
151
|
+
|
130
152
|
date = (date.respond_to?(:strftime) ? date : Date.parse(date))
|
131
153
|
|
132
154
|
period = EffectiveMemberships.Registrar.period(date: date)
|
@@ -135,5 +157,20 @@ module Effective
|
|
135
157
|
assign_attributes(fees_paid_period: period, fees_paid_through_period: period_end_on)
|
136
158
|
end
|
137
159
|
|
160
|
+
# Admin updating membership info
|
161
|
+
def revise!
|
162
|
+
save!
|
163
|
+
|
164
|
+
period = EffectiveMemberships.Registrar.current_period
|
165
|
+
return true if paid_fees_through?(period)
|
166
|
+
|
167
|
+
# Otherwise build fees right now
|
168
|
+
EffectiveMemberships.Registrar.create_renewal_fees!(self, period: period)
|
169
|
+
EffectiveMemberships.Registrar.create_late_fees!(self, period: period)
|
170
|
+
EffectiveMemberships.Registrar.update_membership_status!(self, period: period)
|
171
|
+
|
172
|
+
true
|
173
|
+
end
|
174
|
+
|
138
175
|
end
|
139
176
|
end
|
@@ -3,9 +3,8 @@
|
|
3
3
|
= f.hidden_field :owner_id
|
4
4
|
= f.hidden_field :owner_type
|
5
5
|
- else
|
6
|
-
-
|
7
|
-
|
8
|
-
= f.select :owner_id, collection, polymorphic: true
|
6
|
+
- collection = { 'Users' => current_user.class.sorted, 'Organizations' => EffectiveMemberships.Organization.sorted }
|
7
|
+
= f.select :owner, collection, polymorphic: true
|
9
8
|
|
10
9
|
- if f.object.new_record?
|
11
10
|
= f.select :fee_type, EffectiveMemberships.custom_fee_types
|
@@ -21,7 +21,7 @@
|
|
21
21
|
- periods = registrar.periods(from: f.object.joined_on)
|
22
22
|
- collection = periods.reverse.map { |period| [registrar.period_end_on(date: period), period] }
|
23
23
|
|
24
|
-
= f.select :change_fees_paid_period, collection, label: 'Fees Paid Through', hint: 'Which period this user has fees paid through.
|
24
|
+
= f.select :change_fees_paid_period, collection, label: 'Fees Paid Through', hint: 'Which period this user has fees paid through. Determines which renewal fees should be created. Setting this to a past or blank period may create a renewal fee in the current period.'
|
25
25
|
|
26
26
|
%p.text-muted To update the current membership categories, use the 'Assign' or 'Reclassify' actions below
|
27
27
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
- user = (resource.respond_to?(:email) ? resource : resource.user)
|
2
|
+
|
3
|
+
= user.to_s
|
4
|
+
|
5
|
+
- if user.email.present?
|
6
|
+
%br
|
7
|
+
= mail_to user.email
|
8
|
+
|
9
|
+
- if user.membership.present?
|
10
|
+
%br
|
11
|
+
= '#' + user.membership.number
|
12
|
+
#{user.membership.categories.to_sentence}
|
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.4.
|
4
|
+
version: 0.4.9
|
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: 2022-04-
|
11
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: timecop
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: effective_test_bot
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,6 +366,7 @@ files:
|
|
352
366
|
- app/views/admin/registrar_actions/_form_remove.html.haml
|
353
367
|
- app/views/admin/representatives/_form.html.haml
|
354
368
|
- app/views/admin/representatives/_user_fields.html.haml
|
369
|
+
- app/views/admin/users/_col.html.haml
|
355
370
|
- app/views/effective/applicant_references/_applicant_reference.html.haml
|
356
371
|
- app/views/effective/applicant_references/_datatable_actions.html.haml
|
357
372
|
- app/views/effective/applicant_references/_form.html.haml
|