effective_memberships 0.9.0 → 0.9.2

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: 34a684e853c8b3b7d6e43291514cc6242c9b1fc480e8523c8c40a0f109774c6a
4
- data.tar.gz: 57ce4d9495e7464abd05de9302a69f9bf86ad5fd2e4742e2b978b2fbbe39e079
3
+ metadata.gz: bced8cc69d7024a32e2c3a659c0b97637bbf3f1d3542f1757079e66e585f3cbb
4
+ data.tar.gz: 695ba5032274cceb7e0f1d39f7283edf8029032323b51988875afb0149d76759
5
5
  SHA512:
6
- metadata.gz: 1e1a659ec1fd40c302ebe4212a8c0cb41365fa13415288df965dc7daa3f6525b7237deafb86ca1dfe5ecca6a0f6605190286021227ef6fd2cc1dcea52d51bd03
7
- data.tar.gz: 959a2dce5b5f70566226ceef2bfec3f09dfc75182dd5faa02152c032e166d5ce1e1d569b601aa914ff5d1e9bc3534bcbaeb4e2ab9dc28a187b5198ef5bacd417
6
+ metadata.gz: 07ac154133b57deaa2aeb5eb26af1c2eac572e946e3b407b76715eeae3c8bf4eedb719dd8ed4c5b9a7a3e869a9b0db007dcc177fac88a048ecfa04db822f3954
7
+ data.tar.gz: 9139022657817e218cf169c6aa97b2eec69c89e8dc2592535f78815135289a15e098184b9a099a217112a4c213058f965cfae2835bcfc6369ba903e0f768f5d1
@@ -109,6 +109,17 @@ module EffectiveMembershipsFeePayment
109
109
  validates :user, presence: true
110
110
  validates :period, presence: true
111
111
 
112
+ # Sanity check validations. We should not have more than 1 in progress fee payment at a time
113
+ validate(if: -> { new_record? && user.present? }) do
114
+ existing = user.fee_payments.in_progress.first
115
+ self.errors.add(:base, 'please complete your existing fee payment first') if existing.present?
116
+ end
117
+
118
+ validate(if: -> { new_record? && organization.present? }) do
119
+ existing = organization.fee_payments.in_progress.first
120
+ self.errors.add(:base, 'please complete your existing fee payment first') if existing.present?
121
+ end
122
+
112
123
  # Declarations Step
113
124
  with_options(if: -> { current_step == :declarations }) do
114
125
  validates :declare_code_of_ethics, acceptance: true
@@ -27,10 +27,10 @@ module EffectiveMembershipsOwner
27
27
  has_many :orders, -> { order(:id) }, inverse_of: :user, as: :user, class_name: 'Effective::Order', dependent: :nullify
28
28
  accepts_nested_attributes_for :orders, reject_if: :all_blank, allow_destroy: true
29
29
 
30
- has_one :membership, inverse_of: :owner, as: :owner, class_name: 'Effective::Membership'
30
+ has_one :membership, inverse_of: :owner, as: :owner, class_name: 'Effective::Membership', dependent: :destroy
31
31
  accepts_nested_attributes_for :membership
32
32
 
33
- has_many :membership_histories, -> { Effective::MembershipHistory.sorted }, inverse_of: :owner, as: :owner, class_name: 'Effective::MembershipHistory'
33
+ has_many :membership_histories, -> { Effective::MembershipHistory.sorted }, inverse_of: :owner, as: :owner, class_name: 'Effective::MembershipHistory', dependent: :delete_all
34
34
  accepts_nested_attributes_for :membership_histories
35
35
 
36
36
  scope :members, -> { joins(:membership) }
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.2'
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.0
4
+ version: 0.9.2
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-10 00:00:00.000000000 Z
11
+ date: 2022-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails