taxger 0.2.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE +8 -0
- data/README.md +89 -0
- data/Rakefile +22 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/taxger/einkommensteuer.rb +104 -0
- data/lib/taxger/lohnsteuer/bigdecimal.rb +70 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2006.rb +891 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2007.rb +917 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2008.rb +983 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2009.rb +975 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2010.rb +1026 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2011.rb +1070 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2011dezember.rb +1082 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2012.rb +1118 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2013.rb +1120 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2014.rb +1123 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2015.rb +1144 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2015dezember.rb +1339 -0
- data/lib/taxger/lohnsteuer/lohnsteuer2016.rb +1144 -0
- data/lib/taxger/lohnsteuer.rb +28 -0
- data/lib/taxger/version.rb +3 -0
- data/lib/taxger.rb +9 -0
- data/src/README.md +141 -0
- data/src/code_tree.rb +122 -0
- data/src/converter.rb +61 -0
- data/src/generated/.keep +0 -0
- data/src/node/class_node.rb +30 -0
- data/src/node/comment_node.rb +19 -0
- data/src/node/conditional_node.rb +32 -0
- data/src/node/expr_node.rb +13 -0
- data/src/node/initializer_node.rb +37 -0
- data/src/node/method_call_node.rb +12 -0
- data/src/node/method_node.rb +21 -0
- data/src/node/node.rb +47 -0
- data/src/node/pseudo_code_parser.rb +88 -0
- data/src/node/source_node.rb +43 -0
- data/src/node/var_block_node.rb +39 -0
- data/taxger.gemspec +34 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 973ad4154b155c02e61a8bb6883e9ae644bb5710
|
4
|
+
data.tar.gz: 3dfbb46a51f9b5b1864eba25fa2c3f476adee9bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 195f204a0602cbad392d8e83e60f9019bc729f766ab8b031174e88b2438a36fd3ea316b5e355f5a7a8875d6cf4659dba062c1910ab81a4bf96328b01713ab82c
|
7
|
+
data.tar.gz: de15485b5d9e3f1727e14b4795d1b64ce496bbc0c79d2620af3b090e35120b16d01897bbc8a7cc2f7ba3bb458e4c095fd817ea4a86b34da65661e9bd46ac7f35
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2015-2016 Malte Münchert
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Taxger
|
2
|
+
|
3
|
+
This gem contains tools to calcuate taxes in Germany.
|
4
|
+
|
5
|
+
Currently supported is calculating Lohnsteuer. To achieve this,
|
6
|
+
The pseudo code describing tax caluculations from the Minstery of
|
7
|
+
Finance is used to automatically create Ruby code from this.
|
8
|
+
|
9
|
+
__(German description for SEO purposes):__
|
10
|
+
|
11
|
+
Dieses Gem enthält Routinen zum Berechnen von Steuern in Deutschland
|
12
|
+
(Lohnsteuer).
|
13
|
+
|
14
|
+
Der Programmcode zur Berechnung der Lohnsteuer wurde automatisch anhand
|
15
|
+
der vom Bundesministerium für Finanzen zur Verfügung gestellten
|
16
|
+
Pseudocode-Vorlagen erstellt.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'taxger'
|
24
|
+
```
|
25
|
+
|
26
|
+
And then execute:
|
27
|
+
|
28
|
+
$ bundle
|
29
|
+
|
30
|
+
Or install it yourself as:
|
31
|
+
|
32
|
+
$ gem install taxger
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
### Lohnsteuer
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'taxger'
|
40
|
+
|
41
|
+
# calculate Lohnsteuer for 2015:
|
42
|
+
# stkl: 1, # Steuerklasse I (stkl), 70.000,00 EUR
|
43
|
+
# lzz: 1, # Lohnzahlungszeitraum Jährlich (Salary re4 contains yearly
|
44
|
+
# # salary)
|
45
|
+
# re4: 70_000 * 100 # Salary is 70.000,00 EUR
|
46
|
+
tax = Taxger::Lohnsteuer.calculate(2015, stkl: 1, lzz: 1, re4: 70_000 * 100)
|
47
|
+
puts tax.lstlzz # Lohnsteuer für Lohnzahlungszeitraum (Income tax for
|
48
|
+
# specified interval of one year
|
49
|
+
```
|
50
|
+
|
51
|
+
Have a look into the files in `lib/taxger/lohnsteuer/*.rb` to see
|
52
|
+
possible values.
|
53
|
+
The `initialize` method contains all parameters below the `# INPUTS`
|
54
|
+
section- comments are taken from the official pseudo code sources.
|
55
|
+
|
56
|
+
Resulting values are listed under `# OUTPUTS` with comments (and can be
|
57
|
+
accessed with getter methods under the same name).
|
58
|
+
|
59
|
+
[Further documentation on field names is available from official
|
60
|
+
government resources](https://www.bmf-steuerrechner.de/interface/pap.jsp)
|
61
|
+
|
62
|
+
### Einkommensteuer
|
63
|
+
```ruby
|
64
|
+
require 'taxger'
|
65
|
+
|
66
|
+
# calculate income tax for 2015:
|
67
|
+
tax = Taxger::Einkommensteuer.calculate(2015, 70_000 * 100)
|
68
|
+
puts tax.ekst # => 21138_00 (Income tax in cents)
|
69
|
+
puts tax.solz # => 1162_59 (Solidaritätszuschlag in cents)
|
70
|
+
```
|
71
|
+
|
72
|
+
## Development
|
73
|
+
|
74
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
75
|
+
|
76
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
77
|
+
|
78
|
+
### Regenerating source files
|
79
|
+
|
80
|
+
The code to calculate Lohnsteuer (see files in `lib/taxger/lohnsteuer/`
|
81
|
+
are auto generated from XML pseudo code given by the Ministery of
|
82
|
+
Finance.
|
83
|
+
|
84
|
+
To regenerate or update these files, have a look into `src/README.md`.
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mpm/taxger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
89
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
src = File.expand_path('../src/', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(src) unless $LOAD_PATH.include?(src)
|
3
|
+
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require './src/converter.rb'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
|
10
|
+
task :default => :spec
|
11
|
+
|
12
|
+
namespace :taxger do
|
13
|
+
namespace :source do
|
14
|
+
task :download do
|
15
|
+
Taxger::Converter.download_all!
|
16
|
+
end
|
17
|
+
|
18
|
+
task :generate do
|
19
|
+
Taxger::Converter.generate_all!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "taxger"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
module Taxger
|
2
|
+
module Einkommensteuer
|
3
|
+
class Error < StandardError; end
|
4
|
+
class Result
|
5
|
+
attr_accessor :ekst, :solz
|
6
|
+
|
7
|
+
def initialize(ekst, solz)
|
8
|
+
@ekst = ekst
|
9
|
+
@solz = solz
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
extend self
|
14
|
+
|
15
|
+
F = 10**-8
|
16
|
+
|
17
|
+
ZONES = {
|
18
|
+
# Values are taken from this table:
|
19
|
+
# https://de.wikipedia.org/wiki/Einkommensteuer_(Deutschland)#Entwicklung_der_Parameter
|
20
|
+
# Non-existent parameters for E(i) with i > 3 have to be replaced with nil
|
21
|
+
# Non-existent parameters for a(i) with i > 2 have to be 0.
|
22
|
+
'2010' => [
|
23
|
+
# E(0), a(1) * F, b(1), 0
|
24
|
+
[ 8_003, 912.17 * F, 0.14, 0],
|
25
|
+
|
26
|
+
# E(1), a(2) * F, b(2), S(1)
|
27
|
+
[ 13_469, 228.74 * F, 0.2397, 1038],
|
28
|
+
|
29
|
+
# E(2), a(3) (=0), b(3), S(2)
|
30
|
+
[ 52_881, 0, 0.42, 14_038.5],
|
31
|
+
|
32
|
+
# E(3), a(4) (=0), b(4), S(3)
|
33
|
+
[250_730, 0, 0.45, 97_134.5]
|
34
|
+
],
|
35
|
+
|
36
|
+
# no change from 2010
|
37
|
+
'2011' => [
|
38
|
+
[ 8_003, 912.17 * F, 0.14, 0],
|
39
|
+
[ 13_469, 228.74 * F, 0.2397, 1038],
|
40
|
+
[ 52_881, 0, 0.42, 14_038.5],
|
41
|
+
[250_730, 0, 0.45, 97_134.5]
|
42
|
+
],
|
43
|
+
|
44
|
+
# no change from 2010
|
45
|
+
'2012' => [
|
46
|
+
[ 8_003, 912.17 * F, 0.14, 0],
|
47
|
+
[ 13_469, 228.74 * F, 0.2397, 1038],
|
48
|
+
[ 52_881, 0, 0.42, 14_038.5],
|
49
|
+
[250_730, 0, 0.45, 97_134.5]
|
50
|
+
],
|
51
|
+
|
52
|
+
'2013' => [
|
53
|
+
[ 8_130, 933.70 * F, 0.14, 0],
|
54
|
+
[ 13_469, 228.74 * F, 0.2397, 1014],
|
55
|
+
[ 52_881, 0, 0.42, -8196 + 0.42 * 52_881],
|
56
|
+
[250_730, 0, 0.45, -15718 + 0.45 * 250_730]
|
57
|
+
],
|
58
|
+
|
59
|
+
'2014' => [
|
60
|
+
[ 8_354, 974.58 * F, 0.14, 0],
|
61
|
+
[ 13_469, 228.74 * F, 0.2397, 971],
|
62
|
+
[ 52_881, 0, 0.42, -8239 + 0.42 * 52_881],
|
63
|
+
[250_730, 0, 0.45, -15761 + 0.45 * 250_730]
|
64
|
+
],
|
65
|
+
|
66
|
+
'2015' => [
|
67
|
+
[ 8_472, 997.6 * F, 0.14, 0],
|
68
|
+
[ 13_469, 228.74 * F, 0.2397, 948.68],
|
69
|
+
[ 52_881, 0, 0.42, 13_949],
|
70
|
+
[250_730, 0, 0.45, 97_045]
|
71
|
+
],
|
72
|
+
|
73
|
+
'2016' => [
|
74
|
+
[ 8_652, 993.62 * F, 0.14, 0],
|
75
|
+
[ 13_669, 225.40 * F, 0.2397, 952.48],
|
76
|
+
[ 53_665, 0, 0.42, -8394.14 + 0.42 * 53_665],
|
77
|
+
[254_447, 0, 0.45, -16027.52 + 0.45 * 254_447]
|
78
|
+
],
|
79
|
+
}
|
80
|
+
|
81
|
+
def calculate(year, income)
|
82
|
+
if !ZONES[year.to_s]
|
83
|
+
raise Einkommensteuer::Error.new("No data available for year #{year}")
|
84
|
+
end
|
85
|
+
|
86
|
+
income = income * 0.01
|
87
|
+
ZONES[year.to_s].reverse.each do |zone|
|
88
|
+
(zone_start, a, b, c) = zone
|
89
|
+
if income >= zone_start + 1
|
90
|
+
taxable = income - zone_start
|
91
|
+
tax = (a * (taxable ** 2) + b * taxable + c).to_i * 100
|
92
|
+
|
93
|
+
# Vereinfachte Berechnung des Solidaritätszuschlagsfreibetrags:
|
94
|
+
# Nicht gültig für Steuerklasse III (162 EUR statt 81 EUR) und abweichend,
|
95
|
+
# wenn Lohnsteuer in verschiedenen Monaten jeweils unter- und überhalb der
|
96
|
+
# Grenze lag.
|
97
|
+
solz = tax > 81_00 * 12 ? (tax * 0.055).to_i : 0
|
98
|
+
return Result.new(tax, solz)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
Result.new(0, 0)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Taxger
|
2
|
+
module Lohnsteuer
|
3
|
+
class BigDecimal < Numeric::BigDecimal
|
4
|
+
def multiply(value)
|
5
|
+
BigDecimal.new(self * value)
|
6
|
+
end
|
7
|
+
|
8
|
+
def subtract(value)
|
9
|
+
BigDecimal.new(self - value)
|
10
|
+
end
|
11
|
+
|
12
|
+
def divide(value, scale = nil, rounding=nil)
|
13
|
+
if scale && rounding
|
14
|
+
BigDecimal.new(self / value).set_scale(scale, rounding)
|
15
|
+
elsif scale
|
16
|
+
BigDecimal.new(self / value).set_scale(scale)
|
17
|
+
else
|
18
|
+
BigDecimal.new(self / value)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def add(value)
|
23
|
+
BigDecimal.new(self + value)
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_scale(scale, rounding=nil)
|
27
|
+
if rounding
|
28
|
+
BigDecimal.new(self.round(scale, rounding))
|
29
|
+
else
|
30
|
+
BigDecimal.new(self.round(scale))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def compare_to(value)
|
35
|
+
if self < value
|
36
|
+
-1
|
37
|
+
elsif self == value
|
38
|
+
0
|
39
|
+
elsif self > value
|
40
|
+
1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.value_of(float)
|
45
|
+
new(float, 16)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.ZERO
|
49
|
+
new(0)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.ONE
|
53
|
+
new(1)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.TEN
|
57
|
+
new(10)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.ROUND_UP
|
61
|
+
BigDecimal::ROUND_UP
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.ROUND_DOWN
|
65
|
+
BigDecimal::ROUND_DOWN
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|