Sales Calculator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sales Calculator</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #f7f7f7;
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
h1 {
color: #333;
}
.calculator-container {
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
max-width: 900px;
width: 100%;
padding: 20px;
margin-top: 20px;
}
form {
display: flex;
flex-direction: column;
}
label {
font-weight: 500;
margin-top: 10px;
margin-bottom: 5px;
color: #555;
}
input, button {
padding: 10px;
font-size: 16px;
border: 1px solid #ddd;
border-radius: 5px;
margin-bottom: 15px;
width: 100%;
box-sizing: border-box;
}
button {
background-color: #28a745;
color: white;
border: none;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #218838;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 12px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
<script>
function calculateSales() {
const date = document.getElementById('date').value;
const trays = parseFloat(document.getElementById('trays').value);
const rate = parseFloat(document.getElementById('rate').value);
const amountPaid = parseFloat(document.getElementById('amountPaid').value);
const eggs = trays * 30;
const amount = eggs * rate;
const remaining = amount - amountPaid;
const profit = amount * 0.10;
const totalPending = remaining > 0 ? remaining : 0;
document.getElementById('result').innerHTML = `
<table>
<tr>
<th>DATE</th>
<th>TRAYS</th>
<th>EGGS</th>
<th>RATE</th>
<th>AMOUNT</th>
<th>PAID</th>
<th>REMAINING</th>
<th>TOTAL PENDING</th>
<th>PROFIT</th>
</tr>
<tr>
<td>${date}</td>
<td>${trays}</td>
<td>${eggs}</td>
<td>₹ ${rate.toFixed(2)}</td>
<td>₹ ${amount.toFixed(2)}</td>
<td>₹ ${amountPaid.toFixed(2)}</td>
<td>₹ ${remaining.toFixed(2)}</td>
<td>₹ ${totalPending.toFixed(2)}</td>
<td>₹ ${profit.toFixed(2)}</td>
</tr>
</table>
`;
}
</script>
</head>
<body>
<h1>Sales Calculator</h1>
<div class="calculator-container">
<form onsubmit="event.preventDefault(); calculateSales();">
<label for="date">Date:</label>
<input type="date" id="date" required>
<label for="trays">Trays:</label>
<input type="number" id="trays" required>
<label for="rate">Rate (₹ per egg):</label>
<input type="number" step="0.01" id="rate" required>
<label for="amountPaid">Amount Paid (₹):</label>
<input type="number" step="0.01" id="amountPaid" required>
<button type="submit">Calculate</button>
</form>
<div id="result"></div>
</div>
</body>
</html>