Sha256: 10c9f1a875abf9a7257b347ab80922f63f50792274e2104a4e6f7ed88f0c6797
Contents?: true
Size: 960 Bytes
Versions: 1
Compression:
Stored size: 960 Bytes
Contents
# frozen_string_literal: true module TaxCalculator module Federal # 2021 BRACKETS = { :married => { 10.0 => 19_900.00, 12.0 => 81_050.00, 22.0 => 172_750.00, 24.0 => 329_850.00, 32.0 => 418_850.00, 35.0 => 628_300.00, 37.0 => :remaining }.freeze }.freeze def self.taxes_for(income) previous_amount = 0 taxes_owed = 0 BRACKETS[:married].each_pair do |bracket, amount| if amount == :remaining taxes_owed = taxes_owed + ((income - previous_amount) * (bracket / 100)) break end if income < amount taxes_owed = taxes_owed + ((income - previous_amount) * (bracket / 100)) break end taxes_owed = taxes_owed + ((amount - previous_amount) * (bracket / 100)) previous_amount = amount break if amount == income end taxes_owed.round(2) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tax_calculator-0.3.0 | lib/tax_calculator/federal.rb |