effective_memberships 0.9.16 → 0.10.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90078c67d46aca1f293b49ffacac17288bb24592a4007079e6843847845a4e48
4
- data.tar.gz: 0063d4f68e0c2ff073c06eb62812006d13f050b50eecbc10163aa80f0a862a04
3
+ metadata.gz: '09cdd3d71c709fdaacb54d4abd0d21217bd6e7e3a7395e687004eb124994b75b'
4
+ data.tar.gz: caebcbe36b5c113d715e47ef8df0d224f7ea825ae0fa3ea3f5efc59448bcc30f
5
5
  SHA512:
6
- metadata.gz: 01b87e4c9a1aa5664e5bb0fb14ca95a3fac57ea8f2ca0542e379e7e11a1d0450c7aef6fcd4b8d29ab3312e6db33e4a3729b60301b54870e0d7abe20f144df93b
7
- data.tar.gz: e71ea11d0e5d126f4e37474726a234440f6e2105131a57fd1a6427c9c2ab897884f3502df0f2150a89318748b494d156a1e11d3fd81334aab8d9c19d9c2ef533
6
+ metadata.gz: 50897b485cca843711185839c1e630b90211ac1559c7a956fd5d425d70a37ad7ef94b6a3863cd1055ac8efa226ef635a4b6186f32763e260c277cb198b4c7f3c
7
+ data.tar.gz: 0a53cc0947501e0f89c07d56e052b81f5b6a7f2c676698e5e45227f0c9ae460b8c674d90fd0bc521601eb5adef49ab07d1433ce6ccd5f80fcefb670b6c9845d6
@@ -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
 
@@ -263,8 +267,25 @@ module EffectiveMembershipsOwner
263
267
  # Build the renewal fee
264
268
  fee ||= fees.build()
265
269
 
266
- late_on ||= EffectiveMemberships.Registrar.late_fee_date(period: period) if category.create_late_fees?
267
- not_in_good_standing_on ||= EffectiveMemberships.Registrar.not_in_good_standing_date(period: period) if category.create_not_in_good_standing?
270
+ # Late on this period's late date, or 60 days, whichever is later
271
+ late_on ||= if category.create_late_fees?
272
+ late_date = EffectiveMemberships.Registrar.late_fee_date(period: period)
273
+
274
+ duration = EffectiveMemberships.Registrar.min_late_duration
275
+ min_date = ((fee.created_at || Time.zone.now) + duration) if duration.present?
276
+
277
+ [late_date, min_date].compact.max
278
+ end
279
+
280
+ # NIGS on this period's late date, or 60 days, whichever is later
281
+ not_in_good_standing_on ||= if category.create_not_in_good_standing?
282
+ nigs_date = EffectiveMemberships.Registrar.not_in_good_standing_date(period: period)
283
+
284
+ duration = EffectiveMemberships.Registrar.min_not_in_good_standing_duration
285
+ min_date = ((fee.created_at || Time.zone.now) + duration) if duration.present?
286
+
287
+ [nigs_date, min_date].compact.max
288
+ end
268
289
 
269
290
  fee.assign_attributes(
270
291
  fee_type: 'Renewal',
@@ -33,6 +33,18 @@ module EffectiveMembershipsRegistrar
33
33
  raise('to be implemented by app registrar')
34
34
  end
35
35
 
36
+ # A renewal fee must be at least this old to be considered late?
37
+ # Must be less than (late_fee_date - renewal_fee_date) but this is not enforced
38
+ def min_late_duration
39
+ 60.days
40
+ end
41
+
42
+ # A renewal fee must be at least this old to be considered nigs?
43
+ # Must be less than (nigs_date - renewal_fee_date) but this is not enforced
44
+ def min_not_in_good_standing_duration
45
+ 60.days
46
+ end
47
+
36
48
  # scope
37
49
  def not_in_good_standing_status
38
50
  EffectiveMemberships.Status.where(title: 'Not In Good Standing')
@@ -156,6 +168,7 @@ module EffectiveMembershipsRegistrar
156
168
  raise('expected to and from to be different') if from == to
157
169
 
158
170
  date ||= Time.zone.now
171
+ period = period(date: date)
159
172
 
160
173
  # Existing Membership
161
174
  membership = owner.membership
@@ -171,11 +184,18 @@ module EffectiveMembershipsRegistrar
171
184
  membership.build_membership_status(status: status) if status.present?
172
185
 
173
186
  unless skip_fees
174
- fee = owner.build_prorated_fee(date: date)
175
- raise('already has purchased prorated fee') if fee.purchased?
187
+ existing = owner.membership_period_fee(category: from, period: period)
176
188
 
177
- fee = owner.build_discount_fee(date: date, from: from)
178
- raise('already has purchased discount fee') if fee.purchased?
189
+ if existing
190
+ fee = owner.build_prorated_fee(date: date)
191
+ raise('already has purchased prorated fee') if fee.purchased?
192
+
193
+ fee = owner.build_discount_fee(date: date, from: from)
194
+ raise('already has purchased discount fee') if fee.purchased?
195
+ else
196
+ fee = owner.build_renewal_fee(category: to, period: period)
197
+ raise('already has purchased renewal fee') if fee.purchased?
198
+ end
179
199
  end
180
200
 
181
201
  save!(owner, date: date)
@@ -87,14 +87,26 @@ module Effective
87
87
  return false if late_on.blank?
88
88
  return false if purchased?
89
89
 
90
- late_on <= Time.zone.now.to_date
90
+ now = Time.zone.now
91
+
92
+ if(duration = EffectiveMemberships.Registrar.min_late_duration).present?
93
+ return false if ((created_at || now) + duration > now)
94
+ end
95
+
96
+ late_on <= now.to_date
91
97
  end
92
98
 
93
99
  def not_in_good_standing?
94
100
  return false if not_in_good_standing_on.blank?
95
101
  return false if purchased?
96
102
 
97
- not_in_good_standing_on <= Time.zone.now.to_date
103
+ now = Time.zone.now
104
+
105
+ if(duration = EffectiveMemberships.Registrar.min_not_in_good_standing_duration).present?
106
+ return false if ((created_at || now) + duration > now)
107
+ end
108
+
109
+ not_in_good_standing_on <= now.to_date
98
110
  end
99
111
 
100
112
  # Used by applicant.applicant_submit_fees
@@ -31,8 +31,11 @@
31
31
  %li A #{month} prorated fee
32
32
 
33
33
  - if applicant.reclassification?
34
- %li A #{month} prorated fee to the new category
35
- %li A #{month} discount fee from their old category
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.9.16'
2
+ VERSION = '0.10.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.9.16
4
+ version: 0.10.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-01-20 00:00:00.000000000 Z
11
+ date: 2023-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails