Automated Inventory Buffer Stock Recommendation System

Automated Inventory Buffer Stock Recommendation System

Calculate optimal safety stock levels to prevent stockouts and reduce costs.

Buffer Stock Analysis

Product Current Stock Recommended Buffer Reorder Point Status

Manage Product Inventory Data

Product Name Current Stock Avg Daily Sales Max Daily Sales Avg Lead Time (Days) Max Lead Time (Days)

Critical Items (Below Reorder Point)

${criticalItems}

Total Recommended Buffer Units

${totalBufferUnits}

Products Analyzed

${products.length}

`; document.getElementById('dashboard-date').textContent = `Analysis as of: ${new Date().toLocaleDateString()}`; } // --- Tab & Navigation Logic --- function switchTab(targetTabId) { if (targetTabId === 'dashboard') { const products = analyzeStockLevels(); if (products === null) return; renderDashboard(products); } currentTab = targetTabId; tabs.forEach(tab => tab.classList.toggle('active', tab.dataset.tab === currentTab)); tabContents.forEach(content => content.classList.toggle('active', content.id === currentTab)); updateNavButtons(); } tabs.forEach(tab => tab.addEventListener('click', () => switchTab(tab.dataset.tab))); nextBtn.addEventListener('click', () => currentTab === 'dashboard' ? switchTab('config') : switchTab('dashboard')); prevBtn.addEventListener('click', () => currentTab === 'config' ? switchTab('dashboard') : switchTab('config')); function updateNavButtons() { if (currentTab === 'dashboard') { nextBtn.textContent = 'Configure Data'; prevBtn.style.display = 'none'; pdfButtonContainer.style.display = 'block'; } else { nextBtn.textContent = 'Update Dashboard'; prevBtn.style.display = 'inline-flex'; pdfButtonContainer.style.display = 'none'; } } // --- PDF Download --- downloadPdfBtn.addEventListener('click', async () => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'l', unit: 'mm', format: 'a4' }); const content = document.getElementById('pdf-content'); await new Promise(r => setTimeout(r, 100)); // Allow DOM update const canvas = await html2canvas(content, { scale: 2 }); const imgData = canvas.toDataURL('image/jpeg', 1.0); doc.setFont('helvetica', 'bold'); doc.setFontSize(18); doc.text('Inventory Buffer Stock Report', 14, 22); const imgProps = doc.getImageProperties(imgData); const pdfWidth = doc.internal.pageSize.getWidth() - 28; const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; doc.addImage(imgData, 'JPEG', 14, 30, pdfWidth, pdfHeight); doc.save(`Buffer-Stock-Report-${new Date().toISOString().slice(0,10)}.pdf`); }); // --- Initial Load --- function populateSampleData() { [ { name: 'Wireless Mouse', stock: 150, avgSales: 10, maxSales: 25, avgLead: 7, maxLead: 12 }, { name: 'Mechanical Keyboard', stock: 80, avgSales: 5, maxSales: 15, avgLead: 14, maxLead: 21 }, { name: '4K Webcam', stock: 45, avgSales: 8, maxSales: 20, avgLead: 10, maxLead: 15 }, { name: 'USB-C Hub', stock: 200, avgSales: 15, maxSales: 30, avgLead: 5, maxLead: 8 } ].forEach(p => createProductRow(p)); } populateSampleData(); switchTab('dashboard'); // Analyze and show dashboard on load });
Scroll to Top