예제 #1
0
 def testEarningsUnemployed(self):
     income = incomes.Earnings()
     amount, taxable, year_rec = income.GiveMeMoney(utils.YearRecord())
     self.assertEqual(amount, 0)
     self.assertEqual(taxable, True)
     self.assertIn(incomes.IncomeReceipt(0, incomes.INCOME_TYPE_EARNINGS),
                   year_rec.incomes)
예제 #2
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
        }
예제 #3
0
 def testEarningsEmployedNegativeRandom(self):
     income = incomes.Earnings()
     year_rec = utils.YearRecord()
     year_rec.is_employed = True
     with unittest.mock.patch('random.normalvariate') as my_random:
         my_random.return_value = -10000
         amount, taxable, year_rec = income.GiveMeMoney(year_rec)
         self.assertEqual(amount, 0)
         self.assertEqual(taxable, True)
         self.assertIn(
             incomes.IncomeReceipt(0, incomes.INCOME_TYPE_EARNINGS),
             year_rec.incomes)