effective_memberships 0.9.15 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/admin/effective_fees_datatable.rb +3 -0
- data/app/models/concerns/effective_memberships_owner.rb +23 -0
- data/app/models/concerns/effective_memberships_registrar.rb +14 -25
- data/app/models/effective/membership.rb +30 -0
- data/app/views/admin/applicants/_form_approve.html.haml +5 -2
- data/lib/effective_memberships/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 978c99bc1bc8f0106fac7867dc8a07acea70bd94456d248e20cbb2e57c633b76
|
4
|
+
data.tar.gz: af1183a241f5b564c7b3ca4aa1ded0768dfde262d3b75da1933ddd177e430ede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caa13055dda3360d3d1426710a39923cc79fcf99cf0af710acead650e3f56089d068e4d30fde0072ba2708cc144515a948a4a265624f0726e6afee4e1457861d
|
7
|
+
data.tar.gz: 5f8241aba4c6d6ca7757346ae74520993d48d4d04af8c5bdf486337ec2e939da8f2d7641fe746319d8c284190c07594b0be1b675240e996beee98815bb124c74
|
@@ -99,6 +99,10 @@ module EffectiveMembershipsOwner
|
|
99
99
|
fees.select { |fee| fee.fee_payment_fee? && !fee.purchased? }
|
100
100
|
end
|
101
101
|
|
102
|
+
def outstanding_renewal_fees
|
103
|
+
fees.select { |fee| fee.fee_type == 'Renewal' && !fee.purchased? }
|
104
|
+
end
|
105
|
+
|
102
106
|
def outstanding_fee_payments
|
103
107
|
fee_payments = EffectiveMemberships.FeePayment.all
|
104
108
|
|
@@ -333,6 +337,25 @@ module EffectiveMembershipsOwner
|
|
333
337
|
save!
|
334
338
|
end
|
335
339
|
|
340
|
+
# Delete the last membership history
|
341
|
+
def rollback_membership_history!
|
342
|
+
raise('expected membership to be present') unless membership.present?
|
343
|
+
|
344
|
+
(history, last) = membership_histories.last(2)
|
345
|
+
raise('expected 2 or more membership histories') unless history.present? && last.present?
|
346
|
+
|
347
|
+
last.mark_for_destruction
|
348
|
+
history.assign_attributes(end_on: nil)
|
349
|
+
|
350
|
+
membership.assign_attributes(
|
351
|
+
number: history.number,
|
352
|
+
categories: history.membership_categories,
|
353
|
+
statuses: history.membership_statuses
|
354
|
+
)
|
355
|
+
|
356
|
+
save!
|
357
|
+
end
|
358
|
+
|
336
359
|
def build_membership_history(start_on: nil, notes: nil)
|
337
360
|
raise('expected membership to be present') unless membership.present?
|
338
361
|
|
@@ -76,27 +76,8 @@ module EffectiveMembershipsRegistrar
|
|
76
76
|
membership.number ||= number
|
77
77
|
membership.number_as_integer ||= (Integer(number) rescue nil)
|
78
78
|
|
79
|
-
#
|
80
|
-
membership.
|
81
|
-
next if statuses.include?(membership_status.status)
|
82
|
-
membership_status.mark_for_destruction
|
83
|
-
end
|
84
|
-
|
85
|
-
# Build any additional statuses
|
86
|
-
statuses.each do |status|
|
87
|
-
membership.build_membership_status(status: status)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Delete any removed categories
|
91
|
-
membership.membership_categories.each do |membership_category|
|
92
|
-
next if categories.include?(membership_category.category)
|
93
|
-
membership_category.mark_for_destruction
|
94
|
-
end
|
95
|
-
|
96
|
-
# Build any additional categories
|
97
|
-
categories.each do |category|
|
98
|
-
membership.build_membership_category(category: category)
|
99
|
-
end
|
79
|
+
# Builds the membership_categories and membership_statuses. Marks for destruction ones that don't exist.
|
80
|
+
membership.assign_attributes(statuses: statuses, categories: categories)
|
100
81
|
|
101
82
|
changed = membership.membership_categories.any? { |mc| mc.new_record? || mc.marked_for_destruction? }
|
102
83
|
changed ||= membership.membership_statuses.any? { |ms| ms.new_record? || ms.marked_for_destruction? }
|
@@ -175,6 +156,7 @@ module EffectiveMembershipsRegistrar
|
|
175
156
|
raise('expected to and from to be different') if from == to
|
176
157
|
|
177
158
|
date ||= Time.zone.now
|
159
|
+
period = period(date: date)
|
178
160
|
|
179
161
|
# Existing Membership
|
180
162
|
membership = owner.membership
|
@@ -190,11 +172,18 @@ module EffectiveMembershipsRegistrar
|
|
190
172
|
membership.build_membership_status(status: status) if status.present?
|
191
173
|
|
192
174
|
unless skip_fees
|
193
|
-
|
194
|
-
|
175
|
+
existing = owner.membership_period_fee(category: from, period: period)
|
176
|
+
|
177
|
+
if existing
|
178
|
+
fee = owner.build_prorated_fee(date: date)
|
179
|
+
raise('already has purchased prorated fee') if fee.purchased?
|
195
180
|
|
196
|
-
|
197
|
-
|
181
|
+
fee = owner.build_discount_fee(date: date, from: from)
|
182
|
+
raise('already has purchased discount fee') if fee.purchased?
|
183
|
+
else
|
184
|
+
fee = owner.build_renewal_fee(category: to, period: period)
|
185
|
+
raise('already has purchased renewal fee') if fee.purchased?
|
186
|
+
end
|
198
187
|
end
|
199
188
|
|
200
189
|
save!(owner, date: date)
|
@@ -156,6 +156,21 @@ module Effective
|
|
156
156
|
membership_categories.reject(&:marked_for_destruction?).map(&:category_id)
|
157
157
|
end
|
158
158
|
|
159
|
+
def categories=(categories)
|
160
|
+
categories = Array(categories)
|
161
|
+
raise('expecting a membership category') if categories.any? { |cat| !cat.class.respond_to?(:effective_memberships_category?) }
|
162
|
+
|
163
|
+
# Delete any removed categories
|
164
|
+
membership_categories.each do |membership_category|
|
165
|
+
membership_category.mark_for_destruction unless categories.include?(membership_category.category)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Build any additional categories
|
169
|
+
categories.each { |category| build_membership_category(category: category) }
|
170
|
+
|
171
|
+
nil
|
172
|
+
end
|
173
|
+
|
159
174
|
# We might want to use singular memberships.
|
160
175
|
def category
|
161
176
|
raise('expected singular usage but there are more than one membership category') if categories.length > 1
|
@@ -192,6 +207,21 @@ module Effective
|
|
192
207
|
membership_statuses.reject(&:marked_for_destruction?).map(&:status_id)
|
193
208
|
end
|
194
209
|
|
210
|
+
def statuses=(statuses)
|
211
|
+
statuses = Array(statuses)
|
212
|
+
raise('expecting a membership category') if statuses.any? { |status| !status.class.respond_to?(:effective_memberships_status?) }
|
213
|
+
|
214
|
+
# Delete any removed statuses
|
215
|
+
membership_statuses.each do |membership_status|
|
216
|
+
membership_status.mark_for_destruction unless statuses.include?(membership_status.status)
|
217
|
+
end
|
218
|
+
|
219
|
+
# Build any additional statuses
|
220
|
+
statuses.each { |status| build_membership_status(status: status) }
|
221
|
+
|
222
|
+
nil
|
223
|
+
end
|
224
|
+
|
195
225
|
def statuses_sentence
|
196
226
|
statuses.map(&:to_s).to_sentence.presence || 'None'
|
197
227
|
end
|
@@ -31,8 +31,11 @@
|
|
31
31
|
%li A #{month} prorated fee
|
32
32
|
|
33
33
|
- if applicant.reclassification?
|
34
|
-
|
35
|
-
|
34
|
+
- if applicant.owner.outstanding_renewal_fees.present?
|
35
|
+
%li A renewal fee in their new category
|
36
|
+
- else
|
37
|
+
%li A #{month} prorated fee to the new category
|
38
|
+
%li A #{month} discount fee from their old category
|
36
39
|
|
37
40
|
- if applicant.reinstatement?
|
38
41
|
%li A #{month} prorated fee to their reinstatement category
|
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
|
+
version: 0.10.0
|
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-01-
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|