Class: SingaporeCPFCalculator::AgeGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/singapore_cpf_calculator/age_group.rb

Overview

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.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_date, birthdate:, has_70_up:) ⇒ AgeGroup

Returns a new instance of AgeGroup.

Parameters:

  • current_date (Date)
  • birthdate: (Date)


28
29
30
31
32
# 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

Class Method Details

.get(current_date, birthdate:, has_70_up: false) ⇒ Symbol

Returns 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.

Parameters:

  • current_date (Date)
  • birthdate (Date)

Returns:

  • (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



21
22
23
# 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

Instance Method Details

#getSymbol

Returns 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.

Returns:

  • (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



43
44
45
46
47
48
49
50
51
# 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