Ejemplo n.º 1
0
 def testCPPDuringWorkingPeriod(self):
     income = incomes.CPP()
     amount, taxable, year_rec = income.GiveMeMoney(utils.YearRecord())
     self.assertEqual(amount, 0)
     self.assertEqual(taxable, True)
     self.assertIn(incomes.IncomeReceipt(0, incomes.INCOME_TYPE_CPP),
                   year_rec.incomes)
Ejemplo n.º 2
0
 def testCPPAnnualUpdateZeroEarnings(self):
     income = incomes.CPP()
     income.ympe_fractions = []
     year_rec = utils.YearRecord()
     year_rec.is_retired = False
     year_rec.pensionable_earnings = 0
     income.AnnualUpdate(year_rec)
     self.assertEqual(income.ympe_fractions, [0])
Ejemplo n.º 3
0
 def testCPPAnnualUpdatePositiveEarnings(self):
     income = incomes.CPP()
     income.ympe_fractions = []
     year_rec = utils.YearRecord()
     year_rec.is_retired = False
     year_rec.pensionable_earnings = 100
     income.AnnualUpdate(year_rec)
     self.assertEqual(income.ympe_fractions, [100 / world.YMPE])
Ejemplo n.º 4
0
 def testCPPRetired63AllPositiveEarnings(self):
     income = incomes.CPP()
     income.ympe_fractions = [0.8] * 40 + [0] * 5
     fake_person = unittest.mock.MagicMock()
     fake_person.age = 63
     fake_person.year = 2047
     fake_person.cpi_history = [1, 1, 1, 1, 1, 1]
     income.OnRetirement(fake_person)
     self.assertAlmostEqual(income.benefit_amount, 12115.6655268)
Ejemplo n.º 5
0
 def testCPPRetired72AllPositiveEarnings(self):
     income = incomes.CPP()
     income.ympe_fractions = [0.8] * 49 + [0] * 5
     fake_person = unittest.mock.MagicMock()
     fake_person.age = 72
     fake_person.year = 2056
     fake_person.cpi_history = [1, 1, 1, 1, 1, 1]
     income.OnRetirement(fake_person)
     self.assertAlmostEqual(income.benefit_amount, 21981.3428000)
Ejemplo n.º 6
0
 def testCPPRetired68AllPositiveEarnings(self):
     income = incomes.CPP()
     income.ympe_fractions = [0.8] * 45 + [0] * 5
     fake_person = unittest.mock.MagicMock()
     fake_person.age = 68
     fake_person.year = 2052
     fake_person.cpi_history = [1, 1, 1, 1, 1, 1]
     income.OnRetirement(fake_person)
     self.assertAlmostEqual(income.benefit_amount, 18624.5036950)
Ejemplo n.º 7
0
 def testCPPRetired65IncludesZeroEarnings(self):
     income = incomes.CPP()
     income.ympe_fractions = [0.8] * 37 + [0] * 10
     fake_person = unittest.mock.MagicMock()
     fake_person.age = 65
     fake_person.year = 2049
     fake_person.cpi_history = [1, 1, 1, 1, 1, 1]
     income.OnRetirement(fake_person)
     self.assertAlmostEqual(income.benefit_amount, 13694.3691932)
Ejemplo n.º 8
0
    def __init__(self,
                 strategy,
                 gender=FEMALE,
                 basic_only=False,
                 real_values=True):
        self.year = world.BASE_YEAR
        self.age = world.START_AGE
        self.gender = gender
        self.strategy = strategy
        self.cpi = 1  # Ignoring factor of 100 and StatsCan rounding rules here.
        self.cpi_history = []
        self.basic_only = basic_only
        self.real_values = real_values
        self.employed_last_year = True
        self.retired = False
        # CAUTION: GIS must be the last income in the list.
        self.incomes = [
            incomes.Earnings(),
            incomes.EI(),
            incomes.CPP(),
            incomes.OAS(),
            incomes.GIS()
        ]
        self.funds = {
            "wp_tfsa": funds.TFSA(),
            "wp_rrsp": funds.RRSP(),
            "wp_nonreg": funds.NonRegistered()
        }
        self.involuntary_retirement_random = random.random()
        self.tfsa_room = world.TFSA_INITIAL_CONTRIBUTION_LIMIT
        self.rrsp_room = world.RRSP_INITIAL_LIMIT
        self.capital_loss_carry_forward = 0

        self.accumulators = utils.AccumulatorBundle()
        self.has_been_ruined = False
        self.has_received_gis = False
        self.has_experienced_income_under_lico = False

        # The following hold real dollar amounts
        self.assets_at_retirement = 0
        self.total_retirement_withdrawals = 0
        self.total_lifetime_withdrawals = 0
        self.total_working_savings = 0

        self.positive_earnings_years = 0
        self.positive_savings_years = 0
        self.ei_years = 0
        self.gis_years = 0
        self.gross_income_below_lico_years = 0
        self.no_assets_years = 0

        self.period_years = {
            EMPLOYED: 0,
            UNEMPLOYED: 0,
            RETIRED: 0,
            INVOLUNTARILY_RETIRED: 0
        }
Ejemplo n.º 9
0
 def testCPPRetired65AllPositiveEarningsWithInflation(self):
     income = incomes.CPP()
     income.ympe_fractions = [0.8] * 42 + [0] * 5
     fake_person = unittest.mock.MagicMock()
     fake_person.age = 65
     fake_person.year = 2049
     # We use a silly value for the current year's CPI to check we aren't using it.
     fake_person.cpi_history = [1, 1.02, 1.0404, 1.061208, 1.08243216, 100]
     income.OnRetirement(fake_person)
     self.assertAlmostEqual(income.benefit_amount, 15033.4266907)