def SetupYearRecForIncomeTax( self, earnings=0, oas=0, gis=0, cpp=0, ei=0, rrsp=0, bridging=0,nonreg=0, gains=0, eoy_gains=0, unapplied_losses=0, rrsp_contributions=0, age=30, retired=False, cpi=1): """Set up a person and a year record in one go for testing income tax.""" j_canuck = person.Person(strategy=self.default_strategy) j_canuck.capital_loss_carry_forward = unapplied_losses j_canuck.age += age - world.START_AGE j_canuck.year += age - world.START_AGE j_canuck.retired = retired year_rec = utils.YearRecord() year_rec.is_retired = j_canuck.retired year_rec.year = j_canuck.year year_rec.incomes.append(incomes.IncomeReceipt(earnings, incomes.INCOME_TYPE_EARNINGS)) year_rec.incomes.append(incomes.IncomeReceipt(oas, incomes.INCOME_TYPE_OAS)) year_rec.incomes.append(incomes.IncomeReceipt(gis, incomes.INCOME_TYPE_GIS)) year_rec.incomes.append(incomes.IncomeReceipt(cpp, incomes.INCOME_TYPE_CPP)) year_rec.incomes.append(incomes.IncomeReceipt(ei, incomes.INCOME_TYPE_EI)) year_rec.withdrawals.append(funds.WithdrawReceipt(nonreg, gains, funds.FUND_TYPE_NONREG)) year_rec.withdrawals.append(funds.WithdrawReceipt(rrsp, 0, funds.FUND_TYPE_RRSP)) year_rec.withdrawals.append(funds.WithdrawReceipt(bridging, 0, funds.FUND_TYPE_BRIDGING)) year_rec.tax_receipts.append(funds.TaxReceipt(eoy_gains, funds.FUND_TYPE_NONREG)) year_rec.deposits.append(funds.DepositReceipt(rrsp_contributions, funds.FUND_TYPE_RRSP)) year_rec.cpi = cpi year_rec = j_canuck.CalcPayrollDeductions(year_rec) return (j_canuck, year_rec)
def testGISCalcIncomeBaseCapitalGains(self): income = incomes.GIS() income.last_year_income_base = 10000 year_rec = utils.YearRecord() year_rec.withdrawals = [ funds.WithdrawReceipt(2000, 1000, funds.FUND_TYPE_NONREG) ] year_rec.tax_receipts = [funds.TaxReceipt(500, funds.FUND_TYPE_NONREG)] year_rec.ei_premium = 0 year_rec.cpp_contribution = 0 self.assertEqual(income._CalcIncomeBase(year_rec), 750)
def testNonRegisteredUpdateGainsIncrement(self): fund = funds.NonRegistered() fund.amount = 20 fund.unrealized_gains = 10 year_rec = utils.YearRecord() year_rec.growth_rate = 0.4 fund.Update(year_rec) self.assertEqual(fund.amount, 28) self.assertEqual(fund.unrealized_gains, 13.6) self.assertIn(funds.TaxReceipt(4.4, funds.FUND_TYPE_NONREG), year_rec.tax_receipts)