Smart Spending Budget Tool 🚀

💰 My Income

Income Log:

  • No income logged yet.

🎯 My Savings Goals

My Goals:

  • No goals set yet.

💸 Log My Spending

My Recent Spending:

  • No spending logged yet.

📊 My Budget Dashboard

Total Income Logged: $0.00

Total Spent: $0.00

Money Left: $0.00

🏆 Savings Goals Progress:

  • No goals to show progress for.

🛒 Spending Breakdown (by Category):

  • No spending to break down yet.

💡 Smart Spending Tip!

Track every dollar! Small spends add up quickly.

Money Left: ${document.getElementById('moneyLeftDisplay').textContent}

`; // Income html += `

💰 Income Logged

`; if (incomeItems.length > 0) { html += `
    ${incomeItems.map(item => `
  • ${item.source}: ${formatCurrency(item.amount)}
  • `).join('')}
`; } else { html += `

No income logged.

`; } // Goals html += `

🎯 Savings Goals

`; if (goals.length > 0) { html += `
    ${goals.map(goal => { const progressPercent = Math.min(100, (goal.savedAmount / goal.targetAmount * 100) || 0).toFixed(0); return `
  • ${goal.name} (Target: ${formatCurrency(goal.targetAmount)})
    Saved: ${formatCurrency(goal.savedAmount)} (${progressPercent}%)
  • `; }).join('')}
`; } else { html += `

No goals set.

`; } // Spending Breakdown html += `

🛒 Spending Breakdown

`; const spendingByCategory = expenseItems.reduce((acc, item) => { acc[item.category] = (acc[item.category] || 0) + item.amount; return acc; }, {}); if (Object.keys(spendingByCategory).length > 0) { html += `
    ${Object.entries(spendingByCategory).sort(([,a],[,b]) => b-a).map(([category, amount]) => `
  • ${category}: ${formatCurrency(amount)}
  • `).join('')}
`; } else { html += `

No spending logged.

`; } // Recent Expenses (optional, can make PDF long) // html += `

💸 Recent Spending

`; // if (expenseItems.length > 0) { // const recentExpensesForPdf = [...expenseItems].sort((a,b) => new Date(b.date) - new Date(a.date)).slice(0,10); // Show last 10 // html += `
    ${recentExpensesForPdf.map(item => `
  • ${item.date} - ${item.description} (${item.category}): ${formatCurrency(item.amount)}
  • `).join('')}
`; // } else { // html += `

No spending logged.

`; // } html += `

Keep up the great budgeting! 🎉

`; pdfContentElement.innerHTML = html; document.body.appendChild(pdfContentElement); html2canvas(pdfContentElement, { scale: 1.5, useCORS: true }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pageHeight = pdf.internal.pageSize.getHeight(); const imgHeight = canvas.height * pdfWidth / canvas.width; let heightLeft = imgHeight; let position = 10; // Margin pdf.addImage(imgData, 'PNG', 10, position, pdfWidth - 20, imgHeight); heightLeft -= (pageHeight - 20); while (heightLeft > 0) { position = heightLeft - imgHeight - 10; pdf.addPage(); pdf.addImage(imgData, 'PNG', 10, position, pdfWidth - 20, imgHeight); heightLeft -= (pageHeight - 20); } pdf.save('My_Smart_Budget.pdf'); document.body.removeChild(pdfContentElement); }).catch(error => { console.error("Error generating PDF:", error); alert("Could not generate PDF. See console for details."); if(document.body.contains(pdfContentElement)) document.body.removeChild(pdfContentElement); }); }
Scroll to Top