tax_computation 0.2.7 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 858eefab3ffb334427f138276fac40d29a726ea30958ddef35d77e9640c743ca
4
- data.tar.gz: f9d74ebd14279493f4965f710119abc9ef94d510139eb81e6bdf54470a2ce82f
3
+ metadata.gz: 8d181aea69f2d937eb79447dfcb8e4bedbe5cb3f8f6fa1f8f096da0687083991
4
+ data.tar.gz: 623728f3e6e23476ed5264e451a7070a1da0aa5a091b3c4eff9cd5e8f0b40df2
5
5
  SHA512:
6
- metadata.gz: 8d442a457f0100f9029e4b7ff0655a5b446ec61bccff4e3ccf6cc13448e9434ae8e80c477c928a705ace443acce9544626ff2c3278fa101514ebc0aab08941ec
7
- data.tar.gz: 1ebc05ee3ff561eaee99c2db030ed4ec15668e8b6a57a75a882ceceb66ba31a9a534bf400b26d27822e779ba5ca1f9fb9fdf8005f398eec23f745c6321cdf832
6
+ metadata.gz: 1ebf45bb3dd3d9422d6eef7c597b84331e2b685987f5606e8d55e75419f2be1a50b5a3efd355debc53e82c1a1aeab726d782158a4739c34ab6c880c6d3b7f304
7
+ data.tar.gz: 582e78411018f447bf2c8a9499e4ffabe9f08e837dc17c12cd91e37d1b0e4073aa48eee40f2ced58b9c69a91b2a44ca4e2dcd53602c9c91bc7cdb80663a21231
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TaxComputation
4
- VERSION = "0.2.7"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -3,40 +3,46 @@
3
3
  require_relative "tax_computation/version"
4
4
 
5
5
  module TaxComputation
6
- RANGES = {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
- }
6
+ RANGES_2k21_22 = {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_2k22_23 = {600000.0...1200000.0 => {percentage: 2.5, fixed_amount: 0, low: 600000},
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
+ }
18
26
 
19
27
  private
20
28
 
21
- def self.calculate_monthly_tax(salary)
29
+ def self.calculate_monthly_tax(salary = 0, year = 2021)
22
30
  salary = salary * 12
23
- if salary <= 600000.0
24
- 0
25
- else
26
- calculate(salary) / 12.to_f
27
- end
31
+ return 0 if salary <= 600000.0
32
+
33
+ calculate(salary, year) / 12.to_f
28
34
  end
29
35
 
30
- def self.calculate_yearly_tax(salary)
31
- if salary <= 600000.0
32
- 0
33
- else
34
- calculate(salary)
35
- end
36
+ def self.calculate_yearly_tax(salary = 0, year = 2021)
37
+ return 0 if salary <= 600000.0
38
+
39
+ calculate(salary, year)
36
40
  end
37
41
 
38
- def self.calculate (salary)
39
- range = RANGES.select{|range| range === salary}
42
+ def self.calculate(salary, year)
43
+ slabs = year.eql?(2021) ? RANGES_2k21_22 : RANGES_2k22_23
44
+
45
+ range = slabs.select{|range| range === salary}
40
46
  range.values[0][:fixed_amount] + (((salary - range.values[0][:low]) / 100) * range.values[0][:percentage])
41
47
  end
42
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tax_computation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamza Alvi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-13 00:00:00.000000000 Z
11
+ date: 2022-07-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Write a longer description or delete this line.
14
14
  email:
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  requirements: []
58
- rubygems_version: 3.2.22
58
+ rubygems_version: 3.2.15
59
59
  signing_key:
60
60
  specification_version: 4
61
61
  summary: Write a short summary, because RubyGems requires one.