austax: Add Medicare levy surcharge

This commit is contained in:
RunasSudo 2024-08-16 22:20:45 +10:00
parent dd5b6c1242
commit dca300fd58
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 42 additions and 5 deletions

View File

@ -20,7 +20,7 @@ from drcr.models import AccountConfiguration, Amount, Metadata, Transaction, Tri
from drcr.reports import Calculated, Report, Section, Spacer, Subtotal, entries_for_kind from drcr.reports import Calculated, Report, Section, Spacer, Subtotal, entries_for_kind
from drcr.webapp import eofy_date, sofy_date from drcr.webapp import eofy_date, sofy_date
from .tax_tables import base_tax, medicare_levy_threshold, repayment_rates, fbt_grossup from .tax_tables import base_tax, medicare_levy_threshold, medicare_levy_surcharge_single, repayment_rates, fbt_grossup
def base_income_tax(year, taxable_income): def base_income_tax(year, taxable_income):
"""Get the amount of base income tax""" """Get the amount of base income tax"""
@ -59,6 +59,13 @@ def medicare_levy(year, taxable_income):
# Normal Medicare levy # Normal Medicare levy
return Amount(int(taxable_income.quantity * 0.02), '$') return Amount(int(taxable_income.quantity * 0.02), '$')
def medicare_levy_surcharge(year, taxable_income, rfb_grossedup):
mls_income = taxable_income + rfb_grossedup
for i, (upper_limit, rate) in enumerate(medicare_levy_surcharge_single[year]):
if upper_limit is None or mls_income.quantity <= upper_limit * (10**AMOUNT_DPS):
return Amount(rate * mls_income.quantity, '$')
def study_loan_repayment(year, taxable_income, rfb_grossedup): def study_loan_repayment(year, taxable_income, rfb_grossedup):
"""Get the amount of mandatory study loan repayment""" """Get the amount of mandatory study loan repayment"""
@ -165,6 +172,21 @@ def tax_summary_report():
bordered=True bordered=True
), ),
Spacer(), Spacer(),
Section(
entries=[
Calculated(
'Taxable value of reportable fringe benefits',
lambda _: -sum((e.amount for e in entries_for_kind(account_configurations, accounts, 'austax.rfb')), Amount(0, '$')),
id='rfb_taxable'
),
Calculated(
'Grossed-up value',
lambda _: Amount(report.by_id('rfb_taxable').amount.quantity * fbt_grossup[eofy_date().year], '$'),
id='rfb_grossedup'
)
],
visible=False # Precompute RFB amount as this is required for MLS
),
Section( Section(
entries=[ entries=[
Calculated( Calculated(
@ -175,6 +197,10 @@ def tax_summary_report():
'Medicare levy', 'Medicare levy',
lambda _: medicare_levy(eofy_date().year, report.by_id('taxable').amount) lambda _: medicare_levy(eofy_date().year, report.by_id('taxable').amount)
), ),
Calculated(
'Medicare levy surcharge',
lambda _: medicare_levy_surcharge(eofy_date().year, report.by_id('taxable').amount, report.by_id('rfb_grossedup').amount)
),
Subtotal('Total income tax', id='total_tax', bordered=True) Subtotal('Total income tax', id='total_tax', bordered=True)
] ]
), ),
@ -191,13 +217,11 @@ def tax_summary_report():
entries=[ entries=[
Calculated( Calculated(
'Taxable value of reportable fringe benefits', 'Taxable value of reportable fringe benefits',
lambda _: -sum((e.amount for e in entries_for_kind(account_configurations, accounts, 'austax.rfb')), Amount(0, '$')), lambda _: report.by_id('rfb_taxable').amount
id='rfb_taxable'
), ),
Calculated( Calculated(
'Grossed-up value', 'Grossed-up value',
lambda _: Amount(report.by_id('rfb_taxable').amount.quantity * fbt_grossup[eofy_date().year], '$'), lambda _: report.by_id('rfb_grossedup').amount
id='rfb_grossedup'
), ),
Calculated( Calculated(
'Mandatory study loan repayment', 'Mandatory study loan repayment',

View File

@ -91,6 +91,19 @@ medicare_levy_threshold = {
2022: (23365, 29207) 2022: (23365, 29207)
} }
# Medicare levy surcharge rates (singles)
# https://www.ato.gov.au/individuals-and-families/medicare-and-private-health-insurance/medicare-levy-surcharge/medicare-levy-surcharge-income-thresholds-and-rates
# Maps each financial year to list of (upper limit (INclusive), MLS rate)
# FIXME: Only supports singles
medicare_levy_surcharge_single = {
2024: [
(93000, 0),
(108000, 0.01),
(144000, 0.0125),
(None, 0.015)
]
}
# FBT type 1 gross-up factor # FBT type 1 gross-up factor
# https://www.ato.gov.au/rates/fbt/#GrossupratesforFBT # https://www.ato.gov.au/rates/fbt/#GrossupratesforFBT
fbt_grossup = { fbt_grossup = {