tax_computation 2.0.0 → 2.1.1
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 +4 -4
- data/lib/tax_computation/version.rb +1 -1
- data/lib/tax_computation.rb +42 -17
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6154f93cb01dcc9d89425a658e2f4ac748e03d762f212b5ea5ff166fe612a2c5
|
|
4
|
+
data.tar.gz: f9914f1209f4504e8bca946e9da98282801f73b352c352517a8428ac6b5f266f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b23e7dc56c9ad76b33696afc1e6ceab23d5766ca79f46318a86db09b34c72b9396adf088c0ebdb1d81de81acf6bcb2f54d6155bd0bd26ed0ea77cc1d4326b786
|
|
7
|
+
data.tar.gz: b7a632f3db26c38331fda2d2d1b9841824d86e15a15afc3b6d6a094a085beb4a2b1ebf39271b0fecc425ddbe2089cbe1541ebdffd95b3bc6e42370e86aefed25
|
data/lib/tax_computation.rb
CHANGED
|
@@ -3,31 +3,56 @@
|
|
|
3
3
|
require_relative "tax_computation/version"
|
|
4
4
|
|
|
5
5
|
module TaxComputation
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
RANGES_2021_2022 = {600000.0...1200000.0 => {percentage: 5, fixed_amount: 0, low: 600000},
|
|
7
|
+
1200000.0...1800000.0 => {percentage: 10, fixed_amount: 30000, low: 1200000},
|
|
8
|
+
1800000.0...2500000.0 => {percentage: 15, fixed_amount: 90000, low: 1800000},
|
|
9
|
+
2500000.0...3500000.0 => {percentage: 17.5, fixed_amount: 195000, low: 2500000},
|
|
10
|
+
3500000.0...5000000.0 => {percentage: 20, fixed_amount: 370000, low: 3500000},
|
|
11
|
+
5000000.0...8000000.0 => {percentage: 22.5, fixed_amount: 670000, low: 5000000},
|
|
12
|
+
8000000.0...12000000.0 => {percentage: 25, fixed_amount: 1345000, low: 8000000},
|
|
13
|
+
12000000.0...30000000.0 => {percentage: 27.5, fixed_amount: 2345000, low: 12000000},
|
|
14
|
+
30000000.0...50000000.0 => {percentage: 30, fixed_amount: 7295000, low: 30000000},
|
|
15
|
+
50000000.0...75000000.0 => {percentage: 32.5, fixed_amount: 13295000, low: 50000000},
|
|
16
|
+
75000000.0..Float::INFINITY => {percentage: 35, fixed_amount: 21420000, low: 75000000}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
RANGES_2022_2023 = {600000.0...1200000.0 => {percentage: 2.5, fixed_amount: 0, low: 600000.0},
|
|
20
|
+
1200000.0...2400000.0 => {percentage: 12.5, fixed_amount: 15000, low: 1200000},
|
|
21
|
+
2400000.0...3600000.0 => {percentage: 20, fixed_amount: 165000, low: 2400000},
|
|
22
|
+
3600000.0...6000000.0 => {percentage: 25, fixed_amount: 405000, low: 3600000},
|
|
23
|
+
6000000.0...12000000.0 => {percentage: 32.5, fixed_amount: 1005000, low: 6000000},
|
|
24
|
+
12000000.0...Float::INFINITY => {percentage: 35, fixed_amount: 2955000, low: 12000000.0}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
RANGES_2023_2024 = {600000.0...1200000.0 => {percentage: 2.5, fixed_amount: 0, low: 600000},
|
|
28
|
+
1200000.0...2400000.0 => {percentage: 12.5, fixed_amount: 15000, low: 1200000},
|
|
29
|
+
2400000.0...3600000.0 => {percentage: 22.5, fixed_amount: 165000, low: 2400000},
|
|
30
|
+
3600000.0...6000000.0 => {percentage: 27.5, fixed_amount: 435000, low: 3600000},
|
|
31
|
+
6000000.0...Float::INFINITY => {percentage: 35, fixed_amount: 1095000, low: 6000000}
|
|
32
|
+
}
|
|
12
33
|
|
|
13
34
|
private
|
|
14
35
|
|
|
15
|
-
def self.calculate_monthly_tax(salary =
|
|
36
|
+
def self.calculate_monthly_tax(salary, year=2023)
|
|
16
37
|
salary = salary * 12
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
38
|
+
if salary <= 600000.0
|
|
39
|
+
0
|
|
40
|
+
else
|
|
41
|
+
calculate(salary, year) / 12.to_f
|
|
42
|
+
end
|
|
20
43
|
end
|
|
21
44
|
|
|
22
|
-
def self.calculate_yearly_tax(salary =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
45
|
+
def self.calculate_yearly_tax(salary, year=2023)
|
|
46
|
+
if salary <= 600000.0
|
|
47
|
+
0
|
|
48
|
+
else
|
|
49
|
+
calculate(2023, year)
|
|
50
|
+
end
|
|
26
51
|
end
|
|
27
52
|
|
|
28
|
-
def self.calculate(salary)
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
def self.calculate (salary, year)
|
|
54
|
+
return 'You can only calculate taxes of 2021-22, 2022-23 and 2023-24 only' unless [2021, 2022, 2023].include? year
|
|
55
|
+
slabs = eval("RANGES_#{ year }_#{ year + 1 }")
|
|
31
56
|
range = slabs.select{|range| range === salary}
|
|
32
57
|
range.values[0][:fixed_amount] + (((salary - range.values[0][:low]) / 100) * range.values[0][:percentage])
|
|
33
58
|
end
|