Method: Effective::CpdRule#score

Defined in:
app/models/effective/cpd_rule.rb

#score(cpd_statement_activity:) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'app/models/effective/cpd_rule.rb', line 108

def score(cpd_statement_activity:)
  raise('cpd_cycles must match') unless cpd_statement_activity.cpd_statement.cpd_cycle_id == cpd_cycle_id
  raise('cpd_activities must match') unless cpd_statement_activity.cpd_activity_id == ruleable_id

  return cpd_statement_activity.carry_over if cpd_statement_activity.is_carry_over?

  # Statements can override the #round_amount method to perform their own
  # calculations.  For example, a statement may round to the nearest 0.5 or
  # to the nearest 0.25 or to the nearest 0.1.
  statement = cpd_statement_activity.cpd_statement
  amount = statement.round_amount(cpd_statement_activity.amount)
  amount2 = statement.round_amount(cpd_statement_activity.amount2)

  eval_equation(amount: amount, amount2: amount2)
end