singapore_charitable_donations 1.0.1 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5007963d5123d417bfe408fddf372a8322355673
4
- data.tar.gz: e7ab809df3b4987cfe98b27faa27763240aee021
2
+ SHA256:
3
+ metadata.gz: 77e4c404c5dfbf923115db0ce919edc83b8eadd1174a7b19dc3c157f414811f6
4
+ data.tar.gz: eaeee2b72fa133b0edac08337ad95d1ae008122beb9610620a8739d9ed3a5275
5
5
  SHA512:
6
- metadata.gz: 9de067d6f6010ed6860aaeaeb4b4a8893ec3c4bd40019a0246208ae0a782fac90fb476185eec45dc3ff56e94976f79e82ccdc2231b63b3bb5152e7c2ff1134d5
7
- data.tar.gz: 05474badcdf92252053fd6b135d4d2172d88a62ffa3718d2b69482ef47837d90cddc88d92f555b6d9fe294f86fe988a901c0ee28231332bececb43f5fde2562d
6
+ metadata.gz: f3da1420ccd8cdc017fea2e3a775cfd32a7f0ce0e4c30036466c9239a65ecc4f9db18389d8c6d5a2b34ed4413f79e97a7b678e70cebf3055d0ba0e24d4695d30
7
+ data.tar.gz: 1e9de837b575e53aedfe6eb53425904d2c8bd3ad8a7d82ce0c775bf6b627998bc572665386d016a80b2836dae46e0c19eab96da509216b171c6202c7ead17f97
@@ -20,6 +20,7 @@ module SingaporeCharitableDonations
20
20
  ECF::Year2014Calculator,
21
21
  ECF::Year2015Calculator,
22
22
  MBMF::Year2009Calculator,
23
+ MBMF::Year2016Calculator,
23
24
  SINDA::Year2014Calculator,
24
25
  SINDA::Year2015Calculator,
25
26
  ]
@@ -35,5 +36,6 @@ require_relative 'calculators/cdac/year_2015_calculator'
35
36
  require_relative 'calculators/ecf/year_2014_calculator'
36
37
  require_relative 'calculators/ecf/year_2015_calculator'
37
38
  require_relative 'calculators/mbmf/year_2009_calculator'
39
+ require_relative 'calculators/mbmf/year_2016_calculator'
38
40
  require_relative 'calculators/sinda/year_2014_calculator'
39
41
  require_relative 'calculators/sinda/year_2015_calculator'
@@ -29,9 +29,13 @@ module SingaporeCharitableDonations
29
29
  # @param [String] type of charitable contribution
30
30
  # @return [TrueClass, FalseClass]
31
31
  def applies_to?(date, type)
32
- date.year >= 2009 && type == 'MBMF'
32
+ date.year >= 2009 && date < CUTOFF_DATE && type == 'MBMF'
33
33
  end
34
34
 
35
+ private
36
+
37
+ CUTOFF_DATE = Date.new(2016,6,1)
38
+
35
39
  end
36
40
  end
37
41
  end
@@ -0,0 +1,47 @@
1
+ module SingaporeCharitableDonations
2
+ module Calculators
3
+ module MBMF
4
+
5
+ # Mosque Building and Mendaki Fund contribution calculator for June 1st, 2016 onwards
6
+ module Year2016Calculator
7
+ class << self
8
+
9
+ # @param [BigDecimal] total_wages
10
+ # @return [BigDecimal] contribution amount
11
+ def calculate(total_wages)
12
+ case
13
+ when total_wages <= 1_000.00
14
+ BigDecimal "3.00"
15
+ when total_wages <= 2_000.00
16
+ BigDecimal "4.50"
17
+ when total_wages <= 3_000.00
18
+ BigDecimal "6.50"
19
+ when total_wages <= 4_000.00
20
+ BigDecimal "15.00"
21
+ when total_wages <= 6_000.00
22
+ BigDecimal "19.50"
23
+ when total_wages <= 8_000.00
24
+ BigDecimal "22.00"
25
+ when total_wages <= 10_000.00
26
+ BigDecimal "24.00"
27
+ else # total_wages >= 10_000.00
28
+ BigDecimal "26.00"
29
+ end
30
+ end
31
+
32
+ # @param [Date] date to be considered for calculation
33
+ # @param [String] type of charitable contribution
34
+ # @return [TrueClass, FalseClass]
35
+ def applies_to?(date, type)
36
+ date >= CUTOFF_DATE && type == 'MBMF'
37
+ end
38
+
39
+ private
40
+
41
+ CUTOFF_DATE = Date.new(2016,6,1)
42
+
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module SingaporeCharitableDonations
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -4,6 +4,25 @@ describe SingaporeCharitableDonations::Calculators::MBMF::Year2009Calculator do
4
4
 
5
5
  subject(:result) { described_class.calculate(total_wages) }
6
6
 
7
+ describe 'applies_to?' do
8
+ subject(:answer) { described_class.applies_to?(date, "MBMF") }
9
+
10
+ context "june 1st, 2016" do
11
+ let(:date) { Date.new(2016, 6, 1) }
12
+ it { is_expected.to be false }
13
+ end
14
+
15
+ context "May 22nd, 2016" do
16
+ let(:date) { Date.new(2016, 5, 22) }
17
+ it { is_expected.to be true }
18
+ end
19
+
20
+ context "May 22nd, 2008" do
21
+ let(:date) { Date.new(2008, 5, 22) }
22
+ it { is_expected.to be false }
23
+ end
24
+ end
25
+
7
26
  describe '#calculate' do
8
27
 
9
28
  context 'when the total wage is less than $200.00' do
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeCharitableDonations::Calculators::MBMF::Year2016Calculator do
4
+
5
+ subject(:klass) { described_class }
6
+
7
+ describe 'applies_to?' do
8
+ subject(:answer) { klass.applies_to?(date, "MBMF") }
9
+
10
+ context "june 1st, 2016" do
11
+ let(:date) { Date.new(2016, 6, 1) }
12
+ it { is_expected.to be true }
13
+ end
14
+
15
+ context "May 22nd, 2016" do
16
+ let(:date) { Date.new(2016, 5, 22) }
17
+ it { is_expected.to be false }
18
+ end
19
+ end
20
+
21
+ describe '#calculate' do
22
+
23
+ def it_matches_the_context(example)
24
+ total_wages = example.metadata[:total_wages]
25
+ total_wages = [total_wages] unless total_wages.kind_of?(Array)
26
+ total_wages.each do |total_wage|
27
+ expect(described_class.calculate(total_wage)).to eq example.metadata[:expected_contribution]
28
+ end
29
+ end
30
+
31
+ it 'less than 1000.00', total_wages: [900, 1000], expected_contribution: 3.00 do |example|
32
+ it_matches_the_context(example)
33
+ end
34
+
35
+ it 'less than 2000.00', total_wages: [1900, 2000], expected_contribution: 4.50 do |example|
36
+ it_matches_the_context(example)
37
+ end
38
+
39
+ it 'less than 3000.00', total_wages: [2900, 3000], expected_contribution: 6.50 do |example|
40
+ it_matches_the_context(example)
41
+ end
42
+
43
+ it 'less than 4000.00', total_wages: [3900, 4000], expected_contribution: 15.00 do |example|
44
+ it_matches_the_context(example)
45
+ end
46
+
47
+ it 'less than 6000.00', total_wages: [5900, 6000], expected_contribution: 19.50 do |example|
48
+ it_matches_the_context(example)
49
+ end
50
+
51
+ it 'less than 8000.00', total_wages: [7900, 8000], expected_contribution: 22.00 do |example|
52
+ it_matches_the_context(example)
53
+ end
54
+
55
+ it 'less than 1000.00', total_wages: [9900, 10000], expected_contribution: 24.00 do |example|
56
+ it_matches_the_context(example)
57
+ end
58
+
59
+ it 'greater than 1000.00', total_wages: 11000, expected_contribution: 26.00 do |example|
60
+ it_matches_the_context(example)
61
+ end
62
+
63
+ end
64
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singapore_charitable_donations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Paca
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-09 00:00:00.000000000 Z
12
+ date: 2020-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -90,6 +90,7 @@ files:
90
90
  - lib/singapore_charitable_donations/calculators/ecf/year_2014_calculator.rb
91
91
  - lib/singapore_charitable_donations/calculators/ecf/year_2015_calculator.rb
92
92
  - lib/singapore_charitable_donations/calculators/mbmf/year_2009_calculator.rb
93
+ - lib/singapore_charitable_donations/calculators/mbmf/year_2016_calculator.rb
93
94
  - lib/singapore_charitable_donations/calculators/sinda/year_2014_calculator.rb
94
95
  - lib/singapore_charitable_donations/calculators/sinda/year_2015_calculator.rb
95
96
  - lib/singapore_charitable_donations/version.rb
@@ -99,6 +100,7 @@ files:
99
100
  - spec/singapore_charitable_donations/calculators/ecf/year_2014_calculator_spec.rb
100
101
  - spec/singapore_charitable_donations/calculators/ecf/year_2015_calculator_spec.rb
101
102
  - spec/singapore_charitable_donations/calculators/mbmf/year_2009_calculator_spec.rb
103
+ - spec/singapore_charitable_donations/calculators/mbmf/year_2016_calculator_spec.rb
102
104
  - spec/singapore_charitable_donations/calculators/sinda/year_2014_calculator_spec.rb
103
105
  - spec/singapore_charitable_donations/calculators/sinda/year_2015_calculator_spec.rb
104
106
  - spec/singapore_charitable_donations/calculators_spec.rb
@@ -122,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
124
  - !ruby/object:Gem::Version
123
125
  version: '0'
124
126
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.2.2
127
+ rubygems_version: 3.0.8
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Calculators for Singapore Charitable Donations
@@ -133,6 +134,7 @@ test_files:
133
134
  - spec/singapore_charitable_donations/calculators/ecf/year_2014_calculator_spec.rb
134
135
  - spec/singapore_charitable_donations/calculators/ecf/year_2015_calculator_spec.rb
135
136
  - spec/singapore_charitable_donations/calculators/mbmf/year_2009_calculator_spec.rb
137
+ - spec/singapore_charitable_donations/calculators/mbmf/year_2016_calculator_spec.rb
136
138
  - spec/singapore_charitable_donations/calculators/sinda/year_2014_calculator_spec.rb
137
139
  - spec/singapore_charitable_donations/calculators/sinda/year_2015_calculator_spec.rb
138
140
  - spec/singapore_charitable_donations/calculators_spec.rb