Skip to content

Commit

Permalink
Merge remote-tracking branch 'wundertax/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mpm committed Nov 11, 2018
2 parents 532fd3e + 6aa6979 commit 5f55d82
Show file tree
Hide file tree
Showing 9 changed files with 2,321 additions and 7 deletions.
16 changes: 13 additions & 3 deletions lib/taxger/einkommensteuer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(ekst, solz)
ZONES = {
# Values are taken from this table:
# https://de.wikipedia.org/wiki/Einkommensteuer_(Deutschland)#Entwicklung_der_Parameter
# Non-existent parameters for E(i) with i > 3 have to be replaced with nil
# Non-existent parameters for E(i) with i > 3 have to be replaced with nil
# Non-existent parameters for a(i) with i > 2 have to be 0.
'2010' => [
# E(0), a(1) * F, b(1), 0
Expand Down Expand Up @@ -76,19 +76,29 @@ def initialize(ekst, solz)
[ 53_665, 0, 0.42, -8394.14 + 0.42 * 53_665],
[254_447, 0, 0.45, -16027.52 + 0.45 * 254_447]
],

'2017' => [
[ 8_820, 1_007.27 * F, 0.14, 0],
[ 13_769, 223.76 * F, 0.2397, 939.57],
[ 54_057, 0, 0.42, 14_228.5],
[256_303, 0, 0.45, 99_171.82]
]
}

def calculate(year, income)
def calculate(year, income, pay_taxes_on = nil)
if !ZONES[year.to_s]
raise Einkommensteuer::Error.new("No data available for year #{year}")
end

pay_taxes_on ||= income
pay_taxes_on = pay_taxes_on * 0.01
income = income * 0.01
ZONES[year.to_s].reverse.each do |zone|
(zone_start, a, b, c) = zone
if income >= zone_start + 1
taxable = income - zone_start
tax = (a * (taxable ** 2) + b * taxable + c).to_i * 100
tax = (a * (taxable ** 2) + b * taxable + c)#.to_i * 100
tax = (((tax/income)*pay_taxes_on)).to_i * 100

# Vereinfachte Berechnung des Solidaritätszuschlagsfreibetrags:
# Nicht gültig für Steuerklasse III (162 EUR statt 81 EUR) und abweichend,
Expand Down
2 changes: 2 additions & 0 deletions lib/taxger/lohnsteuer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
require 'taxger/lohnsteuer/lohnsteuer2015'
require 'taxger/lohnsteuer/lohnsteuer2015dezember'
require 'taxger/lohnsteuer/lohnsteuer2016'
require 'taxger/lohnsteuer/lohnsteuer2017'
require 'taxger/lohnsteuer/lohnsteuer2018'

module Taxger
module Lohnsteuer
Expand Down
4 changes: 3 additions & 1 deletion lib/taxger/lohnsteuer/bigdecimal.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'bigdecimal'

module Taxger
module Lohnsteuer
class BigDecimal < Numeric::BigDecimal
class BigDecimal < BigDecimal
def multiply(value)
BigDecimal.new(self * value)
end
Expand Down
1,144 changes: 1,144 additions & 0 deletions lib/taxger/lohnsteuer/lohnsteuer2017.rb

Large diffs are not rendered by default.

1,144 changes: 1,144 additions & 0 deletions lib/taxger/lohnsteuer/lohnsteuer2018.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/taxger/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Taxger
VERSION = "0.2.0"
VERSION = "0.3.1"
end
9 changes: 8 additions & 1 deletion spec/einkommensteuer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ module Taxger
[2016, 20_000_00, 2_560_00, 140_80],
[2016, 50_000_00, 12_636_00, 694_98],
[2016, 70_000_00, 21_005_00, 1_155_27],
[2016, 260_000_00, 100_972_00, 5_553_46]
[2016, 260_000_00, 100_972_00, 5_553_46],

[2017, 5_000_00, 0, 0],
[2017, 10_000_00, 179_00, 0],
[2017, 20_000_00, 2_520_00, 138_60],
[2017, 50_000_00, 12_561_00, 690_85],
[2017, 70_000_00, 20_924_00, 1_150_82],
[2017, 260_000_00, 100_835_00, 5_545_92]
].each do |dataset|
(year, brutto, ekst, solz) = dataset
it "calculates Einkommensteuer for #{brutto / 100.0} EUR in #{year}" do
Expand Down
5 changes: 4 additions & 1 deletion spec/lohnsteuer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ module Lohnsteuer
'2013' => [17_560, 965.80],
'2014' => [17_348, 954.14],
'2015' => [17_376, 955.68],
'2015Dezember' => [17_354, 954.47]
'2015Dezember' => [17_354, 954.47],
'2016' => [17_065, 938.57],
'2017' => [16_805, 924.27],
'2018' => [16_528, 909.04]
}.each do |year, fields|
it "calculates Lohnsteuer and Solidaritätszuschlag #{year}" do
tax = Lohnsteuer.calculate(year, stkl: 1, lzz: 1, re4: 70_000 * 100)
Expand Down
2 changes: 2 additions & 0 deletions src/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Converter
GENERATED_PATH = File.expand_path('../generated/', __FILE__)
URI = 'https://www.bmf-steuerrechner.de/pruefdaten/'
FILES = {
'Lohnsteuer2018.xml' => 'Lohnsteuer2018',
'Lohnsteuer2017.xml' => 'Lohnsteuer2017',
'Lohnsteuer2016.xml' => 'Lohnsteuer2016',
'Lohnsteuer2015Dezember.xml' => 'Lohnsteuer2015Dezember',
'Lohnsteuer2015BisNovember.xml' => 'Lohnsteuer2015',
Expand Down

0 comments on commit 5f55d82

Please sign in to comment.