Class: IncomeTax::Countries::Canada

Inherits:
Models::Generic show all
Defined in:
lib/income_tax/countries/canada.rb,
lib/income_tax/countries/canada/yukon.rb,
lib/income_tax/countries/canada/quebec.rb,
lib/income_tax/countries/canada/alberta.rb,
lib/income_tax/countries/canada/federal.rb,
lib/income_tax/countries/canada/nunavut.rb,
lib/income_tax/countries/canada/ontario.rb,
lib/income_tax/countries/canada/manitoba.rb,
lib/income_tax/countries/canada/nova_scotia.rb,
lib/income_tax/countries/canada/saskatchewan.rb,
lib/income_tax/countries/canada/new_brunswick.rb,
lib/income_tax/countries/canada/british_columbia.rb,
lib/income_tax/countries/canada/prince_edward_island.rb,
lib/income_tax/countries/canada/northwest_territories.rb,
lib/income_tax/countries/canada/newfoundland_and_labrador.rb

Defined Under Namespace

Classes: Alberta, BritishColumbia, Federal, Manitoba, NewBrunswick, NewfoundlandAndLabrador, NorthwestTerritories, NovaScotia, Nunavut, Ontario, PrinceEdwardIsland, Quebec, Saskatchewan, Yukon

Constant Summary collapse

TerritoryRegister =
Register.new("territory")
Territory =
Class.new(Models::Progressive) { register_on TerritoryRegister }

Instance Attribute Summary

Attributes inherited from Models::Generic

#gross_income, #net_income, #options, #rate, #taxes

Instance Method Summary collapse

Methods inherited from Models::Generic

#based_on?, #cast_value, #cast_values, currency, #initialize, #inspect, lazy, #location_name, method_added, name, names, new, other_names, register, register_on, #set_default_options, #validate, wants_options

Constructor Details

This class inherits a constructor from IncomeTax::Models::Generic

Instance Method Details

#calculateObject



23
24
25
# File 'lib/income_tax/countries/canada.rb', line 23

def calculate
  @taxes = federal_taxes + territorial_taxes
end

#federal_taxesObject



19
20
21
# File 'lib/income_tax/countries/canada.rb', line 19

def federal_taxes
  @federal.taxes
end

#setup(**options) ⇒ Object



9
10
11
12
# File 'lib/income_tax/countries/canada.rb', line 9

def setup(**options)
  @federal   = Federal.new(**options)
  @territory = TerritoryRegister[territory].new(**options) if territory?
end

#territorial_taxesObject



14
15
16
17
# File 'lib/income_tax/countries/canada.rb', line 14

def territorial_taxes
  return 0 unless territory?
  @territory.taxes
end