Module: SingaporeCPFCalculator

Defined in:
lib/singapore_cpf_calculator.rb,
lib/singapore_cpf_calculator/version.rb,
lib/singapore_cpf_calculator/age_group.rb,
lib/singapore_cpf_calculator/year_2014.rb,
lib/singapore_cpf_calculator/year_2015.rb,
lib/singapore_cpf_calculator/year_2016.rb,
lib/singapore_cpf_calculator/before_spr.rb,
lib/singapore_cpf_calculator/spr_status.rb,
lib/singapore_cpf_calculator/year_common.rb,
lib/singapore_cpf_calculator/requirements.rb,
lib/singapore_cpf_calculator/year_2014/base.rb,
lib/singapore_cpf_calculator/year_2015/base.rb,
lib/singapore_cpf_calculator/year_2016/base.rb,
lib/singapore_cpf_calculator/base_calculator.rb,
lib/singapore_cpf_calculator/spr_1_fg_common.rb,
lib/singapore_cpf_calculator/spr_1_gg_common.rb,
lib/singapore_cpf_calculator/spr_2_fg_common.rb,
lib/singapore_cpf_calculator/spr_2_gg_common.rb,
lib/singapore_cpf_calculator/cpf_contribution.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_fg.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_gg.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_fg.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_gg.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_fg.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_gg.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_fg.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_gg.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_fg.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_gg.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_fg.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_gg.rb,
lib/singapore_cpf_calculator/citizen_or_spr_3_common.rb,
lib/singapore_cpf_calculator/residency_module_common.rb,
lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3.rb,
lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3.rb,
lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3.rb,
lib/singapore_cpf_calculator/null_contribution_calculator.rb,
lib/singapore_cpf_calculator/requirements/group_above_65_years.rb,
lib/singapore_cpf_calculator/year_2012_to_2015_aw_ceiling_module.rb,
lib/singapore_cpf_calculator/requirements/group_50_years_and_below.rb,
lib/singapore_cpf_calculator/requirements/group_55_years_and_below.rb,
lib/singapore_cpf_calculator/requirements/group_above_50_to_55_years.rb,
lib/singapore_cpf_calculator/requirements/group_above_55_to_60_years.rb,
lib/singapore_cpf_calculator/requirements/group_above_60_to_65_years.rb,
lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/citzen_or_spr3_base.rb,
lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/citizen_or_spr3_base.rb,
lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/citizen_or_spr3_base.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_fg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_gg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_fg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_gg/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_fg/age_55_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_fg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_fg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_gg/age_55_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_gg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_1_gg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_fg/age_55_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_fg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_fg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_gg/age_55_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_gg/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/spr_2_gg/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_65_up_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_to_55_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_55_below_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb,
lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb

Defined Under Namespace

Modules: BeforeSPR, CitizenOrSPR3Common, NullContributionCalculator, Requirements, ResidencyModuleCommon, SPR1FGCommon, SPR1GGCommon, SPR2FGCommon, SPR2GGCommon, Year2012To2015AwCeilingModule, Year2014, Year2015, Year2016, YearCommon Classes: AgeGroup, BaseCalculator, CPFContribution, SPRStatus

Constant Summary collapse

VERSION =
"1.3.4"

Class Method Summary collapse

Class Method Details

.calculate(date:, birthdate:, residency_status:, spr_start_date: nil, ordinary_wages:, additional_wages:, employee_contribution_type: nil, employer_contribution_type: nil, ytd_additional_wages: 0.0, ytd_ow_subject_to_cpf: 0.0, estimated_yearly_ow: 0.0) ⇒ CPFContribution

@example:

result = SingaporeCPFCalculator.calculate age: 32,
                                          date: Date.new(2014, 11, 15),
                                          residency_status: "permanent_resident",
                                          spr_start_date: Date.new(2014, 11, 15),
                                          ordinary_wages: 700.00,
                                          additional_wages: 252.00,
                                          employee_contribution_type: "full",
                                          employer_contribution_type: "full",
                                          ytd_additional_wages: 20_000,
                                          ytd_ow_subject_to_cpf: 60_000

result # => #<SingaporeCPFCalculator::CPFContribution ...>
result.employee # => 190.00
result.employer # => 153.00
result.total # => 343.00

Parameters:

  • date: (Date)

    relevant date when the CPF contribution is being calculated

  • birthdate: (Date)
  • residency_status: (String)
    “citizen”, “permanent_resident”
  • spr_start_date: (Date) (defaults to: nil)

    date when the employee became a Singapore permanent resident

  • employee_contribution_type: (String) (defaults to: nil)
    “full”, “graduated”
  • employer_contribution_type: (String) (defaults to: nil)
    “full”, “graduated”
  • ordinary_wages: (BigDecimal)

    Ordinary wages are wages due or granted in respect of employment and include allowances (e.g. food allowance and overtime payments) earned by an employee in the month and payable before the due date for payment of CPF contributions for that month.

  • additional_wages: (BigDecimal)

    Additional wages are wage supplements which are not granted wholly and exclusively for the month, such as annual bonus and leave pay. These and other incentive payments may be made at intervals of more than a month.

  • ytd_additional_wages: (BigDecimal) (defaults to: 0.0)

    Cumulative Additional Wages for the year (YTD)

  • ytd_ow_subject_to_cpf: (BigDecimal) (defaults to: 0.0)

    The Year to Date Ordinary Wages which have been subject to CPF.

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/singapore_cpf_calculator.rb', line 44

def calculate(date:,
              birthdate:,
              residency_status:,
              spr_start_date: nil,
              ordinary_wages:,
              additional_wages:,
              employee_contribution_type: nil,
              employer_contribution_type: nil,
              ytd_additional_wages: 0.0,
              ytd_ow_subject_to_cpf: 0.0,
              estimated_yearly_ow: 0.0)
  validate_params(date: date,
                  employee_contribution_type: employee_contribution_type,
                  employer_contribution_type: employer_contribution_type,
                  residency_status: residency_status,
                  spr_start_date: spr_start_date)

  module_for_date(date).
    module_for_residency(
      status: residency_status,
      spr_start_date: spr_start_date,
      current_date: date,
      employee_contribution_type: employee_contribution_type,
      employer_contribution_type: employer_contribution_type
    ).calculator_for(date, birthdate: birthdate).
    calculate ordinary_wages: ordinary_wages,
              additional_wages: additional_wages,
              ytd_additional_wages: ytd_additional_wages,
              ytd_ow_subject_to_cpf: ytd_ow_subject_to_cpf,
              estimated_yearly_ow: estimated_yearly_ow
end