effective_memberships 0.9.4 → 0.9.6
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/datatables/admin/effective_fees_datatable.rb +8 -2
- data/app/models/concerns/effective_memberships_applicant.rb +3 -0
- data/app/models/concerns/effective_memberships_owner.rb +9 -0
- data/app/models/concerns/effective_memberships_registrar.rb +39 -7
- data/app/models/effective/fee.rb +5 -1
- data/app/models/effective/membership.rb +2 -3
- data/app/models/effective/registrar_action.rb +2 -0
- data/app/views/admin/applicants/_form_approve.html.haml +11 -1
- data/app/views/admin/fees/_form.html.haml +22 -29
- data/app/views/admin/memberships/_form_membership.html.haml +1 -1
- data/app/views/admin/registrar_actions/_form_fees_paid.html.haml +1 -0
- data/config/routes.rb +1 -1
- data/lib/effective_memberships/version.rb +1 -1
- data/lib/tasks/effective_memberships_tasks.rake +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: f42637485b8a72cd2cf2a7f4845e75dbca8d3c379270d4dfe0a607e70610117d
|
4
|
+
data.tar.gz: 9d41bd14aad6e7e54c76568bd58147d43965fd30060c07525941294b7504d28e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d456e9bcd40ce78fc83689c5352a85bc156ec50f7149bd169f7af1521d3ec1c58f6ed67b06922b28b36fec1cbb7c880a58e4e6c7ddcf197f3872e37fb5ac247b
|
7
|
+
data.tar.gz: 2f27824362cf294f83d4f953bb8c283045ef70a03910b17eeff1591f90df0a508bcf7dff1bbca53b49d6663f60d50376e9a8d4fb50da9cc47e6889724d34ef4d
|
@@ -21,6 +21,13 @@ module Admin
|
|
21
21
|
|
22
22
|
col :fee_type, search: EffectiveMemberships.fee_types
|
23
23
|
|
24
|
+
col :period, search: { collection: EffectiveMemberships.Registrar.periods_collection } do |fee|
|
25
|
+
EffectiveMemberships.Registrar.period_end_on(date: fee.period)
|
26
|
+
end
|
27
|
+
|
28
|
+
col :category, search: { collection: EffectiveMemberships.Category.all, polymorphic: false }
|
29
|
+
col :title
|
30
|
+
|
24
31
|
col :price, as: :price
|
25
32
|
col :qb_item_name, label: 'Quickbooks Item Name'
|
26
33
|
col :tax_exempt, visible: false
|
@@ -31,9 +38,8 @@ module Admin
|
|
31
38
|
col :parent, search: :string, visible: false
|
32
39
|
end
|
33
40
|
|
34
|
-
col :purchased_order
|
41
|
+
col :purchased_order
|
35
42
|
|
36
|
-
col :category, search: { collection: EffectiveMemberships.Category.all, polymorphic: false }
|
37
43
|
col :checkout_type, search: Effective::Fee::CHECKOUT_TYPES, visible: false
|
38
44
|
|
39
45
|
unless attributes[:total] == false
|
@@ -623,6 +623,7 @@ module EffectiveMembershipsApplicant
|
|
623
623
|
category_ids = user.membership.category_ids
|
624
624
|
|
625
625
|
categories.select do |cat|
|
626
|
+
cat.can_apply_new? ||
|
626
627
|
cat.can_apply_existing? ||
|
627
628
|
(cat.can_apply_restricted? && (category_ids & cat.can_apply_restricted_ids).present?)
|
628
629
|
end
|
@@ -847,6 +848,8 @@ module EffectiveMembershipsApplicant
|
|
847
848
|
|
848
849
|
approved!
|
849
850
|
|
851
|
+
EffectiveMemberships.Registrar.delete_fees!(owner)
|
852
|
+
|
850
853
|
if apply_to_join?
|
851
854
|
EffectiveMemberships.Registrar.register!(
|
852
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
|
@@ -375,24 +375,56 @@ module EffectiveMembershipsRegistrar
|
|
375
375
|
retval
|
376
376
|
end
|
377
377
|
|
378
|
+
def periods_collection(from: nil, to: nil)
|
379
|
+
from ||= Time.zone.now - 10.years
|
380
|
+
periods(from: from, to: to).reverse.map { |period| [period_end_on(date: period), period] }
|
381
|
+
end
|
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
|
+
|
378
398
|
# This is intended to be run once per day in a rake task
|
379
399
|
# rake effective_memberships:create_fees
|
380
400
|
# Create Renewal and Late fees
|
381
|
-
|
401
|
+
# Assigns NIGS
|
402
|
+
def create_all_fees!(period: nil)
|
382
403
|
period ||= current_period
|
383
404
|
memberships = Effective::Membership.deep.with_unpaid_fees_through(period)
|
384
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
|
+
|
385
420
|
# Create Renewal Fees
|
386
|
-
|
387
|
-
GC.start
|
421
|
+
create_renewal_fees!(membership, period: period)
|
388
422
|
|
389
423
|
# Create Late Fees
|
390
|
-
|
391
|
-
GC.start
|
424
|
+
create_late_fees!(membership, period: period)
|
392
425
|
|
393
426
|
# Update Membership Status - Assign Not In Good Standing
|
394
|
-
|
395
|
-
GC.start
|
427
|
+
create_not_in_good_standing!(membership, period: period)
|
396
428
|
|
397
429
|
true
|
398
430
|
end
|
data/app/models/effective/fee.rb
CHANGED
@@ -44,9 +44,13 @@ module Effective
|
|
44
44
|
self.with_status ||= owner.membership.statuses.first if owner.membership.statuses.length == 1
|
45
45
|
end
|
46
46
|
|
47
|
+
before_validation(if: -> { changes['title'].blank? && (changes.keys & ['period', 'category_id', 'fee_type']).present? }) do
|
48
|
+
self.title = default_title()
|
49
|
+
end
|
50
|
+
|
47
51
|
before_validation do
|
48
52
|
self.period ||= EffectiveMemberships.Registrar.current_period
|
49
|
-
self.title
|
53
|
+
self.title = default_title() if self.title.blank?
|
50
54
|
end
|
51
55
|
|
52
56
|
before_validation(if: -> { fee_type == 'Renewal' && category.present? && period.present? }) do
|
@@ -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.
|
256
|
-
EffectiveMemberships.Registrar.
|
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
|
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
|
|
@@ -6,45 +6,38 @@
|
|
6
6
|
- collection = { 'Users' => current_user.class.sorted, 'Organizations' => EffectiveMemberships.Organization.sorted }
|
7
7
|
= f.select :owner, collection, polymorphic: true
|
8
8
|
|
9
|
+
- registrar = EffectiveMemberships.Registrar
|
9
10
|
- fee_types = EffectiveMemberships.fee_types
|
10
11
|
- membership_period_fee_types = fee_types.select { |fee_type| Effective::Fee.new(fee_type: fee_type).membership_period_fee? }
|
11
12
|
|
12
|
-
-
|
13
|
-
|
14
|
-
- else
|
15
|
-
= f.static_field :fee_type
|
16
|
-
|
17
|
-
= f.show_if_any(:fee_type, membership_period_fee_types) do
|
18
|
-
= card do
|
19
|
-
%p This is a membership period fee. It will advance the membership fees paid through period when purchased.
|
20
|
-
%p Only one membership period fee -- Prorated or Renewal -- is expected to exist per membership period.
|
21
|
-
|
22
|
-
- registrar = EffectiveMemberships.Registrar
|
23
|
-
- periods = registrar.periods(from: Time.zone.now - 10.years)
|
24
|
-
- collection = periods.reverse.map { |period| [registrar.period_end_on(date: period), period] }
|
13
|
+
- f.object.period ||= registrar.current_period
|
14
|
+
- f.object.checkout_type ||= 'Default'
|
25
15
|
|
26
|
-
|
27
|
-
|
16
|
+
- f.object.category_id ||= f.object.owner&.membership&.categories&.first&.id
|
17
|
+
- f.object.category ||= f.object.owner&.membership&.categories&.first
|
28
18
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
= f.date_field :late_on, hint: 'A late fee will be applied on this date unless purchased'
|
19
|
+
= f.select :period, registrar.periods_collection, label: 'Membership period'
|
20
|
+
= f.select :fee_type, fee_types
|
21
|
+
= f.select :category_id, EffectiveMemberships.Category.all
|
33
22
|
|
34
|
-
|
35
|
-
|
23
|
+
= f.show_if_any(:fee_type, membership_period_fee_types) do
|
24
|
+
%p.text-muted
|
25
|
+
This is a membership period fee. It will advance the membership fees paid through period when purchased.
|
26
|
+
%br
|
27
|
+
Only one membership period fee -- Prorated or Renewal -- is expected to exist per membership period.
|
36
28
|
|
37
|
-
- f.object.
|
38
|
-
|
29
|
+
- if f.object.category.present?
|
30
|
+
= f.show_if(:fee_type, 'Renewal') do
|
31
|
+
- if f.object.category.create_late_fees?
|
32
|
+
= f.date_field :late_on, hint: 'A late fee will be applied on this date unless purchased. Leave blank to assign the default.'
|
39
33
|
|
40
|
-
|
41
|
-
|
34
|
+
- if f.object.category.create_not_in_good_standing?
|
35
|
+
= f.date_field :not_in_good_standing_on, hint: 'The membership will be marked NIGS on this date unless purchased. Leave blank to assign the default.'
|
42
36
|
|
43
|
-
|
44
|
-
|
45
|
-
- else
|
46
|
-
= f.static_field :parent
|
37
|
+
= f.radios :checkout_type, Effective::Fee::CHECKOUT_TYPES, inline: true, label: 'Checkout wizard',
|
38
|
+
hint: 'When default, Applicant and Reinstatement fees will be charged from the applicant wizard, and all other fee types from the fee payment wizard'
|
47
39
|
|
40
|
+
= f.text_field :title, hint: 'Leave blank to assign the default', required: false
|
48
41
|
= f.price_field :price
|
49
42
|
= f.text_field :qb_item_name, label: 'Quickbooks Item Name'
|
50
43
|
= f.check_box :tax_exempt, label: 'Yes, this fee is tax exempt'
|
@@ -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 '
|
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',
|
data/config/routes.rb
CHANGED
@@ -52,7 +52,7 @@ EffectiveMemberships::Engine.routes.draw do
|
|
52
52
|
|
53
53
|
resources :applicant_reviews, only: [:index, :show]
|
54
54
|
|
55
|
-
resources :fees
|
55
|
+
resources :fees, except: [:show]
|
56
56
|
resources :categories, only: [:index, :edit, :update]
|
57
57
|
|
58
58
|
resources :applicant_course_areas, except: [:show]
|
@@ -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.
|
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.
|
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-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|