Side Hustle Profitability Calculator

General Information

Income

One-Time Startup Costs for this Period

Total Startup Costs: $0.00

Recurring Costs (Enter as Per Month)

Total Monthly Recurring Costs: $0.00

Time Investment

Profitability Analysis for "My Side Project"

Please complete inputs and click "Calculate Profitability".

Total Hours Invested: ${totalHours.toLocaleString()} hours

`; costBreakdownEl.innerHTML = `

Cost Breakdown:

Total One-Time Startup Costs: $${totalOneTime.toLocaleString(undefined, {minimumFractionDigits:2, maximumFractionDigits:2})}

Total Monthly Recurring Costs: $${totalMonthlyRecurring.toLocaleString(undefined, {minimumFractionDigits:2, maximumFractionDigits:2})}

Total Recurring Costs for Period (${numMonthsInPeriod} months): $${totalRecurringForPeriod.toLocaleString(undefined, {minimumFractionDigits:2, maximumFractionDigits:2})}

Total Costs for Period: $${totalCostsForPeriod.toLocaleString(undefined, {minimumFractionDigits:2, maximumFractionDigits:2})}

`; let profitMetricsHTML = `

Profitability Metrics:

Net Profit / (Loss) for Period: $${netProfit.toLocaleString(undefined, {minimumFractionDigits:2, maximumFractionDigits:2})}

Profit Margin: ${totalRevenue > 0 ? profitMargin.toFixed(1) + '%' : 'N/A'}

Profit per Hour: ${totalHours > 0 ? '$' + profitPerHour.toLocaleString(undefined, {minimumFractionDigits:2, maximumFractionDigits:2}) + '/hr' : 'N/A'}

`; if (netProfit >= 0) { profitMetricsHTML += `

This side hustle appears profitable for the specified period based on your inputs.

`; } else { profitMetricsHTML += `

This side hustle appears to be operating at a loss for the specified period based on your inputs.

`; } profitMetricsEl.innerHTML = profitMetricsHTML; notesContainerEl.style.display = 'block'; downloadPdfBtn.style.display = 'block'; }); // --- PDF Download --- downloadPdfBtn?.addEventListener('click', function () { const { jsPDF } = window.jspdf; const pdfOutputArea = document.getElementById('shpPdfOutputArea'); if (!pdfOutputArea || profitMetricsEl.innerHTML.includes("Please complete inputs")) { alert('Please calculate profitability first before downloading PDF.'); return; } // Ensure title in PDF area is updated document.querySelector('#shpPdfOutputArea #shpAnalysisTitle').textContent = analysisTitleEl.textContent; html2canvas(pdfOutputArea, { scale: 1.5, useCORS: true, backgroundColor: '#ffffff', windowWidth: pdfOutputArea.scrollWidth }) .then(canvas => { const imgData = canvas.toDataURL('image/jpeg', 0.9); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const margin = 30; let contentWidth = pdfWidth - 2 * margin; const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; let imgWidth = contentWidth; let imgHeight = imgWidth / ratio; if (imgHeight > pdfHeight - 2 * margin) { imgHeight = pdfHeight - 2 * margin; imgWidth = imgHeight * ratio; if (imgWidth > contentWidth) { imgWidth = contentWidth; imgHeight = imgWidth / ratio; } } const x = (pdfWidth - imgWidth) / 2; pdf.addImage(imgData, 'JPEG', x, margin, imgWidth, imgHeight, undefined, 'MEDIUM'); pdf.save(`${(document.getElementById('shpName').value || 'SideHustle').replace(/\s+/g, '_')}_Profitability.pdf`); }) .catch(err => { console.error("Error generating PDF:", err); alert("Error generating PDF. See console for details."); }); }); // --- Utility --- function escapeHtml(unsafe) { if (typeof unsafe !== 'string') return unsafe === undefined || unsafe === null ? '' : String(unsafe); return unsafe.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); } // --- Initial Setup --- switchTab('detailsTab'); });
Scroll to Top