austax: Add tax offset accounts

This commit is contained in:
RunasSudo 2025-06-02 23:29:51 +10:00
parent 815b4843e2
commit c798bd2207
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -272,6 +272,23 @@ function reporting.CalculateIncomeTax.execute(args, context, kinds_for_account,
}}) }})
table.insert(report.entries, 'Spacer') table.insert(report.entries, 'Spacer')
-- Add tax offset entries
local total_offset = 0
do
local entries = entries_for_kind('austax.offset', true, balances, kinds_for_account)
if #entries ~= 0 then
local section: libdrcr.Section = {
text = 'Tax offsets',
id = nil,
visible = true,
entries = entries,
}
table.insert(report.entries, { Section = section })
total_offset += entries_subtotal(entries)
end
end
-- Low income tax offset row -- Low income tax offset row
local offset_lito = calc.lito(net_taxable, tax_total, context) local offset_lito = calc.lito(net_taxable, tax_total, context)
if offset_lito ~= 0 then if offset_lito ~= 0 then
@ -284,14 +301,14 @@ function reporting.CalculateIncomeTax.execute(args, context, kinds_for_account,
heading = false, heading = false,
bordered = false, bordered = false,
}}) }})
total_offset += offset_lito
end end
-- Total tax offsets row -- Total tax offsets row
local offset_total = offset_lito if total_offset ~= 0 then
if offset_total ~= 0 then
table.insert(report.entries, { Row = { table.insert(report.entries, { Row = {
text = 'Total tax offsets', text = 'Total tax offsets',
quantity = {offset_total}, quantity = {total_offset},
id = nil, id = nil,
visible = true, visible = true,
link = nil, link = nil,
@ -347,17 +364,19 @@ function reporting.CalculateIncomeTax.execute(args, context, kinds_for_account,
-- Add PAYGW entries -- Add PAYGW entries
local total_paygw = 0 local total_paygw = 0
local entries = entries_for_kind('austax.paygw', false, balances, kinds_for_account)
if #entries ~= 0 then do
local section: libdrcr.Section = { local entries = entries_for_kind('austax.paygw', false, balances, kinds_for_account)
text = 'PAYG withheld amounts', if #entries ~= 0 then
id = nil, local section: libdrcr.Section = {
visible = true, text = 'PAYG withheld amounts',
entries = entries, id = nil,
} visible = true,
table.insert(report.entries, { Section = section }) entries = entries,
total_paygw = math.floor(entries_subtotal(entries) / 100) * 100 }
table.insert(report.entries, { Section = section })
total_paygw = math.floor(entries_subtotal(entries) / 100) * 100
end
end end
-- Total PAYGW row -- Total PAYGW row
@ -375,7 +394,7 @@ function reporting.CalculateIncomeTax.execute(args, context, kinds_for_account,
end end
-- ATO liability row -- ATO liability row
local ato_payable = tax_total - offset_total - total_paygw + study_loan_repayment local ato_payable = tax_total - total_offset - total_paygw + study_loan_repayment
table.insert(report.entries, { Row = { table.insert(report.entries, { Row = {
text = 'ATO liability payable (refundable)', text = 'ATO liability payable (refundable)',
quantity = {ato_payable}, quantity = {ato_payable},
@ -392,8 +411,8 @@ function reporting.CalculateIncomeTax.execute(args, context, kinds_for_account,
-- Estimated tax payable -- Estimated tax payable
if charge_tax_monthly then if charge_tax_monthly then
-- Charge income tax expense in parts, one per month -- Charge income tax expense in parts, one per month
local monthly_tax = math.floor((tax_total - offset_total) / 12) local monthly_tax = math.floor((tax_total - total_offset) / 12)
local last_month_tax = (tax_total - offset_total) - 11 * monthly_tax -- To account for rounding errors local last_month_tax = (tax_total - total_offset) - 11 * monthly_tax -- To account for rounding errors
-- Some ad hoc calendar code -- Some ad hoc calendar code
local eofy_year, eofy_month, _ = libdrcr.parse_date(context.eofy_date) local eofy_year, eofy_month, _ = libdrcr.parse_date(context.eofy_date)
@ -458,18 +477,18 @@ function reporting.CalculateIncomeTax.execute(args, context, kinds_for_account,
transaction_id = nil, transaction_id = nil,
description = nil, description = nil,
account = INCOME_TAX, account = INCOME_TAX,
quantity = (tax_total - offset_total), quantity = (tax_total - total_offset),
commodity = context.reporting_commodity, commodity = context.reporting_commodity,
quantity_ascost = (tax_total - offset_total), quantity_ascost = (tax_total - total_offset),
}, },
{ {
id = nil, id = nil,
transaction_id = nil, transaction_id = nil,
description = nil, description = nil,
account = INCOME_TAX_CONTROL, account = INCOME_TAX_CONTROL,
quantity = -(tax_total - offset_total), quantity = -(tax_total - total_offset),
commodity = context.reporting_commodity, commodity = context.reporting_commodity,
quantity_ascost = -(tax_total - offset_total), quantity_ascost = -(tax_total - total_offset),
}, },
}, },
}) })