singapore_cpf_calculator 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +97 -0
  7. data/Rakefile +2 -0
  8. data/circle.yml +3 -0
  9. data/lib/singapore_cpf_calculator.rb +125 -0
  10. data/lib/singapore_cpf_calculator/age_group.rb +71 -0
  11. data/lib/singapore_cpf_calculator/base_calculator.rb +114 -0
  12. data/lib/singapore_cpf_calculator/before_spr.rb +36 -0
  13. data/lib/singapore_cpf_calculator/citizen_or_spr_3_common.rb +27 -0
  14. data/lib/singapore_cpf_calculator/cpf_contribution.rb +28 -0
  15. data/lib/singapore_cpf_calculator/null_contribution_calculator.rb +17 -0
  16. data/lib/singapore_cpf_calculator/requirements.rb +10 -0
  17. data/lib/singapore_cpf_calculator/requirements/group_50_years_and_below.rb +13 -0
  18. data/lib/singapore_cpf_calculator/requirements/group_above_50_to_55_years.rb +13 -0
  19. data/lib/singapore_cpf_calculator/requirements/group_above_55_to_60_years.rb +13 -0
  20. data/lib/singapore_cpf_calculator/requirements/group_above_60_to_65_years.rb +13 -0
  21. data/lib/singapore_cpf_calculator/requirements/group_above_65_years.rb +13 -0
  22. data/lib/singapore_cpf_calculator/residency_module_common.rb +12 -0
  23. data/lib/singapore_cpf_calculator/spr_1_fg_common.rb +26 -0
  24. data/lib/singapore_cpf_calculator/spr_1_gg_common.rb +26 -0
  25. data/lib/singapore_cpf_calculator/spr_2_fg_common.rb +26 -0
  26. data/lib/singapore_cpf_calculator/spr_2_gg_common.rb +26 -0
  27. data/lib/singapore_cpf_calculator/spr_status.rb +52 -0
  28. data/lib/singapore_cpf_calculator/version.rb +3 -0
  29. data/lib/singapore_cpf_calculator/year_2014.rb +37 -0
  30. data/lib/singapore_cpf_calculator/year_2014/base.rb +17 -0
  31. data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3.rb +35 -0
  32. data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_below_contribution_calculator.rb +32 -0
  33. data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_to_55_contribution_calculator.rb +33 -0
  34. data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb +32 -0
  35. data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb +32 -0
  36. data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_65_up_contribution_calculator.rb +32 -0
  37. data/lib/singapore_cpf_calculator/year_2014/spr_1_fg.rb +36 -0
  38. data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_below_contribution_calculator.rb +33 -0
  39. data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_to_55_contribution_calculator.rb +32 -0
  40. data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_55_to_60_contribution_calculator.rb +32 -0
  41. data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_60_to_65_contribution_calculator.rb +32 -0
  42. data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_65_up_contribution_calculator.rb +32 -0
  43. data/lib/singapore_cpf_calculator/year_2014/spr_1_gg.rb +36 -0
  44. data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_below_contribution_calculator.rb +32 -0
  45. data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_to_55_contribution_calculator.rb +14 -0
  46. data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_55_to_60_contribution_calculator.rb +14 -0
  47. data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_60_to_65_contribution_calculator.rb +32 -0
  48. data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_65_up_contribution_calculator.rb +32 -0
  49. data/lib/singapore_cpf_calculator/year_2014/spr_2_fg.rb +36 -0
  50. data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_below_contribution_calculator.rb +32 -0
  51. data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_to_55_contribution_calculator.rb +32 -0
  52. data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_55_to_60_contribution_calculator.rb +32 -0
  53. data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_60_to_65_contribution_calculator.rb +32 -0
  54. data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_65_up_contribution_calculator.rb +32 -0
  55. data/lib/singapore_cpf_calculator/year_2014/spr_2_gg.rb +36 -0
  56. data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_below_contribution_calculator.rb +32 -0
  57. data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_to_55_contribution_calculator.rb +14 -0
  58. data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_55_to_60_contribution_calculator.rb +32 -0
  59. data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_60_to_65_contribution_calculator.rb +32 -0
  60. data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_65_up_contribution_calculator.rb +32 -0
  61. data/lib/singapore_cpf_calculator/year_2015.rb +38 -0
  62. data/lib/singapore_cpf_calculator/year_2015/base.rb +17 -0
  63. data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3.rb +35 -0
  64. data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_below_contribution_calculator.rb +32 -0
  65. data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_to_55_contribution_calculator.rb +32 -0
  66. data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb +32 -0
  67. data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb +32 -0
  68. data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_65_up_contribution_calculator.rb +32 -0
  69. data/lib/singapore_cpf_calculator/year_2015/spr_1_fg.rb +37 -0
  70. data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_below_contribution_calculator.rb +32 -0
  71. data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_to_55_contribution_calculator.rb +32 -0
  72. data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_55_to_60_contribution_calculator.rb +32 -0
  73. data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_60_to_65_contribution_calculator.rb +32 -0
  74. data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_65_up_contribution_calculator.rb +32 -0
  75. data/lib/singapore_cpf_calculator/year_2015/spr_1_gg.rb +36 -0
  76. data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_below_contribution_calculator.rb +32 -0
  77. data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_to_55_contribution_calculator.rb +14 -0
  78. data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_55_to_60_contribution_calculator.rb +14 -0
  79. data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_60_to_65_contribution_calculator.rb +32 -0
  80. data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_65_up_contribution_calculator.rb +14 -0
  81. data/lib/singapore_cpf_calculator/year_2015/spr_2_fg.rb +36 -0
  82. data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_below_contribution_calculator.rb +32 -0
  83. data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_to_55_contribution_calculator.rb +32 -0
  84. data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_55_to_60_contribution_calculator.rb +32 -0
  85. data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_60_to_65_contribution_calculator.rb +32 -0
  86. data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_65_up_contribution_calculator.rb +32 -0
  87. data/lib/singapore_cpf_calculator/year_2015/spr_2_gg.rb +36 -0
  88. data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_below_contribution_calculator.rb +32 -0
  89. data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_to_55_contribution_calculator.rb +14 -0
  90. data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_55_to_60_contribution_calculator.rb +32 -0
  91. data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_60_to_65_contribution_calculator.rb +32 -0
  92. data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_65_up_contribution_calculator.rb +32 -0
  93. data/lib/singapore_cpf_calculator/year_common.rb +29 -0
  94. data/singapore_cpf_calculator.gemspec +27 -0
  95. data/spec/acceptance/company_a.csv +1365 -0
  96. data/spec/acceptance/company_a_spec.rb +36 -0
  97. data/spec/singapore_cpf_calculator/age_group_spec.rb +65 -0
  98. data/spec/singapore_cpf_calculator/spr_status_spec.rb +48 -0
  99. data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_below_contribution_calculator_spec.rb +68 -0
  100. data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_to_55_contribution_calculator_spec.rb +68 -0
  101. data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +68 -0
  102. data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +68 -0
  103. data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_65_up_contribution_calculator_spec.rb +68 -0
  104. data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3_spec.rb +176 -0
  105. data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_below_contribution_calculator_spec.rb +73 -0
  106. data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_to_55_contribution_calculator_spec.rb +73 -0
  107. data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +73 -0
  108. data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +73 -0
  109. data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_65_up_contribution_calculator_spec.rb +73 -0
  110. data/spec/singapore_cpf_calculator/year_2014/spr_1_fg_spec.rb +176 -0
  111. data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_below_contribution_calculator_spec.rb +73 -0
  112. data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_to_55_contribution_calculator_spec.rb +73 -0
  113. data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_55_to_60_contribution_calculator_spec.rb +73 -0
  114. data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_60_to_65_contribution_calculator_spec.rb +73 -0
  115. data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_65_up_contribution_calculator_spec.rb +73 -0
  116. data/spec/singapore_cpf_calculator/year_2014/spr_1_gg_spec.rb +176 -0
  117. data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_below_contribution_calculator_spec.rb +73 -0
  118. data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_to_55_contribution_calculator_spec.rb +73 -0
  119. data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_55_to_60_contribution_calculator_spec.rb +73 -0
  120. data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +73 -0
  121. data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_65_up_contribution_calculator_spec.rb +73 -0
  122. data/spec/singapore_cpf_calculator/year_2014/spr_2_fg_spec.rb +176 -0
  123. data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_below_contribution_calculator_spec.rb +73 -0
  124. data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_to_55_contribution_calculator_spec.rb +73 -0
  125. data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_55_to_60_contribution_calculator_spec.rb +73 -0
  126. data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_60_to_65_contribution_calculator_spec.rb +73 -0
  127. data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_65_up_contribution_calculator_spec.rb +73 -0
  128. data/spec/singapore_cpf_calculator/year_2014/spr_2_gg_spec.rb +176 -0
  129. data/spec/singapore_cpf_calculator/year_2014_spec.rb +183 -0
  130. data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_below_contribution_calculator_spec.rb +63 -0
  131. data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_to_55_contribution_calculator_spec.rb +63 -0
  132. data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +63 -0
  133. data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +63 -0
  134. data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_65_up_contribution_calculator_spec.rb +63 -0
  135. data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3_spec.rb +176 -0
  136. data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_below_contribution_calculator_spec.rb +63 -0
  137. data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_to_55_contribution_calculator_spec.rb +63 -0
  138. data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  139. data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  140. data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_65_up_contribution_calculator_spec.rb +63 -0
  141. data/spec/singapore_cpf_calculator/year_2015/spr_1_fg_spec.rb +176 -0
  142. data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_below_contribution_calculator_spec.rb +63 -0
  143. data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_to_55_contribution_calculator_spec.rb +63 -0
  144. data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  145. data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  146. data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_65_up_contribution_calculator_spec.rb +63 -0
  147. data/spec/singapore_cpf_calculator/year_2015/spr_1_gg_spec.rb +176 -0
  148. data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_below_contribution_calculator_spec.rb +63 -0
  149. data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_to_55_contribution_calculator_spec.rb +63 -0
  150. data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  151. data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  152. data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_65_up_contribution_calculator_spec.rb +63 -0
  153. data/spec/singapore_cpf_calculator/year_2015/spr_2_fg_spec.rb +176 -0
  154. data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_below_contribution_calculator_spec.rb +63 -0
  155. data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_to_55_contribution_calculator_spec.rb +63 -0
  156. data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  157. data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  158. data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_65_up_contribution_calculator_spec.rb +63 -0
  159. data/spec/singapore_cpf_calculator/year_2015/spr_2_gg_spec.rb +176 -0
  160. data/spec/singapore_cpf_calculator/year_2015_spec.rb +187 -0
  161. data/spec/singapore_cpf_calculator_spec.rb +48 -0
  162. data/spec/spec_helper.rb +115 -0
  163. metadata +344 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c10a9da895045667814bc945fe76c308fa58f61a
4
+ data.tar.gz: 0c7815f181658ee0511bdf631822ef6c4871164f
5
+ SHA512:
6
+ metadata.gz: d7bd99c5b7bdd11616e9773158838aa03f293e61a3d5555165185702ac423ddb1a4fa5bcc48ff4fc86dd7091f370c698f3e75aaf4f0c31fb2f708d66486fa363
7
+ data.tar.gz: 976dec1337b458a379b4478b3db71e3ca7451ecdf1d5998db3bfc47769adfed4558036f87f1fbe0d7d1933f9e8cd951e15f87096693af7ed193a75602289f865
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in singapore_cpf_calculator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014, PayrollHero PTE. Ltd. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that
4
+ the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7
+ following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
+ following disclaimer in the documentation and/or other materials provided with the distribution.
11
+
12
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or
13
+ promote products derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
18
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
21
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
22
+ DAMAGE.
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # SingaporeCPFCalculator
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/singapore_cpf_calculator.svg)](http://badge.fury.io/rb/singapore_cpf_calculator)
4
+ [![Code Climate](https://codeclimate.com/github/payrollhero/singapore_cpf_calculator/badges/gpa.svg)](https://codeclimate.com/github/payrollhero/singapore_cpf_calculator)
5
+ [![Test Coverage](https://codeclimate.com/github/payrollhero/singapore_cpf_calculator/badges/coverage.svg)](https://codeclimate.com/github/payrollhero/singapore_cpf_calculator)
6
+
7
+ [![Circle CI](https://circleci.com/gh/payrollhero/singapore_cpf_calculator.png?style=badge)](https://circleci.com/gh/payrollhero/singapore_cpf_calculator)
8
+
9
+ `SingaporeCPFCalculator` is the gem PayrollHero.com created and use to calculate for Singapore's
10
+ Central Provident Fund (CPF) contributions.
11
+
12
+ ## Support
13
+
14
+ * [Year 2015](http://mycpf.cpf.gov.sg/NR/rdonlyres/9F38419D-1342-4426-820E-32BA8FDE5C6D/0/CPFContributionandAllocationRatesfrom1January2015.pdf)
15
+ * Singapore Citizens or Singapore Permanent Residents (3rd Year Onwards)
16
+ * Singapore Permanent Residents (SPRs) during 1st Year of SPR Status
17
+ * Graduated Employer & Employee (G/G) Contribution Rate
18
+ * Full Employer & Graduated Employee (F/G) Contribution Rate
19
+ * Singapore Permanent Residents (SPRs) during 2nd Year of SPR Status
20
+ * Graduated Employer & Employee (G/G) Contribution Rate
21
+ * Full Employer & Graduated Employee (F/G) Contribution Rate
22
+ * Year 2014
23
+ * [Singapore Citizens or Singapore Permanent Residents (3rd Year Onwards)](http://mycpf.cpf.gov.sg/NR/rdonlyres/B169395E-335C-479C-AB6E-74BA5FBEC6F0/0/CPFconratetable_from1Jan2014_forPTEandNPEN_SC.pdf)
24
+ * Singapore Permanent Residents (SPRs) during 2nd Year of SPR Status
25
+ * [Graduated Employer & Employee (G/G)](http://mycpf.cpf.gov.sg/NR/rdonlyres/E49C4AFE-8048-4A49-8672-B59D1D34A90B/0/CPFconratetable_from1Jan2014_forPTEandNPEN_2GG.pdf)
26
+ * [Full Employer & Graduated Employee (F/G)](http://mycpf.cpf.gov.sg/NR/rdonlyres/598CEDE2-61D0-44CE-9E96-AAD2FFCE4449/0/CPFconratetable_from1Jan2014_forPTEandNPEN_2FG.pdf)
27
+ * Singapore Permanent Residents (SPRs) during 1st Year of SPR Status
28
+ * [Graduated Employer & Employee (G/G)](http://mycpf.cpf.gov.sg/NR/rdonlyres/90D2E0D8-9922-4CAD-87A6-94D6893954E8/0/CPFconratetable_from1Jan2014_forPTEandNPEN_1GG.pdf)
29
+ * [Full Employer & Graduated Employee (F/G)](http://mycpf.cpf.gov.sg/NR/rdonlyres/32EB83C4-9472-4D25-93D6-D760F486DBE3/0/CPFconratetable_from1Jan2014_forPTEandNPEN_1FG.pdf)
30
+
31
+ ## Installation
32
+
33
+ Add this line to your application's Gemfile:
34
+
35
+ gem 'singapore_cpf_calculator'
36
+
37
+ And then execute:
38
+
39
+ $ bundle
40
+
41
+ Or install it yourself as:
42
+
43
+ $ gem install singapore_cpf_calculator
44
+
45
+ ## Usage
46
+
47
+ Use {SingaporeCPFCalculator.calculate} to calculate for CPF contribution. The method return a
48
+ {SingaporeCPFCalculator::CPFContribution} object responding to {SingaporeCPFCalculator::CPFContribution#employee},
49
+ {SingaporeCPFCalculator::CPFContribution#employer} and {SingaporeCPFCalculator::CPFContribution#total}.
50
+
51
+ ```ruby
52
+ require "singapore_cpf_calculator"
53
+
54
+ result = SingaporeCPFCalculator.calculate date: Date.new(2014, 11, 15),
55
+ birthdate: Date.new(1982, 2, 18),
56
+ residency_status: "permanent_resident",
57
+ spr_start_date: Date.new(2014, 11, 15),
58
+ ordinary_wages: 700.00,
59
+ additional_wages: 252.00,
60
+ employee_contribution_type: "full",
61
+ employer_contribution_type: "full"
62
+
63
+ result # => #<SingaporeCPFCalculator::CPFContribution ...>
64
+ result.employee # => 190.00
65
+ result.employer # => 153.00
66
+ result.total # => 343.00
67
+ ```
68
+
69
+ The following parameters needs to be specified:
70
+
71
+ * **date** : current date when the CPF is being calculated for
72
+ * **birthdate** : birthdate of the employee
73
+ * **residency\_status** : residency status of the employee
74
+ * accepted values : `"citizen"`, `"permanent_resident"`
75
+ * **spr\_start\_date** : date when Singapore Permanent Residency (SPR) started
76
+ * notes:
77
+ * this affects how the employee is classified into SPR1, SPR2 or SPR3
78
+ * required if the `residency_status` is `permanent_resident`
79
+ * see: [Year of Singapore Permanent Resident (SPR) Status](http://mycpf.cpf.gov.sg/NR/exeres/3D0D66F9-0085-4FD5-9CB5-35B55C0ADA53,frameless.htm)
80
+ * **ordinary_wages** :
81
+ * see : [ordinary wages definition](http://mycpf.cpf.gov.sg/NR/exeres/24537890-6D8E-495E-80D5-E5EFEFCA1905,frameless.htm)
82
+ * **additional_wages** :
83
+ * see : [additional wages definition](http://mycpf.cpf.gov.sg/Employers/Employers_Guide_to_CPF/Glossary/Glossary_Additional_Wages.htm)
84
+ * **employee\_contribution\_type** : type of rates to use for the employee's contribution
85
+ * accepted values : `"full"`, `"graduated"`
86
+ * note: *full* rates is not supported if the employer's contribution type is *graduated*
87
+ * **employer\_contribution\_type** : type of rates to use
88
+ * accepted values : `"full"`, `"graduated"` type of rates to use for the employer's contribution
89
+ * note: *graduated* rates is not supported if the employee's contribution type is *full*
90
+
91
+ ## Contributing
92
+
93
+ 1. Fork it ( https://github.com/[my-github-username]/singapore_cpf_calculator/fork )
94
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
95
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
96
+ 4. Push to the branch (`git push origin my-new-feature`)
97
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/circle.yml ADDED
@@ -0,0 +1,3 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.1.2
@@ -0,0 +1,125 @@
1
+ require "singapore_cpf_calculator/version"
2
+ require "active_support/all"
3
+
4
+ module SingaporeCPFCalculator
5
+
6
+ class << self
7
+ # @example:
8
+ # result = SingaporeCPFCalculator.calculate age: 32,
9
+ # date: Date.new(2014, 11, 15),
10
+ # residency_status: "permanent_resident",
11
+ # spr_start_date: Date.new(2014, 11, 15),
12
+ # ordinary_wages: 700.00,
13
+ # additional_wages: 252.00,
14
+ # employee_contribution_type: "full",
15
+ # employer_contribution_type: "full"
16
+ #
17
+ # result # => #<SingaporeCPFCalculator::CPFContribution ...>
18
+ # result.employee # => 190.00
19
+ # result.employer # => 153.00
20
+ # result.total # => 343.00
21
+ #
22
+ #
23
+ # @param [Date] date: relevant date when the CPF contribution is being calculated
24
+ # @param [Date] birthdate:
25
+ # @param [String] residency_status: ["citizen", "permanent_resident"]
26
+ # @param [Date] spr_start_date: date when the employee became a Singapore permanent resident
27
+ # @param [String] employee_contribution_type: ["full", "graduated"]
28
+ # @param [String] employer_contribution_type: ["full", "graduated"]
29
+ # @param [BigDecimal] ordinary_wages:
30
+ # Ordinary wages are wages due or granted in respect of employment and include allowances (e.g.
31
+ # food allowance and overtime payments) earned by an employee in the month and payable before
32
+ # the due date for payment of CPF contributions for that month.
33
+ # @param [BigDecimal] additional_wages:
34
+ # Additional wages are wage supplements which are not granted wholly and exclusively for the
35
+ # month, such as annual bonus and leave pay. These and other incentive payments may be made at
36
+ # intervals of more than a month.
37
+ #
38
+ # @return [CPFContribution]
39
+ def calculate(
40
+ date:,
41
+ birthdate:,
42
+ residency_status:,
43
+ spr_start_date: nil,
44
+ ordinary_wages:,
45
+ additional_wages:,
46
+ employee_contribution_type: nil,
47
+ employer_contribution_type: nil
48
+ )
49
+ validate_params date: date,
50
+ employee_contribution_type: employee_contribution_type,
51
+ employer_contribution_type: employer_contribution_type,
52
+ residency_status: residency_status,
53
+ spr_start_date: spr_start_date
54
+
55
+ module_for_date(date).
56
+ module_for_residency(
57
+ status: residency_status,
58
+ spr_start_date: spr_start_date,
59
+ current_date: date,
60
+ employee_contribution_type: employee_contribution_type,
61
+ employer_contribution_type: employer_contribution_type
62
+ ).calculator_for(date, birthdate: birthdate).
63
+ calculate ordinary_wages: ordinary_wages, additional_wages: additional_wages
64
+ end
65
+
66
+ private
67
+
68
+ def validate_params(
69
+ date:,
70
+ employee_contribution_type:,
71
+ employer_contribution_type:,
72
+ residency_status:,
73
+ spr_start_date:
74
+ )
75
+ if residency_status == "permanent_resident"
76
+ raise ArgumentError, "spr_start_date: must be set" if spr_start_date.nil?
77
+ if contribution_types_required?(date, spr_start_date)
78
+ if employee_contribution_type.nil?
79
+ raise ArgumentError, "employee_contribution_type: must be set"
80
+ end
81
+ if employer_contribution_type.nil?
82
+ raise ArgumentError, "employer_contribution_type: must be set"
83
+ end
84
+ end
85
+ end
86
+
87
+ unless ["citizen", "permanent_resident"].include? residency_status
88
+ raise ArgumentError, "unsupported residency status: #{ residency_status }"
89
+ end
90
+ end
91
+
92
+ def contribution_types_required?(date, spr_start_date)
93
+ date <= (spr_start_date + 2.years)
94
+ end
95
+
96
+ def module_for_date(date)
97
+ date_modules.find { |mod| mod.applies_to? date } or
98
+ raise ArgumentError, "could not find date module for #{ date }"
99
+ end
100
+
101
+ def date_modules
102
+ [
103
+ Year2014,
104
+ Year2015,
105
+ ]
106
+ end
107
+ end
108
+
109
+ end
110
+
111
+ require_relative "singapore_cpf_calculator/cpf_contribution"
112
+ require_relative "singapore_cpf_calculator/base_calculator"
113
+ require_relative "singapore_cpf_calculator/before_spr"
114
+ require_relative "singapore_cpf_calculator/age_group"
115
+ require_relative "singapore_cpf_calculator/spr_status"
116
+ require_relative "singapore_cpf_calculator/requirements"
117
+ require_relative "singapore_cpf_calculator/year_common"
118
+ require_relative "singapore_cpf_calculator/residency_module_common"
119
+ require_relative "singapore_cpf_calculator/citizen_or_spr_3_common"
120
+ require_relative "singapore_cpf_calculator/spr_1_fg_common"
121
+ require_relative "singapore_cpf_calculator/spr_1_gg_common"
122
+ require_relative "singapore_cpf_calculator/spr_2_fg_common"
123
+ require_relative "singapore_cpf_calculator/spr_2_gg_common"
124
+ require_relative "singapore_cpf_calculator/year_2014"
125
+ require_relative "singapore_cpf_calculator/year_2015"
@@ -0,0 +1,71 @@
1
+ module SingaporeCPFCalculator
2
+
3
+ # The contribution rates in respect of an employee above 35, 50, 55, 60 or 65 years of age
4
+ # shall be applied from the first day of the month after the month of his 35th, 50th, 55th,
5
+ # 60th or 65th birthday.
6
+ class AgeGroup
7
+
8
+ class << self
9
+
10
+ # @param [Date] current_date
11
+ # @param [Date] birthdate
12
+ # @return [Symbol] the symbol representation of the age group
13
+ # - :group_50_years_and_below
14
+ # - :group_above_50_to_55_years
15
+ # - :group_above_55_to_60_years
16
+ # - :group_above_60_to_65_years
17
+ # - :group_above_65_years
18
+ def get(current_date, birthdate:)
19
+ new(current_date, birthdate: birthdate).get
20
+ end
21
+ end
22
+
23
+ # @param [Date] current_date
24
+ # @param [Date] birthdate:
25
+ def initialize(current_date, birthdate:)
26
+ @current_date = current_date
27
+ @birthdate = birthdate
28
+ end
29
+
30
+ # @return [Symbol] the symbol representation of the age group
31
+ # - :group_50_years_and_below
32
+ # - :group_above_50_to_55_years
33
+ # - :group_above_55_to_60_years
34
+ # - :group_above_60_to_65_years
35
+ # - :group_above_65_years
36
+ def get
37
+ case
38
+ when age < 50
39
+ :group_50_years_and_below
40
+ when 50 <= age && age < 55
41
+ :group_above_50_to_55_years
42
+ when 55 <= age && age < 60
43
+ :group_above_55_to_60_years
44
+ when 60 <= age && age < 65
45
+ :group_above_60_to_65_years
46
+ else # 65 <= age
47
+ :group_above_65_years
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ attr_reader :current_date, :birthdate
54
+
55
+ def age
56
+ @age ||= effective_age
57
+ end
58
+
59
+ def effective_age
60
+ age_by_year = current_date.year - birthdate.year
61
+
62
+ if current_date.month > birthdate.month
63
+ age_by_year
64
+ else
65
+ age_by_year - 1
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ end
@@ -0,0 +1,114 @@
1
+ module SingaporeCPFCalculator
2
+ # Base class for CPF calculators.
3
+ class BaseCalculator
4
+
5
+ class << self
6
+ # @param [Fixnum] age
7
+ # @return [true, false] returns true if the calculator applies to the employee's age.
8
+ def applies_to?(date, birthdate:)
9
+ AgeGroup.get(date, birthdate: birthdate) == required_age_group
10
+ end
11
+
12
+ # @param [BigDecimal] ordinary_wages:
13
+ # Ordinary wages are wages due or granted in respect of employment and include allowances (e.g.
14
+ # food allowance and overtime payments) earned by an employee in the month and payable before
15
+ # the due date for payment of CPF contributions for that month.
16
+ # @param [BigDecimal] additional_wages:
17
+ # Additional wages are wage supplements which are not granted wholly and exclusively for the
18
+ # month, such as annual bonus and leave pay. These and other incentive payments may be made at
19
+ # intervals of more than a month.
20
+ #
21
+ # @return [Hash] returns the total, employee, employer amounts for the CPF contribution
22
+ def calculate(ordinary_wages:, additional_wages:)
23
+ new(ordinary_wages: ordinary_wages, additional_wages: additional_wages).calculate
24
+ end
25
+
26
+ private
27
+
28
+ def required_age_group
29
+ raise NotImplementedError, "sub classes needs to implement .required_age_group"
30
+ end
31
+ end
32
+
33
+ def initialize(ordinary_wages:, additional_wages:)
34
+ @ordinary_wages = ordinary_wages
35
+ @additional_wages = additional_wages
36
+ end
37
+
38
+ # @return [Hash] returns the total, employee, employer amounts for the CPF contribution
39
+ def calculate
40
+ CPFContribution.new total: total_contribution,
41
+ employee: employee_contribution
42
+ end
43
+
44
+ private
45
+
46
+ attr_reader :ordinary_wages, :additional_wages
47
+
48
+ def total_contribution
49
+ @total_contribution ||= calculated_total_contribution.round(0, :half_up)
50
+ end
51
+
52
+ def employee_contribution
53
+ @employee_contribution ||= calculated_employee_contribution.round(0, :truncate)
54
+ end
55
+
56
+ def employer_contribution
57
+ @employer_contribution ||= total_contribution - employee_contribution
58
+ end
59
+
60
+ def total_wages
61
+ ordinary_wages + additional_wages
62
+ end
63
+
64
+ def calculated_total_contribution
65
+ case
66
+ when total_wages <= d("50.00")
67
+ d("0.0")
68
+ when total_wages <= d("500.00")
69
+ d(tc_rate_1) * total_wages
70
+ when total_wages < d("750.0000")
71
+ (d(tc_rate_1) * total_wages) + (d(adjustment_rate) * (total_wages - d("500.00")))
72
+ else # >= $750
73
+ (d(tc_rate_2) * capped_ordinary_wages) + (d(tc_rate_2) * additional_wages)
74
+ end
75
+ end
76
+
77
+ def calculated_employee_contribution
78
+ case
79
+ when total_wages < d("500.0000")
80
+ d("0.0")
81
+ when total_wages < d("750.0000")
82
+ (d(adjustment_rate) * (total_wages - d("500.00")))
83
+ else # >= $750
84
+ (d(ec_rate) * capped_ordinary_wages) + (d(ec_rate) * additional_wages)
85
+ end
86
+ end
87
+
88
+ def tc_rate_1
89
+ raise NotImplementedError, "sub classes needs to implement #tc_rate_1"
90
+ end
91
+
92
+ def tc_rate_2
93
+ raise NotImplementedError, "sub classes needs to implement #tc_rate_2"
94
+ end
95
+
96
+ def ec_rate
97
+ raise NotImplementedError, "sub classes needs to implement #ec_rate"
98
+ end
99
+
100
+ def adjustment_rate
101
+ raise NotImplementedError, "sub classes needs to implement #adjustment_rate"
102
+ end
103
+
104
+ def capped_ordinary_wages
105
+ raise NotImplementedError, "sub classes needs to implement #capped_ordinary_wages"
106
+ end
107
+
108
+ # precision helper
109
+ def d(val)
110
+ BigDecimal.new val
111
+ end
112
+
113
+ end
114
+ end