Skip to content

Commit

Permalink
Refactor incomes methods in concern.
Browse files Browse the repository at this point in the history
  • Loading branch information
neb417 committed Jul 12, 2024
1 parent 8c2bcd7 commit a13cbf3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/controllers/concerns/taxed_income.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
module TaxedIncome
extend ActiveSupport::Concern

def tax_on_salary
income = Income.find_by(income_type: "Salary")
IncomeTaxCalculatorService.new(income: income)
end

def tax_on_hourly
income = Income.find_by(income_type: "Hourly")
IncomeTaxCalculatorService.new(income: income)
included do
before_action :salary_income, :hourly_income
end

def build_taxed_income_vars!
@salary_taxed = tax_on_salary
@hourly_taxed = tax_on_hourly
end
end

private

def salary_income
@salary_income ||= Income.find_by(income_type: "Salary")
end

def hourly_income
@hourly_income ||= Income.find_by(income_type: "Hourly")
end
end

0 comments on commit a13cbf3

Please sign in to comment.