class SingaporeCPFCalculator::AgeGroup
The contribution rates in respect of an employee above 35, 50, 55, 60 or 65 years of age shall be applied from the first day of the month after the month of his 35th, 50th, 55th, 60th or 65th birthday.
Attributes
birthdate[R]
current_date[R]
has_70_up[R]
Public Class Methods
get(current_date, birthdate:, has_70_up: false)
click to toggle source
@param [Date] current_date
@param [Date] birthdate @return [Symbol] the symbol representation of the age group
- :group_50_years_and_below - :group_55_years_and_below - :group_above_50_to_55_years - :group_above_55_to_60_years - :group_above_60_to_65_years - :group_above_65_years - :group_above_65_to_70_years - :group_above_70_years
# File lib/singapore_cpf_calculator/age_group.rb, line 21 def get(current_date, birthdate:, has_70_up: false) new(current_date, birthdate: birthdate, has_70_up: has_70_up).get end
new(current_date, birthdate:, has_70_up:)
click to toggle source
@param [Date] current_date
@param [Date] birthdate:
# File lib/singapore_cpf_calculator/age_group.rb, line 28 def initialize(current_date, birthdate:, has_70_up:) @current_date = current_date @birthdate = birthdate @has_70_up = has_70_up end
Public Instance Methods
get()
click to toggle source
@return [Symbol] the symbol representation of the age group
- :group_50_years_and_below - :group_55_years_and_below - :group_above_50_to_55_years - :group_above_55_to_60_years - :group_above_60_to_65_years - :group_above_65_years - :group_above_65_to_70_years - :group_above_70_years
# File lib/singapore_cpf_calculator/age_group.rb, line 43 def get if current_date.year <= 2015 age_grouping_for_2015_and_earlier elsif current_date.year <= 2021 || !has_70_up age_grouping_for_2016_and_later else age_grouping_for_2022_and_later end end
Private Instance Methods
age()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 57 def age @age ||= effective_age end
age_grouping_for_2015_and_earlier()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 71 def age_grouping_for_2015_and_earlier case when age < 50 :group_50_years_and_below when 50 <= age && age < 55 :group_above_50_to_55_years when 55 <= age && age < 60 :group_above_55_to_60_years when 60 <= age && age < 65 :group_above_60_to_65_years else # 65 <= age :group_above_65_years end end
age_grouping_for_2016_and_later()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 86 def age_grouping_for_2016_and_later case when age < 55 :group_55_years_and_below when 55 <= age && age < 60 :group_above_55_to_60_years when 60 <= age && age < 65 :group_above_60_to_65_years else # 65 <= age :group_above_65_years end end
age_grouping_for_2022_and_later()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 99 def age_grouping_for_2022_and_later case when age < 55 :group_55_years_and_below when 55 <= age && age < 60 :group_above_55_to_60_years when 60 <= age && age < 65 :group_above_60_to_65_years when 65 <= age && age < 70 :group_above_65_to_70_years else # 70 <= age :group_above_70_years end end
effective_age()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 61 def effective_age age_by_year = current_date.year - birthdate.year if current_date.month > birthdate.month age_by_year else age_by_year - 1 end end