Skip to content

Instantly share code, notes, and snippets.

@spcheema
Last active May 8, 2025 08:26
Show Gist options
  • Save spcheema/c0ead757473492eb548e8a73806b8efa to your computer and use it in GitHub Desktop.
Save spcheema/c0ead757473492eb548e8a73806b8efa to your computer and use it in GitHub Desktop.
Contracting benefits calculator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
margin: 0;
padding: 0;
background: #f8f9fa;
display: flex;
justify-content: center;
align-items: flex-start;
font-size: 14px;
}
strong {
font-weight: 600;
}
.invoice-container {
width: 800px;
background: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
#h2 {
text-align: center;
margin: auto
}
@media print {
@page {
margin: 0;
size: A4;
}
body {
background: none;
margin: 0;
padding: 0;
}
#h2 {
text-align: center;
margin: 100px 0 20px
}
.invoice-container {
width: 100%;
box-shadow: none;
padding: 20px;
margin: 0;
}
#chechlist {
display: none;
}
}
.header-container {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.header-container,
.details,
.service-description {
padding: 15px;
;
border: 1px solid #ddd;
border-bottom: 0;
}
.company-details {
text-align: left;
}
.invoice-details {
text-align: right;
}
.invoice-details table {
width: 100%;
text-align: right;
border-collapse: collapse;
border: none;
}
.invoice-details td {
padding: 2px;
border: none;
}
.invoice-details td:nth-child(1)
{
text-align: right;
font-size: 14px;
padding-right: 5px;
}
p {
font-size: 14px;
margin: 5px 0;
}
table {
width: 100%;
border-collapse: collapse;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background: #f0f0f0;
}
.total {
text-align: right;
font-weight: bold;
}
.bank-details table,
.bank-details table td {
border: none;
}
.bank-details table td {
padding: 2px;
}
.bank-details table td:nth-child(1) {
width: 130px;
}
.bank-details h4 {
margin: 50px 0 0;
}
#chechlist {
font-weight: 600;
color: red;
font-size: 16px;
/* float: left; */
}
</style>
<script>
let serviceDate = new Date()
serviceDate.setMonth((new Date()).getMonth()-1);
let month = serviceDate.toLocaleString('default', { month: 'short' });
let year = serviceDate.getFullYear();
function onLoad() {
document.getElementById('invoice-date-input').valueAsDate = new Date();
console.log(document.getElementById('invoice-date-input').valueAsDate.getDate()+10)
var tomorrow = new Date();
tomorrow.setDate(document.getElementById('invoice-date-input').valueAsDate.getDate()+10);
document.getElementById('invoice-due-date').valueAsDate = tomorrow
document.title = `Invoice-${month}-${year}`
}
function calculateTotals() {
let rate = 900;
let days = parseInt(document.getElementById("days-input").value);
// document.getElementById('invoice-date-input').valueAsDate = new Date();
let today = new Date()
var tomorrow = new Date();
console.log(document.getElementById('invoice-date-input').valueAsDate.getDate()+10)
// tomorrow.setDate(document.getElementById('invoice-date-input').valueAsDate.getDate()+10);
// document.getElementById('invoice-due-date').valueAsDate = tomorrow
console.log("Invoice Date",document.getElementById("invoice-date-input").value)
console.log("Invoice Due Date",document.getElementById("invoice-due-date").value)
let amount = rate * days;
let gst = amount * 0.10;
let total = amount + gst;
document.getElementById("days").innerText = days;
document.getElementById("amount").innerText = new Intl.NumberFormat('en-AU', { style: 'currency', currency: 'AUD' }).format(amount);
document.getElementById("subtotal").innerText = new Intl.NumberFormat('en-AU', { style: 'currency', currency: 'AUD' }).format(amount);
document.getElementById("gst").innerText = new Intl.NumberFormat('en-AU', { style: 'currency', currency: 'AUD' }).format(gst);
document.getElementById("total").innerText = new Intl.NumberFormat('en-AU', { style: 'currency', currency: 'AUD' }).format(total);
let options = { timeZone: 'Australia/Sydney', year: 'numeric', month: '2-digit', day: '2-digit' };
// let invoiceDate = new Date().toLocaleDateString('en-AU', options).replace(/\//g, '-');
// document.getElementById("invoice-date").innerText = invoiceDate;
let invoiceDate = document.getElementById('invoice-date-input').valueAsDate.toLocaleDateString('en-AU', options).replace(/\//g, '-');
console.log(invoiceDate)
document.getElementById("invoice-date").innerText = invoiceDate;
document.getElementById("service-description").innerText = `Service fee of Surinder Pal Singh for the month of ${month} ${year}`;
document.getElementById("service-description").style.display = "none !important";
// let dueDate = new Date();
// dueDate.setDate(today.getDate() + 10);
// let dueDateString = dueDate.toLocaleDateString('en-AU', options).replace(/\//g, '-');
dueDateString = document.getElementById('invoice-due-date').valueAsDate.toLocaleDateString('en-AU', options).replace(/\//g, '-');
document.getElementById("due-date").innerText = dueDateString;
let sequentialNumber = '001';
document.getElementById("invoice-number").innerText = `${serviceDate.getFullYear()}-${String(serviceDate.getMonth()+1).padStart(2, '0')}-${sequentialNumber}`;
// document.getElementById("invoice-number").innerText = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${sequentialNumber}`;
}
</script>
</head>
<body onload="onLoad()">
<div class="invoice-container">
<div id="chechlist">
<div id="input-container">
<label for="days-input">Number of Days:</label>
<input type="number" id="days-input" value="7" min="1">
<label for="days-input">Invoice date:</label>
<input type="date" id="invoice-date-input" >
<label for="days-input">Due date:</label>
<input type="date" id="invoice-due-date">
<button onclick="calculateTotals()">Update Invoice</button>
</div>
<p>Checklist</p>
<ul>
<li>Invoice no.</li>
<li>Invoice date</li>
<li>Invoice due date</li>
<li>Description</li>
<li>No. of days</li>
<li>Total with GST</li>
<li>Most important bank account details</li>
</ul>
</div>
<h2 id="h2">TAX INVOICE</h2>
<br /><br /><br />
<div class="header-container">
<div class="company-details">
<p><strong>ESS PEE CONSULTING PTY LTD</strong></p>
<p>ABN: 16 683 630 971</p>
<p>ACN: 683 630 971</p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
</div>
<div class="invoice-details">
<table>
<tr>
<td><strong>Invoice Number:</strong></td>
<td id="invoice-number"></td>
</tr>
<tr>
<td><strong>Invoice Date:</strong></td>
<td id="invoice-date"></td>
</tr>
<tr>
<td><strong>Due Date:</strong></td>
<td><span id="due-date"></span></td>
</tr>
</table>
</div>
</div>
<!-- <div class="service-description">
<p style="margin-right: 5px"><strong>Service Description:</strong></p>
<p>Technical Services</p>
</div> -->
<div class="details">
<p><strong>Bill To:</strong></p>
<p>Alois Australia Pty Ltd</p>
<p>Level 7, 88 Phillip Street, Sydney, NSW 2000, Australia</p>
<p>ABN: 24 647 056 693</p>
<p>ACN: 647 056 693</p>
</div>
<table>
<thead>
<tr>
<th>Description</th>
<th>Rate (AUD)</th>
<th>Days</th>
<th>Amount (AUD)</th>
</tr>
</thead>
<tbody>
<tr>
<td id="service-description">Service fee of Surinder Pal Singh</td>
<td>$900</td>
<td id="days"></td>
<td id="amount"></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3" class="total">Subtotal</td>
<td id="subtotal"></td>
</tr>
<tr>
<td colspan="3" class="total">GST (10%)</td>
<td id="gst"></td>
</tr>
<tr>
<td colspan="3" class="total">Invoice Total (Inclusive of Taxes)</td>
<td id="total"></td>
</tr>
</tfoot>
</table>
<div class="bank-details">
<table>
<tr>
<td colspan="2"><h4>Bank Account Details</h4></td>
</tr>
<tr>
<td><strong>Account Name:</strong></td>
<td>ESS PEE CONSULTING PTY LTD</td>
</tr>
<tr>
<td><strong>BSB Number:</strong></td>
<td>067-873</td>
</tr>
<tr>
<td><strong>Account Number:</strong></td>
<td>1538 1057</td>
</tr>
</table>
</div>
</div>
</body>
</html>

Comments are disabled for this gist.