tax_computation 0.2.5 → 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: 3f7f0df5618bb06755301b6d4b26ed3aed5ef090795d86eae49ca3b60b6ef037
4
- data.tar.gz: 5d0fa2ecd0a43c1677e197f50d518e0d3a3d2f208911497ef090ed8c5c09dbde
3
+ metadata.gz: 8d181aea69f2d937eb79447dfcb8e4bedbe5cb3f8f6fa1f8f096da0687083991
4
+ data.tar.gz: 623728f3e6e23476ed5264e451a7070a1da0aa5a091b3c4eff9cd5e8f0b40df2
5
5
  SHA512:
6
- metadata.gz: e650502051765cb971f5875de8523ee6972b6d0045724278e80f8b4058c97b3396e5843211f4b069a9faed6af4be1b38276b6fd7e65f8a7cb0fe4c84e78581e1
7
- data.tar.gz: 50d167c644e045ceddba4ec353f4c4455d9c21cf1227f94b2b846cb8b95aa4ab14f4203fb4fdc2e19591231e4e19631622b033f305db900066b732ad01d7ffc9
6
+ metadata.gz: 1ebf45bb3dd3d9422d6eef7c597b84331e2b685987f5606e8d55e75419f2be1a50b5a3efd355debc53e82c1a1aeab726d782158a4739c34ab6c880c6d3b7f304
7
+ data.tar.gz: 582e78411018f447bf2c8a9499e4ffabe9f08e837dc17c12cd91e37d1b0e4073aa48eee40f2ced58b9c69a91b2a44ca4e2dcd53602c9c91bc7cdb80663a21231
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # TaxComputation
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tax_computation`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Welcome! With this gem you can calculate the tax according to the new policy given by income tax department of Pakistan.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,17 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ To get the tax monthly
24
+
25
+ ```ruby
26
+ TaxComputation.calculate_monthly_tax(monthly_salary_amount) #it will return the tax monthly
27
+ ```
28
+
29
+ To get the tax yearly
30
+
31
+ ```ruby
32
+ TaxComputation.calculate_yearly_tax(yearly_salary_amount) #it will return the tax yearly
33
+ ```
26
34
 
27
35
  ## Development
28
36
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TaxComputation
4
- VERSION = "0.2.5"
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
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
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.5
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-06 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:
@@ -28,6 +28,14 @@ files:
28
28
  - bin/setup
29
29
  - lib/tax_computation.rb
30
30
  - lib/tax_computation/version.rb
31
+ - tax_computation-0.1.0.gem
32
+ - tax_computation-0.1.1.gem
33
+ - tax_computation-0.2.0.gem
34
+ - tax_computation-0.2.1.gem
35
+ - tax_computation-0.2.2.gem
36
+ - tax_computation-0.2.3.gem
37
+ - tax_computation-0.2.4.gem
38
+ - tax_computation-0.2.5.gem
31
39
  - tax_computation.gemspec
32
40
  homepage:
33
41
  licenses: []
@@ -47,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
55
  - !ruby/object:Gem::Version
48
56
  version: '0'
49
57
  requirements: []
50
- rubygems_version: 3.2.22
58
+ rubygems_version: 3.2.15
51
59
  signing_key:
52
60
  specification_version: 4
53
61
  summary: Write a short summary, because RubyGems requires one.