austax: Hide irrelevant reports
This commit is contained in:
parent
d50b6a0e0a
commit
3542d80483
@ -201,11 +201,13 @@ def tax_summary_report():
|
||||
),
|
||||
Calculated(
|
||||
'Medicare levy',
|
||||
lambda _: medicare_levy(eofy_date().year, report.by_id('taxable').amount)
|
||||
lambda _: medicare_levy(eofy_date().year, report.by_id('taxable').amount),
|
||||
auto_hide=True
|
||||
),
|
||||
Calculated(
|
||||
'Medicare levy surcharge',
|
||||
lambda _: medicare_levy_surcharge(eofy_date().year, report.by_id('taxable').amount, report.by_id('rfb_grossedup').amount)
|
||||
lambda _: medicare_levy_surcharge(eofy_date().year, report.by_id('taxable').amount, report.by_id('rfb_grossedup').amount),
|
||||
auto_hide=True
|
||||
),
|
||||
Subtotal('Total income tax', id='total_tax', bordered=True)
|
||||
]
|
||||
@ -214,33 +216,39 @@ def tax_summary_report():
|
||||
Section(
|
||||
title='Tax offsets',
|
||||
entries=entries_for_kind(account_configurations, accounts, 'austax.offset', neg=True) + [
|
||||
Calculated('Low income tax offset', lambda _: lito(report.by_id('taxable').amount, report.by_id('total_tax').amount)),
|
||||
Calculated('Low income tax offset', lambda _: lito(report.by_id('taxable').amount, report.by_id('total_tax').amount), auto_hide=True),
|
||||
Subtotal('Total tax offsets', id='offsets')
|
||||
]
|
||||
],
|
||||
auto_hide=True
|
||||
),
|
||||
Spacer(),
|
||||
Section(
|
||||
entries=[
|
||||
Calculated(
|
||||
'Taxable value of reportable fringe benefits',
|
||||
lambda _: report.by_id('rfb_taxable').amount
|
||||
lambda _: report.by_id('rfb_taxable').amount,
|
||||
auto_hide=True
|
||||
),
|
||||
Calculated(
|
||||
'Grossed-up value',
|
||||
lambda _: report.by_id('rfb_grossedup').amount
|
||||
lambda _: report.by_id('rfb_grossedup').amount,
|
||||
auto_hide=True
|
||||
),
|
||||
Calculated(
|
||||
'Mandatory study loan repayment',
|
||||
lambda _: study_loan_repayment(eofy_date().year, report.by_id('taxable').amount, report.by_id('rfb_grossedup').amount),
|
||||
id='loan_repayment',
|
||||
heading=True
|
||||
heading=True,
|
||||
auto_hide=True
|
||||
)
|
||||
]
|
||||
],
|
||||
auto_hide=True
|
||||
),
|
||||
Spacer(),
|
||||
Section(
|
||||
title='PAYG withheld amounts',
|
||||
entries=entries_for_kind(account_configurations, accounts, 'austax.paygw') + [Subtotal('Total withheld amounts', id='paygw')]
|
||||
entries=entries_for_kind(account_configurations, accounts, 'austax.paygw') + [Subtotal('Total withheld amounts', id='paygw')],
|
||||
auto_hide=True
|
||||
),
|
||||
Spacer(),
|
||||
Calculated(
|
||||
|
@ -58,8 +58,8 @@ class Section:
|
||||
entry.calculate(self)
|
||||
|
||||
if self.auto_hide and self.visible:
|
||||
if not any(isinstance(e, Entry) for e in self.entries):
|
||||
# Auto hide if no entries (other than Subtotal)
|
||||
if not any(isinstance(e, Entry) and e.visible for e in self.entries):
|
||||
# Auto hide if no visible entries (other than Subtotal)
|
||||
self.visible = False
|
||||
|
||||
# Hide next Spacer
|
||||
@ -82,11 +82,12 @@ class Section:
|
||||
return None
|
||||
|
||||
class Entry:
|
||||
def __init__(self, text=None, amount=None, *, id=None, visible=True, link=None, heading=False, bordered=False):
|
||||
def __init__(self, text=None, amount=None, *, id=None, visible=True, auto_hide=False, link=None, heading=False, bordered=False):
|
||||
self.text = text
|
||||
self.amount = amount
|
||||
self.id = id
|
||||
self.visible = visible
|
||||
self.auto_hide = auto_hide
|
||||
self.link = link
|
||||
self.heading = heading
|
||||
self.bordered = bordered
|
||||
@ -120,6 +121,10 @@ class Calculated(Entry):
|
||||
|
||||
def calculate(self, parent):
|
||||
self.amount = self.calc(parent)
|
||||
|
||||
if self.auto_hide and self.visible:
|
||||
if self.amount.quantity == 0:
|
||||
self.visible = False
|
||||
|
||||
class Spacer:
|
||||
id = None
|
||||
|
Loading…
Reference in New Issue
Block a user