Skip to content

Commit

Permalink
Refactor how fed tax is calculated (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
neb417 authored Jan 8, 2024
1 parent dbb461d commit bc7b1dc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/services/income_tax_calculator_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def initialize(income:)

def calculate_fed_tax
bracket = FederalTaxBracket.where("bottom_range_cents <= ?", @annual_income.cents).order(:bottom_range_cents).last
rated = bracket.rate * @annual_income
taxable_at_bracket_rate = Money.new(@annual_income.cents - bracket.bottom_range_cents)
rated = bracket.rate * taxable_at_bracket_rate
rated + bracket.cumulative
end

Expand Down

0 comments on commit bc7b1dc

Please sign in to comment.