Module: EffectiveMembershipsFeePayment

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/effective_memberships_fee_payment.rb

Overview

EffectiveMembershipsFeePayment

Mark your model with effective_memberships_fee_payment to get all the includes

Defined Under Namespace

Modules: Base, ClassMethods

Instance Method Summary collapse

Instance Method Details

#build_organization(params = {}) ⇒ Object



212
213
214
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 212

def build_organization(params = {})
  self.organization = EffectiveMemberships.Organization.new(params)
end

#cpd_completed_cpd_cyclesObject



256
257
258
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 256

def cpd_completed_cpd_cycles
  cpd_required_cpd_cycles.select { |cpd_cycle| user&.cpd_statement(cpd_cycle: cpd_cycle)&.completed? }
end

#cpd_required_cpd_cyclesObject



247
248
249
250
251
252
253
254
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 247

def cpd_required_cpd_cycles
  date =  || Time.zone.now

  [
    (EffectiveCpd.previous_cpd_cycle(date: date) if cpd_requirement.to_s.include?('previous')),
    (EffectiveCpd.current_cpd_cycle(date: date) if cpd_requirement.to_s.include?('current'))
  ].compact
end

#cpd_requirementObject

CPD Step



243
244
245
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 243

def cpd_requirement
  (category&.fee_payment_cpd_step_requirement.presence || EffectiveMemberships.Category.cpd_step_requirements.first)
end

#cpd_uncompleted_cpd_cyclesObject



260
261
262
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 260

def cpd_uncompleted_cpd_cycles
  cpd_required_cpd_cycles.reject { |cpd_cycle| user&.cpd_statement(cpd_cycle: cpd_cycle)&.completed? }
end

#done?Boolean

Returns:

  • (Boolean)


229
230
231
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 229

def done?
  
end

#in_progress?Boolean

Instance Methods

Returns:

  • (Boolean)


225
226
227
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 225

def in_progress?
  draft?
end

#individual?Boolean

Returns:

  • (Boolean)


216
217
218
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 216

def individual?
  !owner.kind_of?(EffectiveMemberships.Organization)
end

#organization?Boolean

Returns:

  • (Boolean)


220
221
222
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 220

def organization?
  owner.kind_of?(EffectiveMemberships.Organization)
end

#ownerObject



204
205
206
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 204

def owner
  organization || user
end

#owner_symbolObject



208
209
210
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 208

def owner_symbol
  organization? ? :organization : :user
end

#reset!Object



237
238
239
240
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 237

def reset!
  assign_attributes(wizard_steps: wizard_steps.slice(:start))
  save!
end

#select!Object



233
234
235
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 233

def select!
  reset!
end

#to_sObject



200
201
202
# File 'app/models/concerns/effective_memberships_fee_payment.rb', line 200

def to_s
  'Fee Payment'
end