Module: EffectiveCpdStatement
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/effective_cpd_statement.rb
Overview
EffectiveCpdStatement
Mark your owner model with effective_cpd_statement to get all the includes
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary
collapse
Instance Method Details
#carry_forward ⇒ Object
141
142
143
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 141
def carry_forward
cpd_statement_activities.sum { |activity| activity.carry_forward || BigDecimal(0) }.to_d
end
|
#completed? ⇒ Boolean
Also known as:
submitted?
128
129
130
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 128
def completed?
submitted_at.present?
end
|
#import!(date: nil) ⇒ Object
102
103
104
105
106
107
108
109
110
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 102
def import!(date: nil)
date ||= Time.zone.now
wizard_steps[:start] ||= date
wizard_steps[:activities] ||= date
cpd_statement_activities.each { |activity| activity.importing = true }
save!
end
|
#in_progress? ⇒ Boolean
124
125
126
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 124
def in_progress?
submitted_at.blank?
end
|
#score_per_category ⇒ Object
146
147
148
149
150
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 146
def score_per_category
@score_per_category ||= Hash.new(BigDecimal(0)).tap do |scores|
cpd_statement_activities.each { |activity| scores[activity.cpd_category_id] += activity.score.to_d }
end
end
|
#submit! ⇒ Object
This is the review step where they click Submit Ballot
113
114
115
116
117
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 113
def submit!
wizard_steps[:complete] ||= Time.zone.now
update!(submitted_at: Time.zone.now)
end
|
#target_score ⇒ Object
133
134
135
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 133
def target_score
user.cpd_target_score(cpd_cycle: cpd_cycle)
end
|
#target_score_required_to_submit? ⇒ Boolean
137
138
139
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 137
def target_score_required_to_submit?
user.cpd_target_score_required_to_submit?(cpd_cycle: cpd_cycle)
end
|
#to_s ⇒ Object
98
99
100
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 98
def to_s
cpd_cycle.present? ? "#{cpd_cycle} #{model_name.human}" : model_name.human
end
|
#unsubmit! ⇒ Object
Called by admin only. This is an exceptional action
120
121
122
|
# File 'app/models/concerns/effective_cpd_statement.rb', line 120
def unsubmit!
update!(wizard_steps: {}, submitted_at: nil, confirm_readonly: nil)
end
|