singapore_sdl_calculator 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 58e7fc58f667b6da6fd9342197dcb26515f628f2
4
+ data.tar.gz: 58e08f2d39c684aa0c12082f98d40ed75f9222fb
5
+ SHA512:
6
+ metadata.gz: c32ed772279529fa1a171b0be25822584ee8bccc23462a4189c80cb4670735fb08df2d285c651f6d4d4f297c0a008ecbb827e929e882aae13b9e6d71bb4b1161
7
+ data.tar.gz: 5628193ab2b3f3b58b971c4096a2e07b0025a03f35d6168e0836bbecb89adb067afbb60733dafeb689e07f5bbcfdc8e4ea07c4ef77d1674d4710c7892df70159
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ 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_sdl_calculator.gemspec
4
+ gemspec
@@ -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.
@@ -0,0 +1,43 @@
1
+ # SingaporeSDLCalculator
2
+
3
+ [![Code Climate](https://codeclimate.com/repos/549259c669568035d2001b40/badges/ed0a64be8baa03d50974/gpa.svg)](https://codeclimate.com/repos/549259c669568035d2001b40/feed)
4
+ [![Test Coverage](https://codeclimate.com/repos/549259c669568035d2001b40/badges/ed0a64be8baa03d50974/coverage.svg)](https://codeclimate.com/repos/549259c669568035d2001b40/feed)
5
+
6
+ [![Circle CI](https://circleci.com/gh/payrollhero/singapore_sdl_calculator.svg?style=svg)](https://circleci.com/gh/payrollhero/singapore_sdl_calculator)
7
+
8
+ `SingaporeSDLCalculator` is the gem PayrollHero.com created and use to calculate for Singapore's Skills Development Levy (SDL) contributions.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'singapore_sdl_calculator'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install singapore_sdl_calculator
25
+
26
+ ## Usage
27
+
28
+ Remuneration is any wage, salary, commission, bonus, leave pay, overtime pay, allowance (e.g. housing) and other payments in cash.
29
+
30
+ ```ruby
31
+ require 'singapore_sdl_calculator'
32
+
33
+ result = SingaporeSDLCalculator.calculate(remuneration: 500.50)
34
+ result # => 2.00
35
+ ```
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it ( https://github.com/[my-github-username]/singapore_sdl_calculator/fork )
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,3 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.1.2
@@ -0,0 +1,38 @@
1
+ require 'singapore_sdl_calculator/version'
2
+ require 'bigdecimal'
3
+
4
+ module SingaporeSDLCalculator
5
+
6
+ class << self
7
+
8
+ def calculate(remuneration:)
9
+ determine_contribution_for(remuneration)
10
+ end
11
+
12
+ private
13
+
14
+ def determine_contribution_for(amount)
15
+ bounded(amount * levy_rate)
16
+ end
17
+
18
+ def levy_rate
19
+ BigDecimal "0.0025"
20
+ end
21
+
22
+ def minimum_levy_rate
23
+ BigDecimal "2.00"
24
+ end
25
+
26
+ def maximum_levy_rate
27
+ BigDecimal "11.25"
28
+ end
29
+
30
+ # For any value within the bounds it returns the original value. Otherwise returns the lower limit or upper limit
31
+ # depending on which limit is closer.
32
+ def bounded(rate)
33
+ [[rate, maximum_levy_rate].min, minimum_levy_rate].max
34
+ end
35
+
36
+ end
37
+ end
38
+
@@ -0,0 +1,3 @@
1
+ module SingaporeSDLCalculator
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'singapore_sdl_calculator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "singapore_sdl_calculator"
8
+ spec.version = SingaporeSDLCalculator::VERSION
9
+ spec.authors = ["Vincent Paca", "Ronald Maravilla"]
10
+ spec.email = ["vpaca@payrollhero.com", "rmaravilla@payrollhero.com"]
11
+ spec.summary = "Calculator for Singapore Skill Development Levy"
12
+ spec.description = "Calculates for the employer contributions for the Skill Development Levy Act contribution per employee."
13
+ spec.homepage = "https://github.com/payrollhero/singapore_sdl_calculator"
14
+ spec.license = "BSD-3-Clause"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "codeclimate-test-reporter"
25
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeSDLCalculator do
4
+
5
+ subject(:calculator) { described_class }
6
+
7
+ describe '#calculate' do
8
+ let(:result) {
9
+ calculator.calculate(remuneration: remuneration)
10
+ }
11
+
12
+ describe "Employee's total remuneration for the month is $799.99" do
13
+ let(:remuneration) { 799.99 }
14
+ it { expect(result).to eq 2.00 }
15
+ end
16
+
17
+ describe "Employee's total remuneration for the month is $800.00" do
18
+ let(:remuneration) { 800.00 }
19
+ it { expect(result).to eq 2.00 }
20
+ end
21
+
22
+ describe "Employee's total remuneration for the month is $800.01" do
23
+ let(:remuneration) { 800.01 }
24
+ it { expect(result).to eq 2.000025 }
25
+ end
26
+
27
+ describe "Employee's total remuneration for the month is $4,499.99" do
28
+ let(:remuneration) { 4_499.99 }
29
+ it { expect(result).to eq 11.249975 }
30
+ end
31
+
32
+ describe "Employee's total remuneration for the month is $4,500.00" do
33
+ let(:remuneration) { 4_500.00 }
34
+ it { expect(result).to eq 11.25 }
35
+ end
36
+
37
+ describe "Employee's total remuneration for the month is $4,500.01" do
38
+ let(:remuneration) { 4_500.01 }
39
+ it { expect(result).to eq 11.25 }
40
+ end
41
+
42
+ describe "Employee's total remuneration for the month is $10,000.00" do
43
+ let(:remuneration) { 10_000.00 }
44
+ it { expect(result).to eq 11.25 }
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,94 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+
4
+ require 'singapore_sdl_calculator'
5
+
6
+ # This file was generated by the `rspec --init` command. Conventionally, all
7
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
8
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
9
+ # file to always be loaded, without a need to explicitly require it in any files.
10
+ #
11
+ # Given that it is always loaded, you are encouraged to keep this file as
12
+ # light-weight as possible. Requiring heavyweight dependencies from this file
13
+ # will add to the boot time of your test suite on EVERY test run, even for an
14
+ # individual file that may not need all of that loaded. Instead, consider making
15
+ # a separate helper file that requires the additional dependencies and performs
16
+ # the additional setup, and require it from the spec files that actually need it.
17
+ #
18
+ # The `.rspec` file also contains a few flags that are not defaults but that
19
+ # users commonly want.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ =begin
49
+ # These two settings work together to allow you to limit a spec run
50
+ # to individual examples or groups you care about by tagging them with
51
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
+ # get run.
53
+ config.filter_run :focus
54
+ config.run_all_when_everything_filtered = true
55
+
56
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
57
+ # For more details, see:
58
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
59
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
60
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
61
+ config.disable_monkey_patching!
62
+
63
+ # This setting enables warnings. It's recommended, but in some cases may
64
+ # be too noisy due to issues in dependencies.
65
+ config.warnings = true
66
+
67
+ # Many RSpec users commonly either run the entire suite or an individual
68
+ # file, and it's useful to allow more verbose output when running an
69
+ # individual spec file.
70
+ if config.files_to_run.one?
71
+ # Use the documentation formatter for detailed output,
72
+ # unless a formatter has already been configured
73
+ # (e.g. via a command-line flag).
74
+ config.default_formatter = 'doc'
75
+ end
76
+
77
+ # Print the 10 slowest examples and example groups at the
78
+ # end of the spec run, to help surface which specs are running
79
+ # particularly slow.
80
+ config.profile_examples = 10
81
+
82
+ # Run specs in random order to surface order dependencies. If you find an
83
+ # order dependency and want to debug it, you can fix the order by providing
84
+ # the seed, which is printed after each run.
85
+ # --seed 1234
86
+ config.order = :random
87
+
88
+ # Seed global randomization in this process using the `--seed` CLI option.
89
+ # Setting this allows you to use `--seed` to deterministically reproduce
90
+ # test failures related to randomization by passing the same `--seed` value
91
+ # as the one that triggered the failure.
92
+ Kernel.srand config.seed
93
+ =end
94
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: singapore_sdl_calculator
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Vincent Paca
8
+ - Ronald Maravilla
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-12-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.6'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.6'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: codeclimate-test-reporter
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description: Calculates for the employer contributions for the Skill Development Levy
71
+ Act contribution per employee.
72
+ email:
73
+ - vpaca@payrollhero.com
74
+ - rmaravilla@payrollhero.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - ".rspec"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - circle.yml
86
+ - lib/singapore_sdl_calculator.rb
87
+ - lib/singapore_sdl_calculator/version.rb
88
+ - singapore_sdl_calculator.gemspec
89
+ - spec/singapore_sdl_calculator_spec.rb
90
+ - spec/spec_helper.rb
91
+ homepage: https://github.com/payrollhero/singapore_sdl_calculator
92
+ licenses:
93
+ - BSD-3-Clause
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Calculator for Singapore Skill Development Levy
115
+ test_files:
116
+ - spec/singapore_sdl_calculator_spec.rb
117
+ - spec/spec_helper.rb
118
+ has_rdoc: