示例#1
0
def calculate_net_income(gross_super_eligible_income, gross_annual_income, current_student_loans):
    net_annual_income = gross_annual_income
    salary_sacrifice_total = calculate_salary_sacrifice(gross_super_eligible_income)

    net_annual_income -= calculate_student_loans(gross_annual_income, current_student_loans)
    net_annual_income -= salary_sacrifice_total
    net_annual_income -= calculate_tax(gross_annual_income - salary_sacrifice_total)
    salary_sacrifice_income = salary_sacrifice_total * (1 - SALARY_SACRIFICE_TAX_RATE)
    return net_annual_income + salary_sacrifice_income
def main_calculation(current_savings, current_salary,
                     current_compensation_package, current_student_loans,
                     current_expenses):

    goal_savings = current_expenses / WITHDRAWAL_RATE
    months = 0
    total_savings = current_savings

    while total_savings < goal_savings and months < 1000:
        months += 1
        total_savings *= MONTHLY_GROWTH_RATE
        goal_savings *= MONTHLY_INFLATION_RATE

        net_income = calculate_monthly_net_income(
            current_salary, current_compensation_package,
            current_student_loans)
        current_student_loans -= calculate_student_loans(
            current_salary, current_student_loans)

        expenses = current_expenses / 12
        total_savings += (net_income - expenses)

    print(str(months))
    print(str(int(total_savings)) + " / " + str(int(goal_savings)))
示例#3
0
 def test_calculate_student_loans_at_low_threshold(self):
     student_loan_repayment = calculate_student_loans(50000, 100000)
     self.assertEqual(student_loan_repayment, 500)
示例#4
0
 def test_calculate_student_loans_from_zero_income(self):
     student_loan_repayment = calculate_student_loans(0, 100000)
     self.assertEqual(student_loan_repayment, 0)
示例#5
0
 def test_calculate_student_loans_with_partial_payment_remaining(self):
     student_loan_repayment = calculate_student_loans(150000, 10000)
     self.assertEqual(student_loan_repayment, 10000)
示例#6
0
 def test_calculate_student_loans_at_no_loan_remaining(self):
     student_loan_repayment = calculate_student_loans(150000, 0)
     self.assertEqual(student_loan_repayment, 0)
示例#7
0
 def test_calculate_student_loans_at_middle_threshold(self):
     student_loan_repayment = calculate_student_loans(76000, 100000)
     self.assertEqual(student_loan_repayment, 3800)