effective_memberships 0.9.5 → 0.9.6

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: bea643081128f664a7c004dbc49a3e8e06f940781267f85f63c7c6d4e69fe6d1
4
- data.tar.gz: a769c9c7216ccdc090fc8a3e6107d654e49eeca2b20a171c48769b46d27a0cb0
3
+ metadata.gz: f42637485b8a72cd2cf2a7f4845e75dbca8d3c379270d4dfe0a607e70610117d
4
+ data.tar.gz: 9d41bd14aad6e7e54c76568bd58147d43965fd30060c07525941294b7504d28e
5
5
  SHA512:
6
- metadata.gz: 4553d6b65132b346f36882658baac0ae47ec8945f2f592c19fac705b2e5414d1f4597e5473d2209cdb6a6c0528768a4aa65fe75b59b9712f14ffccdc6c5203ca
7
- data.tar.gz: f6c02642c63397a2484fb0d9cd4b3fd471767b9c1b8449528e720ac2f73946a86520094ba39bd0b7056df0544e230a0f1a3bd60ddeb64ba689431664d9c3938b
6
+ metadata.gz: d456e9bcd40ce78fc83689c5352a85bc156ec50f7149bd169f7af1521d3ec1c58f6ed67b06922b28b36fec1cbb7c880a58e4e6c7ddcf197f3872e37fb5ac247b
7
+ data.tar.gz: 2f27824362cf294f83d4f953bb8c283045ef70a03910b17eeff1591f90df0a508bcf7dff1bbca53b49d6663f60d50376e9a8d4fb50da9cc47e6889724d34ef4d
@@ -848,6 +848,8 @@ module EffectiveMembershipsApplicant
848
848
 
849
849
  approved!
850
850
 
851
+ EffectiveMemberships.Registrar.delete_fees!(owner)
852
+
851
853
  if apply_to_join?
852
854
  EffectiveMemberships.Registrar.register!(
853
855
  owner,
@@ -99,6 +99,15 @@ module EffectiveMembershipsOwner
99
99
  fees.select { |fee| fee.fee_payment_fee? && !fee.purchased? }
100
100
  end
101
101
 
102
+ def outstanding_fee_payments
103
+ fee_payments = EffectiveMemberships.FeePayment.all
104
+
105
+ fee_payments = fee_payments.where(user: self) if self.class.respond_to?(:effective_memberships_user?)
106
+ fee_payments = fee_payments.where(organization: self) if self.class.respond_to?(:effective_memberships_organization?)
107
+
108
+ fee_payments.select { |fee_payment| fee_payment.in_progress? && fee_payment.orders.none?(&:purchased?) }
109
+ end
110
+
102
111
  def outstanding_fee_payment_orders
103
112
  orders.select { |order| order.parent_type.to_s.include?('FeePayment') && !order.purchased? }
104
113
  end
@@ -380,24 +380,51 @@ module EffectiveMembershipsRegistrar
380
380
  periods(from: from, to: to).reverse.map { |period| [period_end_on(date: period), period] }
381
381
  end
382
382
 
383
+ # Called by applicant.approve!
384
+ def delete_fees!(resource)
385
+ owner = (resource.class.respond_to?(:effective_memberships_owner?) ? resource : resource.try(:owner))
386
+ raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
387
+
388
+ # Delete unpurchased fees and orders
389
+ owner.outstanding_fee_payment_fees.each { |fee| fee.mark_for_destruction }
390
+ owner.outstanding_fee_payment_orders.each { |order| order.mark_for_destruction }
391
+ owner.save!
392
+
393
+ owner.outstanding_fee_payments.each { |fee_payment| fee_payment.destroy! }
394
+
395
+ true
396
+ end
397
+
383
398
  # This is intended to be run once per day in a rake task
384
399
  # rake effective_memberships:create_fees
385
400
  # Create Renewal and Late fees
386
- def create_fees!(period: nil)
401
+ # Assigns NIGS
402
+ def create_all_fees!(period: nil)
387
403
  period ||= current_period
388
404
  memberships = Effective::Membership.deep.with_unpaid_fees_through(period)
389
405
 
406
+ memberships.find_each do |membership|
407
+ create_fees!(membership, period: period)
408
+ GC.start
409
+ end
410
+
411
+ true
412
+ end
413
+
414
+ def create_fees!(resource, period: nil)
415
+ period ||= current_period
416
+
417
+ membership = (resource.class.respond_to?(:effective_memberships_owner?) ? resource.membership : resource)
418
+ raise('expected a membership') unless membership.present? && membership.kind_of?(Effective::Membership)
419
+
390
420
  # Create Renewal Fees
391
- memberships.find_each { |membership| create_renewal_fees!(membership, period: period) }
392
- GC.start
421
+ create_renewal_fees!(membership, period: period)
393
422
 
394
423
  # Create Late Fees
395
- memberships.find_each { |membership| create_late_fees!(membership, period: period) }
396
- GC.start
424
+ create_late_fees!(membership, period: period)
397
425
 
398
426
  # Update Membership Status - Assign Not In Good Standing
399
- memberships.find_each { |membership| create_not_in_good_standing!(membership, period: period) }
400
- GC.start
427
+ create_not_in_good_standing!(membership, period: period)
401
428
 
402
429
  true
403
430
  end
@@ -252,9 +252,8 @@ module Effective
252
252
  return true if paid_fees_through?(period)
253
253
 
254
254
  # Otherwise build fees right now
255
- EffectiveMemberships.Registrar.create_renewal_fees!(self, period: period)
256
- EffectiveMemberships.Registrar.create_late_fees!(self, period: period)
257
- EffectiveMemberships.Registrar.create_not_in_good_standing!(self, period: period)
255
+ EffectiveMemberships.Registrar.delete_fees!(self)
256
+ EffectiveMemberships.Registrar.create_fees!(self, period: period)
258
257
 
259
258
  true
260
259
  end
@@ -28,6 +28,7 @@ module Effective
28
28
  # Mark Fees Paid - Order Attributes
29
29
  attr_accessor :payment_provider
30
30
  attr_accessor :payment_card
31
+ attr_accessor :purchased_at
31
32
  attr_accessor :note_to_buyer
32
33
  attr_accessor :note_internal
33
34
 
@@ -136,6 +137,7 @@ module Effective
136
137
  {
137
138
  payment_provider: @payment_provider.presence,
138
139
  payment_card: @payment_card.presence,
140
+ purchased_at: @purchased_at.presence,
139
141
  note_to_buyer: @note_to_buyer.presence,
140
142
  note_internal: @note_internal.presence
141
143
  }.compact
@@ -16,7 +16,7 @@
16
16
  No membership number will be assigned.
17
17
 
18
18
  %h3 Fees
19
- %p The following fee(s) will be created:
19
+ %p The following fees will be created:
20
20
  - month = Time.zone.now.strftime('%B')
21
21
 
22
22
  %ul
@@ -27,6 +27,16 @@
27
27
  %li A #{month} prorated fee to the new category
28
28
  %li A #{month} discount fee from their old category
29
29
 
30
+ %p The following unpurchased fees will be deleted:
31
+ - outstanding_fee_payment_fees = applicant.owner.outstanding_fee_payment_fees
32
+
33
+ %ul
34
+ - outstanding_fee_payment_fees.each do |fee|
35
+ %li= fee
36
+
37
+ - if outstanding_fee_payment_fees.blank?
38
+ %li None
39
+
30
40
  %h3 Email to send
31
41
  - email_templates = applicant.approve_email_templates
32
42
 
@@ -23,6 +23,6 @@
23
23
 
24
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
- %p.text-muted To update the current membership categories, use the 'Assign' or 'Reclassify' actions below
26
+ %p.text-muted To update the current membership categories or statuses, use the 'Reclassify' or 'Status Change' actions below
27
27
 
28
28
  = f.submit 'Update Membership', border: false, center: true, 'data-confirm': "Really update #{f.object.owner}?"
@@ -31,6 +31,7 @@
31
31
  %p An order will be created and marked as paid with the following information:
32
32
 
33
33
  = f.select :payment_provider, EffectiveOrders.admin_payment_providers, required: true
34
+ = f.datetime_field :purchased_at, label: 'Purchased or completed'
34
35
 
35
36
  = f.text_field :payment_card,
36
37
  label: 'Payment card type, cheque or transaction number',
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.9.5'
2
+ VERSION = '0.9.6'
3
3
  end
@@ -11,7 +11,7 @@ namespace :effective_memberships do
11
11
  begin
12
12
  if ActiveRecord::Base.connection.table_exists?(:memberships)
13
13
  EffectiveLogger.info "Running effective_memberships:create_fees scheduled task" if defined?(EffectiveLogger)
14
- EffectiveMemberships.Registrar.create_fees!
14
+ EffectiveMemberships.Registrar.create_all_fees!
15
15
  end
16
16
  rescue => e
17
17
  ExceptionNotifier.notify_exception(e) if defined?(ExceptionNotifier)
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.5
4
+ version: 0.9.6
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-24 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails