SingaporeCPFCalculator

Gem Version Code Climate Test Coverage

Circle CI

SingaporeCPFCalculator is the gem PayrollHero.com created and use to calculate for Singapore's Central Provident Fund (CPF) contributions.

Support

Installation

Add this line to your application's Gemfile:

gem 'singapore_cpf_calculator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install singapore_cpf_calculator

Usage

Use SingaporeCPFCalculator.calculate to calculate for CPF contribution. The method return a SingaporeCPFCalculator::CPFContribution object responding to SingaporeCPFCalculator::CPFContribution#employee, SingaporeCPFCalculator::CPFContribution#employer and SingaporeCPFCalculator::CPFContribution#total.

  require "singapore_cpf_calculator"

  result = SingaporeCPFCalculator.calculate date: Date.new(2014, 11, 15),
                                            birthdate: Date.new(1982, 2, 18),
                                            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"

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

The following parameters needs to be specified:

  • date : current date when the CPF is being calculated for
  • birthdate : birthdate of the employee
  • residency_status : residency status of the employee
    • accepted values : "citizen", "permanent_resident"
  • spr_start_date : date when Singapore Permanent Residency (SPR) started
  • ordinary_wages :
  • additional_wages :
  • employee_contribution_type : type of rates to use for the employee's contribution
    • accepted values : "full", "graduated"
    • note: full rates is not supported if the employer's contribution type is graduated
  • employer_contribution_type : type of rates to use
    • accepted values : "full", "graduated" type of rates to use for the employer's contribution
    • note: graduated rates is not supported if the employee's contribution type is full

Contributing

  1. Fork it ( https://github.com/[my-github-username]/singapore_cpf_calculator/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request