Compare commits
5 Commits
bbb91ad1e7
...
b326695dc7
Author | SHA1 | Date | |
---|---|---|---|
b326695dc7 | |||
20e49aba1a | |||
726ed7baa9 | |||
b56fd836d8 | |||
eda3bf1703 |
129
libdrcr/plugins/austax/calc.luau
Normal file
129
libdrcr/plugins/austax/calc.luau
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
--!strict
|
||||||
|
-- DrCr: Web-based double-entry bookkeeping framework
|
||||||
|
-- Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
||||||
|
--
|
||||||
|
-- This program is free software: you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU Affero General Public License as published by
|
||||||
|
-- the Free Software Foundation, either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU Affero General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU Affero General Public License
|
||||||
|
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
local libdrcr = require('../libdrcr')
|
||||||
|
local tax_tables = require('../austax/tax_tables')
|
||||||
|
|
||||||
|
local calc = {}
|
||||||
|
|
||||||
|
-- Get the amount of base income tax
|
||||||
|
function calc.base_income_tax(net_taxable: number, context: libdrcr.ReportingContext): number
|
||||||
|
local year, _, _ = libdrcr.parse_date(context.eofy_date)
|
||||||
|
local base_tax_table = tax_tables.base_tax[year]
|
||||||
|
|
||||||
|
for i, row in ipairs(base_tax_table) do
|
||||||
|
local upper_limit = row[1] * (10 ^ context.dps)
|
||||||
|
local flat_amount = row[2] * (10 ^ context.dps)
|
||||||
|
local marginal_rate = row[3]
|
||||||
|
|
||||||
|
-- Lower limit is the upper limit of the preceding bracket
|
||||||
|
local lower_limit = 0
|
||||||
|
if i > 1 then
|
||||||
|
lower_limit = base_tax_table[i - 1][1] * (10 ^ context.dps)
|
||||||
|
end
|
||||||
|
|
||||||
|
if net_taxable <= upper_limit then
|
||||||
|
return flat_amount + math.floor(marginal_rate * (net_taxable - lower_limit))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
error('Taxable income not within any tax bracket')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the amount of low income tax offset
|
||||||
|
-- https://www.ato.gov.au/forms-and-instructions/low-and-middle-income-earner-tax-offsets
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/itaa1997240/s61.115.html
|
||||||
|
function calc.lito(net_taxable: number, tax_total: number, context: libdrcr.ReportingContext): number
|
||||||
|
if net_taxable <= 37500 * (10 ^ context.dps) then
|
||||||
|
-- LITO is non-refundable
|
||||||
|
-- FIXME: This will not work if we implement multiple non-refundable tax offsets
|
||||||
|
if tax_total <= 700 * (10 ^ context.dps) then
|
||||||
|
return tax_total
|
||||||
|
else
|
||||||
|
return 700 * (10 ^ context.dps)
|
||||||
|
end
|
||||||
|
elseif net_taxable <= 45000 * (10 ^ context.dps) then
|
||||||
|
return 700 * (10 ^ context.dps) - math.floor(0.05 * (net_taxable - 37500 * (10 ^ context.dps)))
|
||||||
|
elseif net_taxable <= 66667 * (10 ^ context.dps) then
|
||||||
|
return 325 * (10 ^ context.dps) - math.floor(0.015 * (net_taxable - 45000 * (10 ^ context.dps)))
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the amount of Medicare levy
|
||||||
|
function calc.medicare_levy(net_taxable: number, context: libdrcr.ReportingContext): number
|
||||||
|
local year, _, _ = libdrcr.parse_date(context.eofy_date)
|
||||||
|
local threshold_table = tax_tables.medicare_levy_threshold[year]
|
||||||
|
local lower_threshold = threshold_table[1] * (10 ^ context.dps)
|
||||||
|
local upper_threshold = threshold_table[2] * (10 ^ context.dps)
|
||||||
|
|
||||||
|
if net_taxable < lower_threshold then
|
||||||
|
return 0
|
||||||
|
elseif net_taxable < upper_threshold then
|
||||||
|
-- Medicare levy is 10% of the amount above the lower threshold
|
||||||
|
return math.floor((net_taxable - lower_threshold) * 0.1)
|
||||||
|
else
|
||||||
|
-- Normal Medicare levy
|
||||||
|
return math.floor(net_taxable * 0.02)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the amount of Medicare levy surcharge
|
||||||
|
function calc.medicare_levy_surcharge(net_taxable: number, rfb_grossedup: number, context: libdrcr.ReportingContext): number
|
||||||
|
local mls_income = net_taxable + rfb_grossedup
|
||||||
|
|
||||||
|
local year, _, _ = libdrcr.parse_date(context.eofy_date)
|
||||||
|
local mls_table = tax_tables.medicare_levy_surcharge_single[year]
|
||||||
|
|
||||||
|
for _, row in ipairs(mls_table) do
|
||||||
|
local upper_limit = row[1] * (10 ^ context.dps)
|
||||||
|
local rate = row[2]
|
||||||
|
|
||||||
|
if mls_income <= upper_limit then
|
||||||
|
return math.floor(rate * mls_income)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
error('MLS income not within any MLS bracket')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Calculate the grossed-up reportable fringe benefit
|
||||||
|
function calc.rfb_grossup(rfb_taxable: number, context: libdrcr.ReportingContext): number
|
||||||
|
return math.floor(rfb_taxable * tax_tables.fbt_grossup)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the amount of mandatory study loan repayment
|
||||||
|
function calc.study_loan_repayment(net_taxable: number, rfb_grossedup: number, context: libdrcr.ReportingContext): number
|
||||||
|
local repayment_income = net_taxable + rfb_grossedup
|
||||||
|
|
||||||
|
local year, _, _ = libdrcr.parse_date(context.eofy_date)
|
||||||
|
local repayment_table = tax_tables.study_loan_repayment_rates[year]
|
||||||
|
|
||||||
|
for _, row in ipairs(repayment_table) do
|
||||||
|
local upper_limit = row[1] * (10 ^ context.dps)
|
||||||
|
local rate = row[2]
|
||||||
|
|
||||||
|
if repayment_income < upper_limit then
|
||||||
|
return math.floor(rate * repayment_income)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
error('HELP repayment income not within any repayment bracket')
|
||||||
|
end
|
||||||
|
|
||||||
|
return calc
|
28
libdrcr/plugins/austax/plugin.luau
Normal file
28
libdrcr/plugins/austax/plugin.luau
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
--!strict
|
||||||
|
-- DrCr: Web-based double-entry bookkeeping framework
|
||||||
|
-- Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
||||||
|
--
|
||||||
|
-- This program is free software: you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU Affero General Public License as published by
|
||||||
|
-- the Free Software Foundation, either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU Affero General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU Affero General Public License
|
||||||
|
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
local libdrcr = require('../libdrcr')
|
||||||
|
local reporting = require('../austax/reporting')
|
||||||
|
|
||||||
|
local plugin: libdrcr.Plugin = {
|
||||||
|
name = 'austax',
|
||||||
|
reporting_steps = {
|
||||||
|
reporting.CalculateIncomeTax
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return plugin
|
@ -16,34 +16,27 @@
|
|||||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
local libdrcr = require('../libdrcr')
|
local libdrcr = require('../libdrcr')
|
||||||
|
|
||||||
local account_kinds = require('../austax/account_kinds')
|
local account_kinds = require('../austax/account_kinds')
|
||||||
local tax_tables = require('../austax/tax_tables')
|
local calc = require('../austax/calc')
|
||||||
|
|
||||||
function get_base_income_tax(net_taxable: number, context: libdrcr.ReportingContext): number
|
-- Account constants
|
||||||
local year, _, _ = libdrcr.parse_date(context.eofy_date)
|
local CURRENT_YEAR_EARNINGS = 'Current Year Earnings'
|
||||||
local base_tax_table = tax_tables.base_tax[year]
|
local HELP = 'HELP'
|
||||||
|
local INCOME_TAX = 'Income Tax'
|
||||||
for i, row in ipairs(base_tax_table) do
|
local INCOME_TAX_CONTROL = 'Income Tax Control'
|
||||||
local upper_limit = row[1] * (10 ^ context.dps)
|
local RETAINED_EARNINGS = 'Retained Earnings'
|
||||||
local flat_amount = row[2] * (10 ^ context.dps)
|
|
||||||
local marginal_rate = row[3]
|
|
||||||
|
|
||||||
-- Lower limit is the upper limit of the preceding bracket
|
|
||||||
local lower_limit = 0
|
|
||||||
if i > 1 then
|
|
||||||
lower_limit = base_tax_table[i - 1][1] * (10 ^ context.dps)
|
|
||||||
end
|
|
||||||
|
|
||||||
if net_taxable <= upper_limit then
|
|
||||||
return flat_amount + marginal_rate * (net_taxable - lower_limit)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
error('Taxable income not within any tax bracket')
|
|
||||||
end
|
|
||||||
|
|
||||||
function requires(args, context)
|
local reporting = {}
|
||||||
|
|
||||||
|
-- This ReportingStep calculates income tax
|
||||||
|
--
|
||||||
|
-- Generates the tax summary DynamicReport, and adds Transactions reconciling income tax expense, PAYG withholding and study loan repayments.
|
||||||
|
reporting.CalculateIncomeTax = {
|
||||||
|
name = 'CalculateIncomeTax',
|
||||||
|
product_kinds = {'DynamicReport', 'Transactions'},
|
||||||
|
} :: libdrcr.ReportingStep
|
||||||
|
|
||||||
|
function reporting.CalculateIncomeTax.requires(args, context)
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
name = 'CombineOrdinaryTransactions',
|
name = 'CombineOrdinaryTransactions',
|
||||||
@ -53,7 +46,7 @@ function requires(args, context)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function after_init_graph(args, steps, add_dependency, context)
|
function reporting.CalculateIncomeTax.after_init_graph(args, steps, add_dependency, context)
|
||||||
for _, other in ipairs(steps) do
|
for _, other in ipairs(steps) do
|
||||||
if other.name == 'AllTransactionsExceptEarningsToEquity' then
|
if other.name == 'AllTransactionsExceptEarningsToEquity' then
|
||||||
-- AllTransactionsExceptEarningsToEquity depends on CalculateIncomeTax
|
-- AllTransactionsExceptEarningsToEquity depends on CalculateIncomeTax
|
||||||
@ -75,7 +68,7 @@ function after_init_graph(args, steps, add_dependency, context)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function execute(args, context, kinds_for_account, get_product)
|
function reporting.CalculateIncomeTax.execute(args, context, kinds_for_account, get_product)
|
||||||
-- Get balances for current year
|
-- Get balances for current year
|
||||||
local product = get_product({
|
local product = get_product({
|
||||||
name = 'CombineOrdinaryTransactions',
|
name = 'CombineOrdinaryTransactions',
|
||||||
@ -128,7 +121,7 @@ function execute(args, context, kinds_for_account, get_product)
|
|||||||
visible = true,
|
visible = true,
|
||||||
link = nil,
|
link = nil,
|
||||||
heading = true,
|
heading = true,
|
||||||
bordered = true,
|
bordered = false,
|
||||||
}})
|
}})
|
||||||
table.insert(report.entries, { Section = section })
|
table.insert(report.entries, { Section = section })
|
||||||
table.insert(report.entries, 'Spacer')
|
table.insert(report.entries, 'Spacer')
|
||||||
@ -176,7 +169,7 @@ function execute(args, context, kinds_for_account, get_product)
|
|||||||
visible = true,
|
visible = true,
|
||||||
link = nil,
|
link = nil,
|
||||||
heading = true,
|
heading = true,
|
||||||
bordered = true,
|
bordered = false,
|
||||||
}})
|
}})
|
||||||
table.insert(report.entries, { Section = section })
|
table.insert(report.entries, { Section = section })
|
||||||
table.insert(report.entries, 'Spacer')
|
table.insert(report.entries, 'Spacer')
|
||||||
@ -208,7 +201,7 @@ function execute(args, context, kinds_for_account, get_product)
|
|||||||
table.insert(report.entries, 'Spacer')
|
table.insert(report.entries, 'Spacer')
|
||||||
|
|
||||||
-- Base income tax row
|
-- Base income tax row
|
||||||
local tax_base = get_base_income_tax(net_taxable, context)
|
local tax_base = calc.base_income_tax(net_taxable, context)
|
||||||
table.insert(report.entries, { Row = {
|
table.insert(report.entries, { Row = {
|
||||||
text = 'Base income tax',
|
text = 'Base income tax',
|
||||||
quantity = {tax_base},
|
quantity = {tax_base},
|
||||||
@ -219,8 +212,45 @@ function execute(args, context, kinds_for_account, get_product)
|
|||||||
bordered = false,
|
bordered = false,
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
-- Medicare levy row
|
||||||
|
local tax_ml = calc.medicare_levy(net_taxable, context)
|
||||||
|
if tax_ml ~= 0 then
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'Medicare levy',
|
||||||
|
quantity = {tax_ml},
|
||||||
|
id = 'tax_ml',
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = false,
|
||||||
|
bordered = false,
|
||||||
|
}})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Precompute RFB amount as this is required for MLS
|
||||||
|
local rfb_taxable = 0
|
||||||
|
for account, kinds in pairs(kinds_for_account) do
|
||||||
|
if libdrcr.arr_contains(kinds, 'austax.rfb') then
|
||||||
|
rfb_taxable -= balances[account] or 0 -- Invert as income = credit balances
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local rfb_grossedup = calc.rfb_grossup(rfb_taxable, context)
|
||||||
|
|
||||||
|
-- Medicare levy surcharge row
|
||||||
|
local tax_mls = calc.medicare_levy_surcharge(net_taxable, rfb_grossedup, context)
|
||||||
|
if tax_mls ~= 0 then
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'Medicare levy surcharge',
|
||||||
|
quantity = {tax_mls},
|
||||||
|
id = 'tax_mls',
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = false,
|
||||||
|
bordered = false,
|
||||||
|
}})
|
||||||
|
end
|
||||||
|
|
||||||
-- Total income tax row
|
-- Total income tax row
|
||||||
local tax_total = tax_base
|
local tax_total = tax_base + tax_ml + tax_mls
|
||||||
table.insert(report.entries, { Row = {
|
table.insert(report.entries, { Row = {
|
||||||
text = 'Total income tax',
|
text = 'Total income tax',
|
||||||
quantity = {tax_total},
|
quantity = {tax_total},
|
||||||
@ -230,10 +260,126 @@ function execute(args, context, kinds_for_account, get_product)
|
|||||||
heading = true,
|
heading = true,
|
||||||
bordered = true,
|
bordered = true,
|
||||||
}})
|
}})
|
||||||
|
table.insert(report.entries, 'Spacer')
|
||||||
|
|
||||||
-- Generate income tax transaction
|
-- Low income tax offset row
|
||||||
|
local offset_lito = calc.lito(net_taxable, tax_total, context)
|
||||||
|
if offset_lito ~= 0 then
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'Low income tax offset',
|
||||||
|
quantity = {offset_lito},
|
||||||
|
id = nil,
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = false,
|
||||||
|
bordered = false,
|
||||||
|
}})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Total tax offsets row
|
||||||
|
local offset_total = offset_lito
|
||||||
|
if offset_total ~= 0 then
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'Total tax offsets',
|
||||||
|
quantity = {offset_total},
|
||||||
|
id = nil,
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = true,
|
||||||
|
bordered = false,
|
||||||
|
}})
|
||||||
|
table.insert(report.entries, 'Spacer')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Calculate mandatory study loan repayment
|
||||||
|
local study_loan_repayment = calc.study_loan_repayment(net_taxable, rfb_grossedup, context)
|
||||||
|
|
||||||
|
-- Mandatory study loan repayment section
|
||||||
|
if study_loan_repayment ~= 0 then
|
||||||
|
-- Taxable value of reportable fringe benefits row
|
||||||
|
if rfb_taxable ~= 0 then
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'Taxable value of reportable fringe benefits',
|
||||||
|
quantity = {rfb_taxable},
|
||||||
|
id = 'rfb_taxable',
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = false,
|
||||||
|
bordered = false,
|
||||||
|
}})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Grossed-up value row
|
||||||
|
if rfb_grossedup ~= 0 then
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'Grossed-up value',
|
||||||
|
quantity = {rfb_grossedup},
|
||||||
|
id = 'rfb_grossedup',
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = false,
|
||||||
|
bordered = false,
|
||||||
|
}})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Mandatory study loan repayment row
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'Mandatory study loan repayment',
|
||||||
|
quantity = {study_loan_repayment},
|
||||||
|
id = 'study_loan_repayment',
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = true,
|
||||||
|
bordered = false,
|
||||||
|
}})
|
||||||
|
table.insert(report.entries, 'Spacer')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add PAYGW entries
|
||||||
|
local total_paygw = 0
|
||||||
|
local entries = entries_for_kind('austax.paygw', false, balances, kinds_for_account)
|
||||||
|
|
||||||
|
if #entries ~= 0 then
|
||||||
|
local section: libdrcr.Section = {
|
||||||
|
text = 'PAYG withheld amounts',
|
||||||
|
id = nil,
|
||||||
|
visible = true,
|
||||||
|
entries = entries,
|
||||||
|
}
|
||||||
|
table.insert(report.entries, { Section = section })
|
||||||
|
total_paygw = math.floor(entries_subtotal(entries) / 100) * 100
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Total PAYGW row
|
||||||
|
if total_paygw ~= 0 then
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'Total withheld amounts',
|
||||||
|
quantity = {total_paygw},
|
||||||
|
id = 'total_paygw',
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = true,
|
||||||
|
bordered = false,
|
||||||
|
}})
|
||||||
|
table.insert(report.entries, 'Spacer')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ATO liability row
|
||||||
|
local ato_payable = tax_total - offset_total - total_paygw + study_loan_repayment
|
||||||
|
table.insert(report.entries, { Row = {
|
||||||
|
text = 'ATO liability payable (refundable)',
|
||||||
|
quantity = {ato_payable},
|
||||||
|
id = 'ato_payable',
|
||||||
|
visible = true,
|
||||||
|
link = nil,
|
||||||
|
heading = true,
|
||||||
|
bordered = true,
|
||||||
|
}})
|
||||||
|
|
||||||
|
-- Generate income tax transactions
|
||||||
local transactions: {libdrcr.Transaction} = {
|
local transactions: {libdrcr.Transaction} = {
|
||||||
{
|
{
|
||||||
|
-- # Estimated tax payable
|
||||||
id = nil,
|
id = nil,
|
||||||
dt = libdrcr.date_to_dt(context.eofy_date),
|
dt = libdrcr.date_to_dt(context.eofy_date),
|
||||||
description = 'Estimated income tax',
|
description = 'Estimated income tax',
|
||||||
@ -242,24 +388,84 @@ function execute(args, context, kinds_for_account, get_product)
|
|||||||
id = nil,
|
id = nil,
|
||||||
transaction_id = nil,
|
transaction_id = nil,
|
||||||
description = nil,
|
description = nil,
|
||||||
account = 'Income Tax',
|
account = INCOME_TAX,
|
||||||
quantity = tax_total,
|
quantity = (tax_total - offset_total),
|
||||||
commodity = context.reporting_commodity,
|
commodity = context.reporting_commodity,
|
||||||
quantity_ascost = tax_total,
|
quantity_ascost = (tax_total - offset_total),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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,
|
quantity = -(tax_total - offset_total),
|
||||||
commodity = context.reporting_commodity,
|
commodity = context.reporting_commodity,
|
||||||
quantity_ascost = -tax_total,
|
quantity_ascost = -(tax_total - offset_total),
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
-- Mandatory study loan repayment
|
||||||
|
id = nil,
|
||||||
|
dt = libdrcr.date_to_dt(context.eofy_date),
|
||||||
|
description = 'Mandatory study loan repayment payable',
|
||||||
|
postings = {
|
||||||
|
{
|
||||||
|
id = nil,
|
||||||
|
transaction_id = nil,
|
||||||
|
description = nil,
|
||||||
|
account = HELP,
|
||||||
|
quantity = study_loan_repayment,
|
||||||
|
commodity = context.reporting_commodity,
|
||||||
|
quantity_ascost = study_loan_repayment,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = nil,
|
||||||
|
transaction_id = nil,
|
||||||
|
description = nil,
|
||||||
|
account = INCOME_TAX_CONTROL,
|
||||||
|
quantity = -study_loan_repayment,
|
||||||
|
commodity = context.reporting_commodity,
|
||||||
|
quantity_ascost = -study_loan_repayment,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Transfer PAYGW balances to Income Tax Control
|
||||||
|
for account, kinds in pairs(kinds_for_account) do
|
||||||
|
if libdrcr.arr_contains(kinds, 'austax.paygw') then
|
||||||
|
local balance = balances[account] or 0
|
||||||
|
if balance ~= 0 then
|
||||||
|
table.insert(transactions, {
|
||||||
|
id = nil,
|
||||||
|
dt = libdrcr.date_to_dt(context.eofy_date),
|
||||||
|
description = 'PAYG withheld amounts',
|
||||||
|
postings = {
|
||||||
|
{
|
||||||
|
id = nil,
|
||||||
|
transaction_id = nil,
|
||||||
|
description = nil,
|
||||||
|
account = INCOME_TAX_CONTROL,
|
||||||
|
quantity = balance,
|
||||||
|
commodity = context.reporting_commodity,
|
||||||
|
quantity_ascost = balance,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = nil,
|
||||||
|
transaction_id = nil,
|
||||||
|
description = nil,
|
||||||
|
account = account,
|
||||||
|
quantity = -balance,
|
||||||
|
commodity = context.reporting_commodity,
|
||||||
|
quantity_ascost = -balance,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
[{ name = 'CalculateIncomeTax', kind = 'Transactions', args = 'VoidArgs' }] = {
|
[{ name = 'CalculateIncomeTax', kind = 'Transactions', args = 'VoidArgs' }] = {
|
||||||
Transactions = {
|
Transactions = {
|
||||||
@ -296,9 +502,9 @@ function entries_for_kind(kind: string, invert: boolean, balances:{ [string]: nu
|
|||||||
|
|
||||||
-- Some exceptions for the link
|
-- Some exceptions for the link
|
||||||
local link: string | nil
|
local link: string | nil
|
||||||
if account == 'Current Year Earnings' then
|
if account == CURRENT_YEAR_EARNINGS then
|
||||||
link = '/income-statement'
|
link = '/income-statement'
|
||||||
elseif account == 'Retained Earnings' then
|
elseif account == RETAINED_EARNINGS then
|
||||||
link = nil
|
link = nil
|
||||||
else
|
else
|
||||||
link = '/transactions/' .. account
|
link = '/transactions/' .. account
|
||||||
@ -338,17 +544,4 @@ function entries_subtotal(entries: {libdrcr.DynamicReportEntry}): number
|
|||||||
return subtotal
|
return subtotal
|
||||||
end
|
end
|
||||||
|
|
||||||
local plugin: libdrcr.Plugin = {
|
return reporting
|
||||||
name = 'austax',
|
|
||||||
reporting_steps = {
|
|
||||||
{
|
|
||||||
name = 'CalculateIncomeTax',
|
|
||||||
product_kinds = {'DynamicReport', 'Transactions'},
|
|
||||||
requires = requires,
|
|
||||||
after_init_graph = after_init_graph,
|
|
||||||
execute = execute,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return plugin
|
|
@ -15,10 +15,14 @@
|
|||||||
-- You should have received a copy of the GNU Affero General Public License
|
-- You should have received a copy of the GNU Affero General Public License
|
||||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
local tax_tables = {}
|
||||||
|
|
||||||
-- Base income tax
|
-- Base income tax
|
||||||
-- https://www.ato.gov.au/rates/individual-income-tax-rates/
|
-- https://www.ato.gov.au/rates/individual-income-tax-rates/
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/itra1986174/sch7.html
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/itra1986174/s3.html (tax-free threshold)
|
||||||
-- Maps each financial year to list of (upper limit (INclusive), flat amount, marginal rate)
|
-- Maps each financial year to list of (upper limit (INclusive), flat amount, marginal rate)
|
||||||
local base_tax = {
|
tax_tables.base_tax = {
|
||||||
[2025] = {
|
[2025] = {
|
||||||
{18200, 0, 0},
|
{18200, 0, 0},
|
||||||
{45000, 0, 0.16},
|
{45000, 0, 0.16},
|
||||||
@ -42,8 +46,114 @@ local base_tax = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local tax_tables = {
|
-- FBT type 1 gross-up factor
|
||||||
base_tax = base_tax,
|
-- https://www.ato.gov.au/rates/fbt/#GrossupratesforFBT
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/fbtaa1986312/s5b.html
|
||||||
|
tax_tables.fbt_grossup = 2.0802
|
||||||
|
|
||||||
|
-- Medicare levy thresholds
|
||||||
|
-- https://www.ato.gov.au/Individuals/Medicare-and-private-health-insurance/Medicare-levy/Medicare-levy-reduction/Medicare-levy-reduction-for-low-income-earners/
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/mla1986131/s3.html
|
||||||
|
-- Maps each financial year to list of (lower threshold, upper threshold)
|
||||||
|
tax_tables.medicare_levy_threshold = {
|
||||||
|
[2025] = {27222, 34027},
|
||||||
|
[2024] = {26000, 32500},
|
||||||
|
[2023] = {24276, 30345},
|
||||||
|
[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
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdb/au/legis/cth/consol_act/mla1986131/s8b.html
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/phia2007248/s22.35.html
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/phia2007248/s22.45.html
|
||||||
|
-- Maps each financial year to list of (upper limit (INclusive), MLS rate)
|
||||||
|
-- FIXME: Only supports singles
|
||||||
|
tax_tables.medicare_levy_surcharge_single = {
|
||||||
|
[2025] = {
|
||||||
|
{97000, 0},
|
||||||
|
{113000, 0.01},
|
||||||
|
{151000, 0.0125},
|
||||||
|
{math.huge, 0.015}
|
||||||
|
},
|
||||||
|
[2024] = {
|
||||||
|
{93000, 0},
|
||||||
|
{108000, 0.01},
|
||||||
|
{144000, 0.0125},
|
||||||
|
{math.huge, 0.015}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Study and training loan (HELP, etc.) repayment thresholds and rates
|
||||||
|
-- https://www.ato.gov.au/Rates/HELP,-TSL-and-SFSS-repayment-thresholds-and-rates/
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/hesa2003271/s154.20.html
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/hesa2003271/s154.25.html
|
||||||
|
-- https://www.austlii.edu.au/cgi-bin/viewdoc/au/legis/cth/consol_act/hesa2003271/s154.30.html
|
||||||
|
-- Maps each financial year to list of (upper limit (EXclusive), repayment rate)
|
||||||
|
tax_tables.study_loan_repayment_rates = {
|
||||||
|
[2025] = {
|
||||||
|
{54435, 0},
|
||||||
|
{62851, 0.01},
|
||||||
|
{66621, 0.02},
|
||||||
|
{70619, 0.025},
|
||||||
|
{74856, 0.03},
|
||||||
|
{79347, 0.035},
|
||||||
|
{84108, 0.04},
|
||||||
|
{89155, 0.045},
|
||||||
|
{94504, 0.05},
|
||||||
|
{100175, 0.055},
|
||||||
|
{106186, 0.06},
|
||||||
|
{112557, 0.065},
|
||||||
|
{119310, 0.07},
|
||||||
|
{126468, 0.075},
|
||||||
|
{134057, 0.08},
|
||||||
|
{142101, 0.085},
|
||||||
|
{150627, 0.09},
|
||||||
|
{159664, 0.095},
|
||||||
|
{math.huge, 0.1}
|
||||||
|
},
|
||||||
|
[2024] = {
|
||||||
|
{51550, 0},
|
||||||
|
{59519, 0.01},
|
||||||
|
{63090, 0.02},
|
||||||
|
{66876, 0.025},
|
||||||
|
{70889, 0.03},
|
||||||
|
{75141, 0.035},
|
||||||
|
{79650, 0.04},
|
||||||
|
{84430, 0.045},
|
||||||
|
{89495, 0.05},
|
||||||
|
{94866, 0.055},
|
||||||
|
{100558, 0.06},
|
||||||
|
{106591, 0.065},
|
||||||
|
{112986, 0.07},
|
||||||
|
{119765, 0.075},
|
||||||
|
{126951, 0.08},
|
||||||
|
{134569, 0.085},
|
||||||
|
{142643, 0.09},
|
||||||
|
{151201, 0.095},
|
||||||
|
{math.huge, 0.1}
|
||||||
|
},
|
||||||
|
[2023] = {
|
||||||
|
{48361, 0},
|
||||||
|
{55837, 0.01},
|
||||||
|
{59187, 0.02},
|
||||||
|
{62739, 0.025},
|
||||||
|
{66503, 0.03},
|
||||||
|
{70493, 0.035},
|
||||||
|
{74723, 0.04},
|
||||||
|
{79207, 0.045},
|
||||||
|
{83959, 0.05},
|
||||||
|
{88997, 0.055},
|
||||||
|
{94337, 0.06},
|
||||||
|
{99997, 0.065},
|
||||||
|
{105997, 0.07},
|
||||||
|
{112356, 0.075},
|
||||||
|
{119098, 0.08},
|
||||||
|
{126244, 0.085},
|
||||||
|
{133819, 0.09},
|
||||||
|
{141848, 0.095},
|
||||||
|
{math.huge, 0.1}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tax_tables
|
return tax_tables
|
||||||
|
@ -13,6 +13,4 @@ pub type QuantityInt = i64;
|
|||||||
// Magic strings
|
// Magic strings
|
||||||
// TODO: Make this configurable
|
// TODO: Make this configurable
|
||||||
pub const CURRENT_YEAR_EARNINGS: &'static str = "Current Year Earnings";
|
pub const CURRENT_YEAR_EARNINGS: &'static str = "Current Year Earnings";
|
||||||
pub const INCOME_TAX: &'static str = "Income Tax";
|
|
||||||
pub const INCOME_TAX_CONTROL: &'static str = "Income Tax Control";
|
|
||||||
pub const RETAINED_EARNINGS: &'static str = "Retained Earnings";
|
pub const RETAINED_EARNINGS: &'static str = "Retained Earnings";
|
||||||
|
@ -39,7 +39,7 @@ async fn main() {
|
|||||||
let mut context = ReportingContext::new(
|
let mut context = ReportingContext::new(
|
||||||
db_connection,
|
db_connection,
|
||||||
"plugins".to_string(),
|
"plugins".to_string(),
|
||||||
vec!["austax.austax".to_string()],
|
vec!["austax.plugin".to_string()],
|
||||||
NaiveDate::from_ymd_opt(2025, 6, 30).unwrap(),
|
NaiveDate::from_ymd_opt(2025, 6, 30).unwrap(),
|
||||||
"$".to_string(),
|
"$".to_string(),
|
||||||
);
|
);
|
||||||
|
@ -764,14 +764,17 @@ impl ReportingStep for UpdateBalancesBetween {
|
|||||||
let dependencies_for_step = dependencies.dependencies_for_step(&parent_step.id());
|
let dependencies_for_step = dependencies.dependencies_for_step(&parent_step.id());
|
||||||
let balances_between_product = &dependencies_for_step[0].product; // Existence and uniqueness checked in can_build
|
let balances_between_product = &dependencies_for_step[0].product; // Existence and uniqueness checked in can_build
|
||||||
|
|
||||||
if matches!(
|
let mut is_already_transitive_dependency = false;
|
||||||
balances_between_product.args,
|
if let ReportingStepArgs::DateStartDateEndArgs(args) = &balances_between_product.args {
|
||||||
ReportingStepArgs::DateStartDateEndArgs(_)
|
if *args == self.args {
|
||||||
) {
|
// Directly depends on BalanceBetween -> Transaction with appropriate date
|
||||||
// Directly depends on BalanceBetween -> Transaction with appropriate date
|
// Do not need to add extra dependencies
|
||||||
// Do not need to add extra dependencies
|
is_already_transitive_dependency = true;
|
||||||
} else {
|
}
|
||||||
// Depends on BalanceBetween with appropriate date
|
}
|
||||||
|
|
||||||
|
if !is_already_transitive_dependency {
|
||||||
|
// Add dependency on BalanceBetween with appropriate date
|
||||||
dependencies.add_dependency(
|
dependencies.add_dependency(
|
||||||
self.id(),
|
self.id(),
|
||||||
ReportingProductId {
|
ReportingProductId {
|
||||||
|
34
package.json
34
package.json
@ -10,28 +10,28 @@
|
|||||||
"tauri": "tauri"
|
"tauri": "tauri"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@heroicons/vue": "^2.1.5",
|
"@heroicons/vue": "^2.2.0",
|
||||||
"@tauri-apps/api": "^2",
|
"@tauri-apps/api": "^2.5.0",
|
||||||
"@tauri-apps/plugin-dialog": "~2",
|
"@tauri-apps/plugin-dialog": "~2.2.2",
|
||||||
"@tauri-apps/plugin-shell": "^2",
|
"@tauri-apps/plugin-shell": "^2.2.1",
|
||||||
"@tauri-apps/plugin-sql": "~2",
|
"@tauri-apps/plugin-sql": "~2.2.0",
|
||||||
"@tauri-apps/plugin-store": "~2",
|
"@tauri-apps/plugin-store": "~2.2.0",
|
||||||
"clusterize.js": "^1.0.0",
|
"clusterize.js": "^1.0.0",
|
||||||
"csv-parse": "^5.6.0",
|
"csv-parse": "^5.6.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.5.16",
|
||||||
"vue-router": "4"
|
"vue-router": "^4.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/forms": "^0.5.9",
|
"@tailwindcss/forms": "^0.5.10",
|
||||||
"@tauri-apps/cli": "^2",
|
"@tauri-apps/cli": "^2.5.0",
|
||||||
"@types/clusterize.js": "^0.18.3",
|
"@types/clusterize.js": "^0.18.3",
|
||||||
"@vitejs/plugin-vue": "^5.0.5",
|
"@vitejs/plugin-vue": "^5.2.4",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.21",
|
||||||
"postcss": "^8.4.49",
|
"postcss": "^8.5.4",
|
||||||
"tailwindcss": "^3.4.15",
|
"tailwindcss": "^3.4.17",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.8.3",
|
||||||
"vite": "^5.3.1",
|
"vite": "^5.4.19",
|
||||||
"vue-tsc": "^2.0.22"
|
"vue-tsc": "^2.2.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
865
pnpm-lock.yaml
generated
865
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,7 @@ fn prepare_reporting_context(context: &mut ReportingContext) {
|
|||||||
|
|
||||||
fn get_plugins() -> Vec<String> {
|
fn get_plugins() -> Vec<String> {
|
||||||
// FIXME: Dynamically get this
|
// FIXME: Dynamically get this
|
||||||
vec!["austax.austax".to_string()]
|
vec!["austax.plugin".to_string()]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn get_report(
|
pub(crate) async fn get_report(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user