income-tax 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/income_tax/countries/canada.rb +38 -5
- data/lib/income_tax/countries/canada/alberta.rb +15 -0
- data/lib/income_tax/countries/canada/british_columbia.rb +15 -0
- data/lib/income_tax/countries/canada/federal.rb +22 -0
- data/lib/income_tax/countries/canada/manitoba.rb +13 -0
- data/lib/income_tax/countries/canada/new_brunswick.rb +16 -0
- data/lib/income_tax/countries/canada/newfoundland_and_labrador.rb +15 -0
- data/lib/income_tax/countries/canada/northwest_territories.rb +14 -0
- data/lib/income_tax/countries/canada/nova_scotia.rb +15 -0
- data/lib/income_tax/countries/canada/nunavut.rb +14 -0
- data/lib/income_tax/countries/canada/ontario.rb +15 -0
- data/lib/income_tax/countries/canada/prince_edward_island.rb +13 -0
- data/lib/income_tax/countries/canada/quebec.rb +14 -0
- data/lib/income_tax/countries/canada/saskatchewan.rb +13 -0
- data/lib/income_tax/countries/canada/yukon.rb +15 -0
- data/lib/income_tax/rate.rb +5 -0
- data/lib/income_tax/version.rb +1 -1
- data/readme.md +11 -1
- data/spec/income_tax/countries/canada_spec.rb +134 -84
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09ed2953aba2e33c5e4ef89a4bb53a7e10211d33
|
4
|
+
data.tar.gz: a4182214a3454f3762d1d7057ae1ca313dc7f065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 725d3f2b5dc1465a56f2cc77ce98f4db32a01c4b8d423afc625d1ebe06e3c5cf7b1ca0cab633318989568185346bf4e20d7673906dd2f3a5470b23522ab312af
|
7
|
+
data.tar.gz: f9fdd789b6b51324ed3b204d70ca2fa4edb73279b47d268ca65f90b89fa221755c285ba95460da464e35cf5a0e70f0e70abf72c2236a596f41212fe9aa6a48be
|
@@ -1,13 +1,46 @@
|
|
1
1
|
module IncomeTax
|
2
2
|
module Countries
|
3
|
-
class Canada < Models::
|
3
|
+
class Canada < Models::Generic
|
4
4
|
register "Canada", "CA", "CAN"
|
5
5
|
currency "CAD"
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
wants_options :territory
|
8
|
+
|
9
|
+
def setup(**options)
|
10
|
+
@federal = Federal.new(**options)
|
11
|
+
@territory = TerritoryRegister[territory].new(**options) if territory?
|
12
|
+
end
|
13
|
+
|
14
|
+
def territorial_taxes
|
15
|
+
return 0 unless territory?
|
16
|
+
@territory.taxes
|
17
|
+
end
|
18
|
+
|
19
|
+
def federal_taxes
|
20
|
+
@federal.taxes
|
21
|
+
end
|
22
|
+
|
23
|
+
def calculate
|
24
|
+
@taxes = federal_taxes + territorial_taxes
|
25
|
+
end
|
26
|
+
|
27
|
+
TerritoryRegister = Register.new("territory")
|
28
|
+
Territory = Class.new(Models::Progressive) { register_on TerritoryRegister }
|
29
|
+
|
30
|
+
require 'income_tax/countries/canada/federal'
|
31
|
+
require 'income_tax/countries/canada/alberta'
|
32
|
+
require 'income_tax/countries/canada/british_columbia'
|
33
|
+
require 'income_tax/countries/canada/manitoba'
|
34
|
+
require 'income_tax/countries/canada/new_brunswick'
|
35
|
+
require 'income_tax/countries/canada/newfoundland_and_labrador'
|
36
|
+
require 'income_tax/countries/canada/northwest_territories'
|
37
|
+
require 'income_tax/countries/canada/nova_scotia'
|
38
|
+
require 'income_tax/countries/canada/nunavut'
|
39
|
+
require 'income_tax/countries/canada/ontario'
|
40
|
+
require 'income_tax/countries/canada/prince_edward_island'
|
41
|
+
require 'income_tax/countries/canada/quebec'
|
42
|
+
require 'income_tax/countries/canada/saskatchewan'
|
43
|
+
require 'income_tax/countries/canada/yukon'
|
11
44
|
end
|
12
45
|
end
|
13
46
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class Alberta < Territory
|
5
|
+
register "Alberta", "AB"
|
6
|
+
|
7
|
+
level offset(125000), "10%"
|
8
|
+
level offset(25000), "12%"
|
9
|
+
level offset(50000), "13%"
|
10
|
+
level offset(100000), "14%"
|
11
|
+
remainder "15%"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class BritishColumbia < Territory
|
5
|
+
register "British Columbia", "BC"
|
6
|
+
|
7
|
+
level offset(38210), "5.06%"
|
8
|
+
level offset(38211), "7.7%"
|
9
|
+
level offset(11320), "10.5%"
|
10
|
+
level offset(18802), "12.29%"
|
11
|
+
remainder "14.7%"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class Federal < Models::Progressive
|
5
|
+
levels year: 2015 do
|
6
|
+
level offset(44700), "15%"
|
7
|
+
level offset(44700), "22%"
|
8
|
+
level offset(49185), "26%"
|
9
|
+
remainder "29%"
|
10
|
+
end
|
11
|
+
|
12
|
+
levels year: 2016 do
|
13
|
+
level offset(45282), "15%"
|
14
|
+
level offset(45281), "22%"
|
15
|
+
level offset(49825), "26%"
|
16
|
+
level offset(59612), "29%"
|
17
|
+
remainder "33%"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class NewBrunswick < Territory
|
5
|
+
register "New Brunswick", "NB"
|
6
|
+
|
7
|
+
level offset(40492), "9.68%"
|
8
|
+
level offset(40493), "14.82%"
|
9
|
+
level offset(50679), "16.52%"
|
10
|
+
level offset(18336), "17.84%"
|
11
|
+
level offset(100000), "21%"
|
12
|
+
remainder "25.75%"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class NewfoundlandAndLabrador < Territory
|
5
|
+
register "Newfoundland and Labrador", "Newfoundland", "Labrador", "NL"
|
6
|
+
|
7
|
+
level offset(35148), "7.7%"
|
8
|
+
level offset(35147), "12.5%"
|
9
|
+
level offset(55205), "13.3%"
|
10
|
+
level offset(50200), "14.3%"
|
11
|
+
remainder "15.3%"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class NorthwestTerritories < Territory
|
5
|
+
register "Northwest Territories", "NT"
|
6
|
+
|
7
|
+
level offset(41011), "5.9%"
|
8
|
+
level offset(41013), "8.6%"
|
9
|
+
level offset(51329), "12.2%"
|
10
|
+
remainder "14.05%"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class NovaScotia < Territory
|
5
|
+
register "Nova Scotia", "NS"
|
6
|
+
|
7
|
+
level offset(29590), "8.79%"
|
8
|
+
level offset(29590), "14.95%"
|
9
|
+
level offset(33820), "16.67%"
|
10
|
+
level offset(57000), "17.5%"
|
11
|
+
remainder "21%"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class Ontario < Territory
|
5
|
+
register "Ontario", "ON"
|
6
|
+
|
7
|
+
level offset(41536), "5.05%"
|
8
|
+
level offset(41539), "9.15%"
|
9
|
+
level offset(66925), "11.16%"
|
10
|
+
level offset(70000), "12.16%"
|
11
|
+
remainder "13.16%"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module IncomeTax
|
2
|
+
module Countries
|
3
|
+
class Canada
|
4
|
+
class Yukon < Territory
|
5
|
+
register "Yukon", "YT"
|
6
|
+
|
7
|
+
level offset(45282), "6.4%"
|
8
|
+
level offset(45281), "9%"
|
9
|
+
level offset(49825), "10.9%"
|
10
|
+
level offset(359612), "12.8%"
|
11
|
+
remainder "15%"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/income_tax/rate.rb
CHANGED
data/lib/income_tax/version.rb
CHANGED
data/readme.md
CHANGED
@@ -68,7 +68,7 @@ There is also a [full list of countries](locations.md).
|
|
68
68
|
|
69
69
|
#### United States
|
70
70
|
|
71
|
-
* **Federal only:** By default only federal taxes are calculated.
|
71
|
+
* **Federal only:** By default, only federal taxes are calculated.
|
72
72
|
* **State taxes:** Passing in the `state` option with either the full name of the state of the two letter abbreviation will also take state taxes into account.
|
73
73
|
* **Washington, D.C.:** Use the state option as if it was a state, which by the way it should be.
|
74
74
|
* **Guam, Puerto Rico, and other territories:** Treat them like separate countries.
|
@@ -80,6 +80,16 @@ IncomeTax.new("US", "100k", state: "California")
|
|
80
80
|
IncomeTax.new("Guam", "100k")
|
81
81
|
```
|
82
82
|
|
83
|
+
#### Canada
|
84
|
+
|
85
|
+
* **Federal only:** By default, only federal taxes are calculated.
|
86
|
+
* **Territorial taxes:** Passing in the `territory` option with either the full name of the state of the two letter abbreviation will also take state taxes into account.
|
87
|
+
|
88
|
+
``` ruby
|
89
|
+
IncomeTax.new("CA", "100k")
|
90
|
+
IncomeTax.new("CA", "100k", territory: "British Columbia")
|
91
|
+
```
|
92
|
+
|
83
93
|
#### Switzerland
|
84
94
|
|
85
95
|
You can use the `canton` option with either the full canton name or the two letter abbreviation.
|
@@ -1,99 +1,149 @@
|
|
1
1
|
describe IncomeTax::Countries::Canada do
|
2
|
-
subject(:result) { described_class.new(income: income, income_type: type, tax_year: tax_year) }
|
2
|
+
subject(:result) { described_class.new(income: income, income_type: type, tax_year: tax_year, territory: territory) }
|
3
3
|
let(:type) { :gross }
|
4
|
+
let(:territory) { nil }
|
4
5
|
|
5
|
-
describe "
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
describe "tax year 2015, federal taxes only" do
|
7
|
+
describe "from gross income of 0" do
|
8
|
+
let(:tax_year) { 2015 }
|
9
|
+
let(:income) { 0 }
|
10
|
+
its(:rate) { should be == Rational(0, 1) }
|
11
|
+
its(:gross_income) { should be == 0 }
|
12
|
+
its(:net_income) { should be == 0 }
|
13
|
+
its(:taxes) { should be == 0 }
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
describe "from gross income of 1000" do
|
17
|
+
let(:tax_year) { 2015 }
|
18
|
+
let(:income) { 1000 }
|
19
|
+
its(:rate) { should be == Rational(3, 20) }
|
20
|
+
its(:gross_income) { should be == 1000 }
|
21
|
+
its(:net_income) { should be == 850 }
|
22
|
+
its(:taxes) { should be == 150 }
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
describe "from gross income of 10000" do
|
26
|
+
let(:tax_year) { 2015 }
|
27
|
+
let(:income) { 10000 }
|
28
|
+
its(:rate) { should be == Rational(3, 20) }
|
29
|
+
its(:gross_income) { should be == 10000 }
|
30
|
+
its(:net_income) { should be == 8500 }
|
31
|
+
its(:taxes) { should be == 1500 }
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
describe "from gross income of 100000" do
|
35
|
+
let(:tax_year) { 2015 }
|
36
|
+
let(:income) { 100000 }
|
37
|
+
its(:rate) { should be == Rational(82, 425) }
|
38
|
+
its(:gross_income) { should be == 100000 }
|
39
|
+
its(:net_income) { should be == 80705 }
|
40
|
+
its(:taxes) { should be == 19295 }
|
41
|
+
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
describe "from gross income of 100000000" do
|
44
|
+
let(:tax_year) { 2015 }
|
45
|
+
let(:income) { 100000000 }
|
46
|
+
its(:rate) { should be == Rational(109, 376) }
|
47
|
+
its(:gross_income) { should be == 100000000 }
|
48
|
+
its(:net_income) { should be == "71010862.55".to_d }
|
49
|
+
its(:taxes) { should be == "28989137.45".to_d }
|
50
|
+
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
describe "from net income of 0" do
|
53
|
+
let(:type) { :net }
|
54
|
+
let(:tax_year) { 2015 }
|
55
|
+
let(:income) { 0 }
|
56
|
+
its(:rate) { should be == Rational(0, 1) }
|
57
|
+
its(:gross_income) { should be == 0 }
|
58
|
+
its(:net_income) { should be == 0 }
|
59
|
+
its(:taxes) { should be == 0 }
|
60
|
+
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
describe "from net income of 1000" do
|
63
|
+
let(:type) { :net }
|
64
|
+
let(:tax_year) { 2015 }
|
65
|
+
let(:income) { 1000 }
|
66
|
+
its(:rate) { should be == Rational(3, 20) }
|
67
|
+
its(:gross_income) { should be == "1176.470588235294118".to_d }
|
68
|
+
its(:net_income) { should be == 1000 }
|
69
|
+
its(:taxes) { should be == "176.470588235294118".to_d }
|
70
|
+
end
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
describe "from net income of 10000" do
|
73
|
+
let(:type) { :net }
|
74
|
+
let(:tax_year) { 2015 }
|
75
|
+
let(:income) { 10000 }
|
76
|
+
its(:rate) { should be == Rational(3, 20) }
|
77
|
+
its(:gross_income) { should be == "11764.70588235294118".to_d }
|
78
|
+
its(:net_income) { should be == 10000 }
|
79
|
+
its(:taxes) { should be == "1764.70588235294118".to_d }
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "from net income of 100000" do
|
83
|
+
let(:type) { :net }
|
84
|
+
let(:tax_year) { 2015 }
|
85
|
+
let(:income) { 100000 }
|
86
|
+
its(:rate) { should be == Rational(85, 411) }
|
87
|
+
its(:gross_income) { should be == "126074.3243243243243".to_d }
|
88
|
+
its(:net_income) { should be == 100000 }
|
89
|
+
its(:taxes) { should be == "26074.3243243243243".to_d }
|
90
|
+
end
|
79
91
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
92
|
+
describe "from net income of 100000000" do
|
93
|
+
let(:type) { :net }
|
94
|
+
let(:tax_year) { 2015 }
|
95
|
+
let(:income) { 100000000 }
|
96
|
+
its(:rate) { should be == Rational(69, 238) }
|
97
|
+
its(:gross_income) { should be == "140829771.056338028".to_d }
|
98
|
+
its(:net_income) { should be == 100000000 }
|
99
|
+
its(:taxes) { should be == "40829771.056338028".to_d }
|
100
|
+
end
|
88
101
|
end
|
89
102
|
|
90
|
-
describe "
|
91
|
-
let(:
|
92
|
-
let(:
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
103
|
+
describe "tax year 2016, taxes in Labrador" do
|
104
|
+
let(:tax_year) { 2016 }
|
105
|
+
let(:territory) { "Labrador" }
|
106
|
+
|
107
|
+
describe "from gross income of 0" do
|
108
|
+
let(:income) { 0 }
|
109
|
+
its(:rate) { should be == Rational(0, 1) }
|
110
|
+
its(:gross_income) { should be == 0 }
|
111
|
+
its(:net_income) { should be == 0 }
|
112
|
+
its(:taxes) { should be == 0 }
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "from gross income of 1000" do
|
116
|
+
let(:income) { 1000 }
|
117
|
+
its(:rate) { should be == Rational(37, 163) }
|
118
|
+
its(:gross_income) { should be == 1000 }
|
119
|
+
its(:net_income) { should be == 773 }
|
120
|
+
its(:taxes) { should be == 227 }
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "from gross income of 100000" do
|
124
|
+
let(:income) { 100000 }
|
125
|
+
its(:rate) { should be == Rational(82, 271) }
|
126
|
+
its(:gross_income) { should be == 100000 }
|
127
|
+
its(:net_income) { should be == "69741.724".to_d }
|
128
|
+
its(:taxes) { should be == "30258.276".to_d }
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "from net income of 0" do
|
132
|
+
let(:type) { :net }
|
133
|
+
let(:income) { 0 }
|
134
|
+
its(:rate) { should be == Rational(0, 1) }
|
135
|
+
its(:gross_income) { should be == 0 }
|
136
|
+
its(:net_income) { should be == 0 }
|
137
|
+
its(:taxes) { should be == 0 }
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "from net income of 100000" do
|
141
|
+
let(:type) { :net }
|
142
|
+
let(:income) { 100000 }
|
143
|
+
its(:rate) { should be == Rational(137, 491) }
|
144
|
+
its(:gross_income) { should be == "138702.1216683811839".to_d }
|
145
|
+
its(:net_income) { should be == 100000 }
|
146
|
+
its(:taxes) { should be == "38702.1216683811839".to_d }
|
147
|
+
end
|
98
148
|
end
|
99
149
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: income-tax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Estimate Income Tax for different Countries
|
14
14
|
email: income-tax-gem@rkh.im
|
@@ -61,6 +61,20 @@ files:
|
|
61
61
|
- lib/income_tax/countries/cambodia.rb
|
62
62
|
- lib/income_tax/countries/cameroon.rb
|
63
63
|
- lib/income_tax/countries/canada.rb
|
64
|
+
- lib/income_tax/countries/canada/alberta.rb
|
65
|
+
- lib/income_tax/countries/canada/british_columbia.rb
|
66
|
+
- lib/income_tax/countries/canada/federal.rb
|
67
|
+
- lib/income_tax/countries/canada/manitoba.rb
|
68
|
+
- lib/income_tax/countries/canada/new_brunswick.rb
|
69
|
+
- lib/income_tax/countries/canada/newfoundland_and_labrador.rb
|
70
|
+
- lib/income_tax/countries/canada/northwest_territories.rb
|
71
|
+
- lib/income_tax/countries/canada/nova_scotia.rb
|
72
|
+
- lib/income_tax/countries/canada/nunavut.rb
|
73
|
+
- lib/income_tax/countries/canada/ontario.rb
|
74
|
+
- lib/income_tax/countries/canada/prince_edward_island.rb
|
75
|
+
- lib/income_tax/countries/canada/quebec.rb
|
76
|
+
- lib/income_tax/countries/canada/saskatchewan.rb
|
77
|
+
- lib/income_tax/countries/canada/yukon.rb
|
64
78
|
- lib/income_tax/countries/cape_verde.rb
|
65
79
|
- lib/income_tax/countries/caribbean_netherlands.rb
|
66
80
|
- lib/income_tax/countries/cayman_islands.rb
|