Module: Lohnsteuer
- Defined in:
- lib/lohnsteuer.rb,
lib/lohnsteuer/version.rb
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
- .calculate(year, annual_salary, options = {}) ⇒ Object
- .calculate_month(year, month, monthly_salary, options = {}) ⇒ Object
- .tax_algorithms ⇒ Object
Class Method Details
.calculate(year, annual_salary, options = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/lohnsteuer.rb', line 53 def self.calculate(year, annual_salary, = {}) (1..12).map do |month| calculate_month(year, month, annual_salary / 12.0, ) end.inject(income_tax: 0, solidarity_tax: 0) do |res, item| res[:income_tax] = res[:income_tax] + item[:income_tax] res[:solidarity_tax] = res[:solidarity_tax] + item[:solidarity_tax] res end end |
.calculate_month(year, month, monthly_salary, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lohnsteuer.rb', line 12 def self.calculate_month(year, month, monthly_salary, = {}) params = { # The tax class must be 1, 2, 3, 4, 5 or 6. STKL: [:tax_class] || 1, # Monthly salary in Euro cent. RE4: monthly_salary * 100.0, # Configure the algorithm to calculate monthly taxes. LZZ: 2, # Health insurance state. # 0 = general health insurance. # 1 = private health insurance without employer supplement. # 2 = private health insurance with employer supplement. PKV: [:health_insurance_state] || 0, # Additional contribution rate to the general health insurance. KVZ: [:additional_contribution_rate] || 1.10, # Allow to deselect the calculation of the nursing care insurance. PVZ: [:no_nursing_care_insurance] ? 0 : 1, # Number of children eligible for the children allowance. ZKF: [:children] || 0 } algorithm = tax_algorithms.find { |c| c.applies?(Date.new(year, month, 1)) } fail "No tax algorithm found for #{month}/#{year}" unless algorithm res = algorithm.calculate(params) total_income_tax = (res[:LSTLZZ] || 0) + (res[:STS] || 0) + (res[:STV] || 0) total_solidarity_tax = (res[:SOLZLZZ] || 0) + (res[:SOLZS] || 0) + (res[:SOLZV] || 0) { income_tax: total_income_tax / 100.0, solidarity_tax: total_solidarity_tax / 100.0 } end |