effective_memberships 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5630148361e363550dea41e32b75f80ce1534bd93a4c18873d724c7b0b9cd61
4
- data.tar.gz: 46e7aa62a886f604e4ebbf9b80e76f44f3fe5ee933f9e5f468513d412007fd62
3
+ metadata.gz: 0100c4901a84ee663094b0c2875ea528d7345f68f99659e09f5d6daf973ce54c
4
+ data.tar.gz: 17df43487cab37459c5ea999396724f556b74f05e7ed853eaf55bfb3f0e3b279
5
5
  SHA512:
6
- metadata.gz: 91fb28c6ba34f3ac0146219b14f613fb4d19b883963e268d1117bcd56d9f7fcdfb4c5bd807230c53d14d2aefc49eb525867cc23c370948562d881ad79a29029a
7
- data.tar.gz: eb61306191817a7bde172a548d2cf373f3210b235857c1a35d6923522a7ffddafbeeff6124ce5ef2e8d2bb9161c32d0de606465738ee88aeb74adc2e15efc92e
6
+ metadata.gz: 3e06ad2ca2dc09ec15d83a7d413d6cd07663c198f16b6ea8716c0e669dd1671d6141396cf2ce0d903cf47b0c22a2bccf710764981595ee55d43a624bbc91be54
7
+ data.tar.gz: c0c489c0dfc6deda6be5fdb9ebb70f8647c7afb41a10d8905d59e78b7dcf1ad03d3bc46733169b1089d28d0a767f4c46d8bbc6a26f2459602d88466c93a53426
@@ -264,7 +264,7 @@ module EffectiveMembershipsOwner
264
264
 
265
265
  # Only continue if there is a late renewal fee for the same period
266
266
  renewal_fee = fees.find { |fee| fee.fee_type == 'Renewal' && fee.period == period && fee.category_id == category.id && fee.category_type == category.class.name }
267
- return unless fee.present? || renewal_fee&.late?
267
+ return if fee.blank? && (renewal_fee.blank? || renewal_fee.late? == false)
268
268
 
269
269
  # Build the late fee
270
270
  fee ||= fees.build()
@@ -292,7 +292,7 @@ module EffectiveMembershipsOwner
292
292
  # Assign in bad standing
293
293
  if membership.bad_standing_admin?
294
294
  # Nothing to do
295
- elsif bad_standing_fees.present?
295
+ elsif bad_standing_fees.present? && membership.categories.any?(&:create_bad_standing?)
296
296
  membership.bad_standing = true
297
297
  membership.bad_standing_reason = 'Unpaid Fees'
298
298
  else
@@ -401,7 +401,7 @@ module EffectiveMembershipsRegistrar
401
401
  GC.start
402
402
 
403
403
  # Update Membership Status - Assign In Bad Standing
404
- memberships.find_each { |membership| update_membership_status!(membership, period: period) }
404
+ memberships.find_each { |membership| create_bad_standing!(membership, period: period) }
405
405
  GC.start
406
406
 
407
407
  true
@@ -416,7 +416,7 @@ module EffectiveMembershipsRegistrar
416
416
  raise("expected build_renewal_fee to return a fee for period #{period}") unless fee.kind_of?(Effective::Fee)
417
417
  next if fee.purchased?
418
418
 
419
- puts("Created renewal fee for #{membership.owner}") if fee.new_record? && !Rails.env.test?
419
+ puts("Created renewal fee for #{membership.owner}") if fee.new_record? && debug?
420
420
 
421
421
  fee.save!
422
422
  end
@@ -426,10 +426,18 @@ module EffectiveMembershipsRegistrar
426
426
  membership.categories.select(&:create_late_fees?).map do |category|
427
427
  fee = membership.owner.build_late_fee(category: category, period: period)
428
428
  next if fee.blank? || fee.purchased?
429
+
430
+ puts("Created late fee for #{membership.owner}") if fee.new_record? && debug?
431
+
429
432
  fee.save!
430
433
  end
431
434
  end
432
435
 
436
+ def create_bad_standing!(membership, period:)
437
+ return unless membership.categories.any?(&:create_bad_standing?)
438
+ update_membership_status!(membership, period: period)
439
+ end
440
+
433
441
  def update_membership_status!(membership, period: nil)
434
442
  membership.owner.update_membership_status!
435
443
  end
@@ -442,6 +450,10 @@ module EffectiveMembershipsRegistrar
442
450
 
443
451
  protected
444
452
 
453
+ def debug?
454
+ false
455
+ end
456
+
445
457
  def add_member_role(owner)
446
458
  owner.add_role(:member)
447
459
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.7.3'
2
+ VERSION = '0.7.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_memberships
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect