Petrol Pump Accounting In Excel Sheet Download Guide
// 3. Stock Management Table html += `<h3 style="margin:25px 0 5px 0; color:#1e4a2f;">📦 Stock Summary (Liters / Units)</h3>`; html += `<table id="stockTable"><thead><tr><th>Product</th><th>Opening (Ltr)</th><th>Received (Ltr)</th><th>Sold (Ltr)</th><th>Closing (Ltr)</th><th>Unit Price (₹)</th><th>Stock Value (₹)</th><th></th></tr></thead><tbody>`; for (let i = 0; i < stockData.length; i++) let st = stockData[i]; let stockValue = (st.closing * st.unitPrice).toFixed(2); html += `<tr data-type="stock" data-index="$i"> <td style="background:#faf3e0;">$st.product</td> <td><input type="number" step="0.01" class="stock-opening" value="$st.opening" data-idx="$i"></td> <td><input type="number" step="0.01" class="stock-received" value="$st.received" data-idx="$i"></td> <td><input type="number" step="0.01" class="stock-sold" value="$st.sold" data-idx="$i"></td> <td class="stock-closing">$st.closing.toFixed(2)</td> <td><input type="number" step="0.01" class="stock-price" value="$st.unitPrice" data-idx="$i"></td> <td class="stock-value">$stockValue</td> <td><button class="delRowBtn" data-type="stock" data-idx="$i" style="background:#b33;">🗑️</button></td> </tr>`; html += `<tr><td colspan="7"><button id="addStockRowBtn" style="background:#3c8c40;">+ Add Stock Product</button></td><td></td></tr>`; html += `</tbody></table>`;
function resetDemo() salesData = [ product: "Petrol (MS)", liters: 1250, rate: 102.50, amount: 128125 , product: "Diesel (HSD)", liters: 980, rate: 94.80, amount: 92904 , product: "Premium Petrol", liters: 320, rate: 115.00, amount: 36800 , product: "Engine Oil (Lube)", liters: 45, rate: 850, amount: 38250 ]; expensesData = [ date: "01-Apr-2026", category: "Electricity", amount: 5500 , date: "05-Apr-2026", category: "Staff Salary", amount: 28500 , date: "10-Apr-2026", category: "Maintenance", amount: 3200 , date: "15-Apr-2026", category: "Misc", amount: 1750 ]; stockData = [ product: "Petrol (MS)", opening: 5200, received: 8000, sold: 1250, closing: 11950, unitPrice: 102.50 , product: "Diesel (HSD)", opening: 4300, received: 7000, sold: 980, closing: 10320, unitPrice: 94.80 , product: "Premium Petrol", opening: 1100, received: 2000, sold: 320, closing: 2780, unitPrice: 115.00 , product: "Engine Oil (Lube)", opening: 180, received: 120, sold: 45, closing: 255, unitPrice: 850.00 ]; recomputeSales(); recomputeStock(); renderTables();
// Build HTML with three sections let html = `<style>td input border:1px solid #ddd; border-radius:6px; padding:6px; text-align:center; td vertical-align: middle; </style>`; petrol pump accounting in excel sheet download
// Render full editable Excel-style tables function renderTables() const container = document.getElementById("excelTableContainer"); if (!container) return;
function getTotalExpenses() return expensesData.reduce((sum, exp) => sum + exp.amount, 0); document
// Get total sales sum function getTotalSales() return salesData.reduce((sum, item) => sum + item.amount, 0);
function attachInputEvents() // Sales liters & rate document.querySelectorAll('.sales-lit, .sales-rate').forEach(inp => inp.removeEventListener('input', salesChangeHandler); inp.addEventListener('input', salesChangeHandler); ); // Expenses amount document.querySelectorAll('.exp-amt').forEach(inp => inp.removeEventListener('input', expenseChangeHandler); inp.addEventListener('input', expenseChangeHandler); ); // Stock fields: opening, received, sold, price document.querySelectorAll('.stock-opening, .stock-received, .stock-sold, .stock-price').forEach(inp => inp.removeEventListener('input', stockChangeHandler); inp.addEventListener('input', stockChangeHandler); ); document.querySelector('#expensesTable').outerHTML : ''<
// Download as Excel (XLS format - HTML table wrapper) function downloadExcel() // Generate full workbook style HTML let exportHtml = ` <html> <head><meta charset="UTF-8"><title>PetrolPump_Accounting.xls</title> <style> th background: #4c8b5e; color: #fff; td border: 1px solid #ccc; </style> </head> <body> <h2>Petrol Pump Financial Statement</h2> <h3>Sales Register</h3> <table border="1">$document.querySelector('#salesTable') ? document.querySelector('#salesTable').outerHTML : ''</table> <h3>Expenses Register</h3> <table border="1">$document.querySelector('#expensesTable') ? document.querySelector('#expensesTable').outerHTML : ''</table> <h3>Stock Management</h3> <table border="1">$document.querySelector('#stockTable') ? document.querySelector('#stockTable').outerHTML : ''</table> <br/> <p><strong>Total Sales:</strong> $getTotalSales().toFixed(2)</p> <p><strong>Total Expenses:</strong> $getTotalExpenses().toFixed(2)</p> <p><strong>Net Profit:</strong> $getNetProfit().toFixed(2)</p> <p><strong>Closing Stock Value:</strong> $getTotalClosingStockValue().toFixed(2)</p> </body></html>`; const blob = new Blob([exportHtml], type: "application/vnd.ms-excel" ); const link = document.createElement('a'); const url = URL.createObjectURL(blob); link.href = url; link.download = "Petrol_Pump_Accounts.xls"; document.body.appendChild(link); link.click(); document.body.removeChild(link); URL.revokeObjectURL(url);