-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module GuiltFree | ||
def build_guilt_free_vars! | ||
@guilt_free_salary = GuiltFreeCalculator.new(@salary_taxed.total_net_income, salary_savings_totalizer) | ||
@guilt_free_hourly = GuiltFreeCalculator.new(@hourly_taxed.total_net_income, hourly_savings_totalizer) | ||
end | ||
|
||
def salary_savings_totalizer | ||
@salary_saving.annual_saving + @salary_invest.annual_saving | ||
# @salary_saving + @salary_investing | ||
end | ||
|
||
def hourly_savings_totalizer | ||
@hourly_saving.annual_saving + @salary_invest.annual_saving | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
class GuiltFreeCalculator | ||
attr_reader :annual_guilt_free, | ||
:biannual_guilt_free, | ||
:quarterly_guilt_free, | ||
:monthly_guilt_free, | ||
:bi_weekly_guilt_free, | ||
:weekly_guilt_free, | ||
:daily_guilt_free | ||
|
||
def initialize(taxed_income, savings_totals) | ||
@taxed_income = taxed_income | ||
@savings_totals = savings_totals | ||
@annual_guilt_free = calculate_annual_guilt_free | ||
@biannual_guilt_free = calculate_biannual_guilt_free | ||
@quarterly_guilt_free = calculate_quarterly_guilt_free | ||
@monthly_guilt_free = calculate_monthly_guilt_free | ||
@bi_weekly_guilt_free = calculate_bi_weekly_guilt_free | ||
@weekly_guilt_free = calculate_weekly_guilt_free | ||
@daily_guilt_free = calculate_daily_guilt_free | ||
end | ||
|
||
def calculate_annual_guilt_free | ||
@taxed_income - @savings_totals | ||
end | ||
|
||
def calculate_biannual_guilt_free | ||
@annual_guilt_free / 2 | ||
end | ||
|
||
def calculate_quarterly_guilt_free | ||
@annual_guilt_free / 4 | ||
end | ||
|
||
def calculate_monthly_guilt_free | ||
@annual_guilt_free / 12 | ||
end | ||
|
||
def calculate_bi_weekly_guilt_free | ||
@annual_guilt_free / 26 | ||
end | ||
|
||
def calculate_weekly_guilt_free | ||
@annual_guilt_free / 52 | ||
end | ||
|
||
def calculate_daily_guilt_free | ||
@annual_guilt_free / 365 | ||
end | ||
end |