Created
January 29, 2025 04:43
-
-
Save spcheema/c0ead757473492eb548e8a73806b8efa to your computer and use it in GitHub Desktop.
Contracting benefits calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Contracting benefits calculator</title> | |
<!-- Bootstrap CSS --> | |
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> | |
<style> | |
.result-table { | |
margin-top: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container mt-5"> | |
<h2 class="text-center">Income Tax Calculator</h2> | |
<div class="form-group"> | |
<label for="incomeInput">Annual Income:</label> | |
<input type="text" value="" class="form-control" id="incomeInput" | |
placeholder="Enter your annual income"> | |
</div> | |
<table class="table table-bordered table-striped result-table"> | |
<thead class="thead-dark"> | |
<tr> | |
<th scope="col">Category</th> | |
<th scope="col">Amount ($AUD)</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Income</td> | |
<td id="adjustedIncome">-</td> | |
</tr> | |
<tr> | |
<td>Take-Home Pay</td> | |
<td id="takeHome">-</td> | |
</tr> | |
<tr> | |
<td>Superannuation</td> | |
<td id="superAmount">-</td> | |
</tr> | |
<tr> | |
<td>Tax</td> | |
<td id="taxAmount">-</td> | |
</tr> | |
</tbody> | |
</table> | |
<h2 class="text-center mt-5">Company Income Calculator</h2> | |
<div class="form-group"> | |
<label for="dailyRate">Daily Rate:</label> | |
<input type="text" class="form-control" id="dailyRate" value="" placeholder="Enter your daily rate"> | |
</div> | |
<div class="form-group"> | |
<label for="companyExpenses">Company Expenses:</label> | |
<input type="text" class="form-control" id="companyExpenses" value="" | |
placeholder="Enter your company expenses"> | |
</div> | |
<div class="form-group"> | |
<label for="salries">Salaries (Annually):</label> | |
<input type="text" class="form-control" id="salries" value="" | |
placeholder="Enter director's annual salary"> | |
</div> | |
<div class="form-group"> | |
<label for="workingDays">Working Days:</label> | |
<input type="text" class="form-control" id="workingDays" value="" | |
placeholder="Enter the number of working days"> | |
</div> | |
<table class="table table-bordered table-striped result-table"> | |
<thead class="thead-dark"> | |
<tr> | |
<th scope="col">Category</th> | |
<th scope="col">Amount ($AUD)</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Revenue</td> | |
<td id="revenueAmount">-</td> | |
</tr> | |
<tr> | |
<td>Total Expenses</td> | |
<td id="totalExpenses">-</td> | |
</tr> | |
<tr> | |
<td>Income After Expenses</td> | |
<td id="incomeAfterExpenses">-</td> | |
</tr> | |
<tr> | |
<td>Franking Credit</td> | |
<td id="frankingCredit">-</td> | |
</tr> | |
<tr> | |
<td>Distributed Balance</td> | |
<td id="distributedBalance">-</td> | |
</tr> | |
</tbody> | |
</table> | |
<h2 class="text-center mt-5">Total Summary</h2> | |
<table class="table table-bordered table-striped result-table"> | |
<thead class="thead-dark"> | |
<tr> | |
<th scope="col">Category</th> | |
<th scope="col">Amount ($AUD)</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Total Take-Home Pay</td> | |
<td id="totalTakeHome">-</td> | |
</tr> | |
<tr> | |
<td>Personal Tax Paid</td> | |
<td id="personalTaxPaid">-</td> | |
</tr> | |
<tr> | |
<td>Corporate Tax</td> | |
<td id="corpTax">-</td> | |
</tr> | |
<tr> | |
<td>Total Tax Paid</td> | |
<td id="totalTaxPaid">-</td> | |
</tr> | |
<tr> | |
<td>Total Superannuation</td> | |
<td id="totalSuper">-</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
<!-- Bootstrap JS (Optional for interactivity) --> | |
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script> | |
<script src="https://stackpath.herokuapp.com/js/bootstrap.min.js"></script> | |
<!-- currency.js --> | |
<script src="https://cdn.jsdelivr.net/npm/currency.js"></script> | |
<script> | |
function formatNumber(num) { | |
return currency(num, { symbol: '', precision: 0 }).format(); | |
} | |
function formatInput(input) { | |
let value = input.value.replace(/,/g, ''); | |
input.value = formatNumber(parseFloat(value) || 0); | |
} | |
function personalTaxCalc(income) { | |
let tax = 0; | |
if (income > 180000) { | |
tax += (income - 180000) * 0.45; | |
income = 180000; | |
} | |
if (income > 120000) { | |
tax += (income - 120000) * 0.37; | |
income = 120000; | |
} | |
if (income > 45000) { | |
tax += (income - 45000) * 0.325; | |
income = 45000; | |
} | |
if (income > 18200) { | |
tax += (income - 18200) * 0.19; | |
} | |
return tax; | |
} | |
function calculate() { | |
let income = parseFloat(document.getElementById('incomeInput').value.replace(/,/g, '')); | |
let tax = personalTaxCalc(income); | |
let superannuation = income * 0.115; // Superannuation rate is 11.5% | |
document.getElementById('adjustedIncome').textContent = formatNumber(income.toFixed(2)); | |
let takeHome = income - tax; | |
document.getElementById('taxAmount').textContent = formatNumber(tax.toFixed(2)); | |
document.getElementById('superAmount').textContent = formatNumber(superannuation.toFixed(2)); | |
document.getElementById('takeHome').textContent = formatNumber(takeHome.toFixed(2)); | |
} | |
function calculateCompany() { | |
let dailyRate = parseFloat(document.getElementById('dailyRate').value.replace(/,/g, '')); | |
let companyExpenses = parseFloat(document.getElementById('companyExpenses').value.replace(/,/g, '')); | |
let salries = parseFloat(document.getElementById('salries').value.replace(/,/g, '')); | |
let workingDays = parseInt(document.getElementById('workingDays').value.replace(/,/g, '')); | |
let corpTaxRate = 0.30; | |
let revenue = dailyRate * workingDays; | |
let totalExpenses = companyExpenses + salries; | |
let directorSuper = salries * 0.115; // Director's superannuation rate is 11.5% | |
let incomeAfterExpenses = revenue - totalExpenses - directorSuper; | |
let corpTax = incomeAfterExpenses * corpTaxRate; | |
let frankingCredit = corpTax * corpTaxRate; | |
let distributedBalance = incomeAfterExpenses - corpTax; | |
document.getElementById('revenueAmount').textContent = formatNumber(revenue.toFixed(2)); | |
document.getElementById('totalExpenses').textContent = formatNumber(totalExpenses.toFixed(2)); | |
document.getElementById('incomeAfterExpenses').textContent = formatNumber(incomeAfterExpenses.toFixed(2)); | |
document.getElementById('frankingCredit').textContent = formatNumber(frankingCredit.toFixed(2)); | |
document.getElementById('distributedBalance').textContent = formatNumber(distributedBalance.toFixed(2)); | |
return { | |
salries, distributedBalance, corpTax, directorSuper | |
}; | |
} | |
// Calculate total take home pay, personal tax paid, corporate tax, total tax paid, and total superannuation | |
function calculateTotal() { | |
calculate(); | |
let company = calculateCompany(); | |
let totalTakeHome = company.salries - personalTaxCalc(company.salries); | |
let totalTaxPaid = formatNumber((company.corpTax + personalTaxCalc(company.salries)).toFixed(2)); | |
let totalSuper = company.directorSuper; | |
document.getElementById('totalTakeHome').textContent = formatNumber(totalTakeHome.toFixed(2)); | |
document.getElementById('personalTaxPaid').textContent = formatNumber(personalTaxCalc(company.salries).toFixed(2)); | |
document.getElementById('totalTaxPaid').textContent = totalTaxPaid.toString(); | |
document.getElementById('totalSuper').textContent = formatNumber(totalSuper.toFixed(2)); | |
document.getElementById('corpTax').textContent = formatNumber(company.corpTax.toFixed(2)); | |
} | |
document.addEventListener('DOMContentLoaded', function () { | |
calculateTotal(); | |
}); | |
document.addEventListener('keyup', function (e) { | |
if (e.target.tagName === 'INPUT') { | |
formatInput(e.target); | |
calculateTotal(); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Comments are disabled for this gist.