Module: SingaporeCPFCalculator::YearCommon

Included in:
Year2014, Year2015, Year2016
Defined in:
lib/singapore_cpf_calculator/year_common.rb

Instance Method Summary collapse

Instance Method Details

#module_for_residency(status:, current_date:, spr_start_date:, employee_contribution_type:, employer_contribution_type:) ⇒ #residency_module

Parameters:

  • status: (String)
    “citizen”, “permanent_resident”, “foreigner”
  • current_date: (Date)

    current date used to determine permanent residency’s duration

  • spr_start_date: (Date)

    date when the permanent residency started

  • employee_contribution_type: (String)
    “full”, “graduated”
  • employer_contribution_type: (String)
    “full”, “graduated”

Returns:

  • (#residency_module)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/singapore_cpf_calculator/year_common.rb', line 11

def module_for_residency(
  status:,
  current_date:,
  spr_start_date:,
  employee_contribution_type:,
  employer_contribution_type:
)
  residency_modules.find { |mod|
    mod.applies_to? status: status,
                    current_date: current_date,
                    spr_start_date: spr_start_date,
                    employee_contribution_type: employee_contribution_type,
                    employer_contribution_type: employer_contribution_type
  } or raise ArgumentError, "could not find residency module"
end