Class: Cats::Core::BeneficiaryPlanItem

Inherits:
ApplicationRecord show all
Defined in:
app/models/cats/core/beneficiary_plan_item.rb

Instance Method Summary collapse

Instance Method Details

#psnp?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'app/models/cats/core/beneficiary_plan_item.rb', line 19

def psnp?
  return false unless plan_item

  plan_item.plan.program.code == "PSNP"
end

#validate_roundsObject



25
26
27
28
29
30
31
32
33
# File 'app/models/cats/core/beneficiary_plan_item.rb', line 25

def validate_rounds
  return unless rounds && rounds_served

  errors.add(:rounds, "should not be set for non PSNP plans.") unless psnp?

  errors.add(:rounds_served, "should not be set for non PSNP plans.") unless psnp?

  errors.add(:rounds, "cannot be lower than rounds served.") if rounds < rounds_served
end