effective_memberships 0.4.5 → 0.4.8
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/memberships_controller.rb +1 -1
- data/app/datatables/admin/effective_organizations_datatable.rb +46 -3
- data/app/models/concerns/effective_memberships_organization.rb +1 -0
- data/app/models/concerns/effective_memberships_owner.rb +2 -2
- data/app/models/concerns/effective_memberships_registrar.rb +31 -30
- data/app/models/effective/membership.rb +40 -3
- data/app/views/admin/memberships/_form_membership.html.haml +1 -1
- data/app/views/admin/organizations/_fields.html.haml +0 -2
- data/app/views/admin/organizations/_form.html.haml +1 -5
- data/app/views/admin/organizations/_form_organization.html.haml +1 -3
- data/lib/effective_memberships/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52711c835dc479a8bc52e2c523d295999270b98eac479cfa8af855d12452466e
|
4
|
+
data.tar.gz: d5368da347ce46759fc6858b4c231788f91a0baf4ba70a8a8c9104c10e991c1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a62bf9547cd039f6f9035c0e075328db83455173709a0dbd672db63be2a6c92cf10551d43962deddcafca76c828c53ff0df2cf374ebf26a8e960d443b71586b
|
7
|
+
data.tar.gz: 7d57abebdaffccdf19af9a1220e20cd244054f04e8807da1e2dc3a45bb40a6010758e4e8676ded2e6321f14d59e4ca488dd05ac391514403c0315464b21c5c86
|
@@ -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
|
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Admin
|
2
2
|
class EffectiveOrganizationsDatatable < Effective::Datatable
|
3
|
-
|
3
|
+
filters do
|
4
|
+
scope :unarchived, label: 'All'
|
5
|
+
scope :members
|
6
|
+
scope :archived
|
7
|
+
end
|
4
8
|
|
9
|
+
datatable do
|
5
10
|
col :updated_at, visible: false
|
6
11
|
col :created_at, visible: false
|
7
12
|
|
@@ -11,16 +16,54 @@ module Admin
|
|
11
16
|
col :category, search: categories
|
12
17
|
end
|
13
18
|
|
14
|
-
col :
|
19
|
+
col(:to_s, label: 'Organization', sql_column: true, action: :edit)
|
20
|
+
.search do |collection, term|
|
21
|
+
collection.where(id: effective_resource.search_any(term))
|
22
|
+
end.sort do |collection, direction|
|
23
|
+
collection.order(title: direction)
|
24
|
+
end
|
25
|
+
|
26
|
+
col :title, visible: false
|
27
|
+
|
28
|
+
col 'membership.joined_on'
|
29
|
+
col 'membership.fees_paid_through_period', label: 'Fees Paid Through'
|
30
|
+
col 'membership.categories'
|
15
31
|
|
16
32
|
col :representatives_count
|
17
33
|
col :representatives
|
18
34
|
|
35
|
+
col :email, visible: false
|
36
|
+
|
37
|
+
col :address1, visible: false do |organization|
|
38
|
+
organization.billing_address&.address1
|
39
|
+
end
|
40
|
+
col :address2, visible: false do |organization|
|
41
|
+
organization.billing_address&.address2
|
42
|
+
end
|
43
|
+
col :city, visible: false do |organization|
|
44
|
+
organization.billing_address&.city
|
45
|
+
end
|
46
|
+
col :state_code, label: 'Prov', visible: false do |organization|
|
47
|
+
organization.billing_address&.state_code
|
48
|
+
end
|
49
|
+
col :postal_code, label: 'Postal', visible: false do |organization|
|
50
|
+
organization.billing_address&.postal_code
|
51
|
+
end
|
52
|
+
col :country_code, label: 'Country', visible: false do |organization|
|
53
|
+
organization.billing_address&.country_code
|
54
|
+
end
|
55
|
+
|
56
|
+
col :phone, visible: false
|
57
|
+
col :fax, visible: false
|
58
|
+
col :website, visible: false
|
59
|
+
col :category, visible: false
|
60
|
+
col :notes, visible: false
|
61
|
+
|
19
62
|
actions_col
|
20
63
|
end
|
21
64
|
|
22
65
|
collection do
|
23
|
-
EffectiveMemberships.Organization.deep.
|
66
|
+
EffectiveMemberships.Organization.deep.left_joins(:membership).includes(:addresses, membership: :membership_categories)
|
24
67
|
end
|
25
68
|
|
26
69
|
def categories
|
@@ -23,6 +23,7 @@ module EffectiveMembershipsOrganization
|
|
23
23
|
effective_memberships_owner
|
24
24
|
|
25
25
|
acts_as_addressable :billing # effective_addresses
|
26
|
+
acts_as_archived unless respond_to?(:acts_as_archived?)
|
26
27
|
log_changes(except: [:representatives, :users]) if respond_to?(:log_changes)
|
27
28
|
|
28
29
|
# rich_text_body
|
@@ -181,8 +181,8 @@ module EffectiveMembershipsOwner
|
|
181
181
|
# Build the renewal fee
|
182
182
|
fee ||= fees.build()
|
183
183
|
|
184
|
-
late_on ||= EffectiveMemberships.Registrar.late_fee_date(period: period)
|
185
|
-
bad_standing_on ||= EffectiveMemberships.Registrar.bad_standing_date(period: period)
|
184
|
+
late_on ||= EffectiveMemberships.Registrar.late_fee_date(period: period) if category.create_late_fees?
|
185
|
+
bad_standing_on ||= EffectiveMemberships.Registrar.bad_standing_date(period: period) if category.create_bad_standing?
|
186
186
|
|
187
187
|
fee.assign_attributes(
|
188
188
|
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
|
@@ -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
|
@@ -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
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
- if organization.persisted?
|
6
6
|
- if can?(:index, Effective::Membership)
|
7
7
|
= tab 'Membership' do
|
8
|
-
= render 'admin/
|
8
|
+
= render 'admin/memberships/form', owner: organization
|
9
9
|
|
10
10
|
= tab 'Representatives' do
|
11
11
|
= render_datatable(Admin::EffectiveRepresentativesDatatable.new(organization: organization), inline: true, namespace: :admin)
|
@@ -18,10 +18,6 @@
|
|
18
18
|
= tab 'Fee Payments' do
|
19
19
|
= render_inline_datatable(Admin::EffectiveFeePaymentsDatatable.new(organization: organization))
|
20
20
|
|
21
|
-
- if can?(:index, Effective::MembershipHistory)
|
22
|
-
= tab 'History' do
|
23
|
-
= render_datatable(Admin::EffectiveMembershipHistoriesDatatable.new(owner: organization))
|
24
|
-
|
25
21
|
- if can?(:index, Effective::Order)
|
26
22
|
= tab 'Orders' do
|
27
23
|
= render_datatable(Admin::EffectiveOrdersDatatable.new(user: organization))
|
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.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: 2022-
|
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
|