Annual Cost Reduction Plan Generator

Annual Cost Reduction Plan Generator

Current Monthly Spending

No spending categories added yet.

Total Current Monthly: $0.00 | Total Current Annual: $0.00

Set Reduction Targets & Actions

Add spending categories in Tab 1 to set targets.

Total Projected Monthly Savings: $0.00 | Total Projected Annual Savings: $0.00

Annual Cost Reduction Plan Summary

Your plan summary will appear here once targets are set.

Add spending categories in Tab 1 to set targets.

'; acrp_updateTotalProjectedSavingsDisplay(); return; } acrp_spendingCategories.forEach(cat => { const itemDiv = document.createElement('div'); itemDiv.className = 'acrp-reduction-item'; itemDiv.innerHTML = `

${cat.name}

Current Monthly Spending: $${cat.currentMonthlySpending.toFixed(2)} (Annual: $${(cat.currentMonthlySpending * 12).toFixed(2)})

Projected Monthly Saving: $0.00 | Projected Annual Saving: $0.00

`; area.appendChild(itemDiv); acrp_calculateIndividualProjectedSaving(cat.id); // Calculate and display initial saving for this item }); acrp_updateTotalProjectedSavingsDisplay(); } function acrp_updateCategoryTarget(categoryId) { const category = acrp_spendingCategories.find(cat => cat.id === categoryId); if (!category) return; category.reductionType = document.getElementById(`reductionType_${categoryId}`).value; category.reductionValue = parseFloat(document.getElementById(`reductionValue_${categoryId}`).value) || 0; category.actionItems = document.getElementById(`actionItems_${categoryId}`).value.trim(); // Adjust step for reductionValue input based on type for future interactions const valueInput = document.getElementById(`reductionValue_${categoryId}`); valueInput.step = category.reductionType === 'percentage' ? '1' : '0.01'; acrp_calculateIndividualProjectedSaving(categoryId); acrp_updateTotalProjectedSavingsDisplay(); } function acrp_calculateIndividualProjectedSaving(categoryId) { const category = acrp_spendingCategories.find(cat => cat.id === categoryId); if (!category) return { monthly: 0, annual: 0 }; let monthlySaving = 0; if (category.reductionType === 'percentage') { monthlySaving = category.currentMonthlySpending * (category.reductionValue / 100); } else if (category.reductionType === 'fixed') { monthlySaving = category.reductionValue; } // Ensure saving isn't more than current spending for that category monthlySaving = Math.min(monthlySaving, category.currentMonthlySpending); if (monthlySaving < 0) monthlySaving = 0; const annualSaving = monthlySaving * 12; // Update the UI for this specific category const monthlySavingEl = document.getElementById(`monthlySaving_${categoryId}`); const annualSavingEl = document.getElementById(`annualSaving_${categoryId}`); if(monthlySavingEl) monthlySavingEl.textContent = monthlySaving.toFixed(2); if(annualSavingEl) annualSavingEl.textContent = annualSaving.toFixed(2); return { monthly: monthlySaving, annual: annualSaving }; } function acrp_updateTotalProjectedSavingsDisplay() { let totalMonthlySavings = 0; acrp_spendingCategories.forEach(cat => { // Recalculate to be sure, or trust the individual updates if they are always triggered const { monthly } = acrp_getCategoryProjectedSavings(cat); totalMonthlySavings += monthly; }); const displayDiv = document.getElementById('acrpTotalProjectedSavingsDisplay'); if (displayDiv) { displayDiv.innerHTML = `Total Projected Monthly Savings: $${totalMonthlySavings.toFixed(2)} | Total Projected Annual Savings: $${(totalMonthlySavings * 12).toFixed(2)}`; } } function acrp_getCategoryProjectedSavings(category) { let monthlySaving = 0; if (category.reductionType === 'percentage') { monthlySaving = category.currentMonthlySpending * ((category.reductionValue || 0) / 100); } else if (category.reductionType === 'fixed') { monthlySaving = category.reductionValue || 0; } monthlySaving = Math.min(monthlySaving, category.currentMonthlySpending); if (monthlySaving < 0) monthlySaving = 0; return { monthly: monthlySaving, annual: monthlySaving * 12 }; } // --- Plan Summary (Tab 3) & PDF --- function acrp_generatePlanSummaryDisplay() { const summaryArea = document.getElementById('acrpPlanSummaryArea'); const detailsContainer = document.getElementById('acrpPlanDetailsTableContainer'); let totalCurrentMonthlySpending = 0; let totalProjectedMonthlySavings = 0; acrp_spendingCategories.forEach(cat => { totalCurrentMonthlySpending += cat.currentMonthlySpending; const { monthly } = acrp_getCategoryProjectedSavings(cat); totalProjectedMonthlySavings += monthly; }); const totalCurrentAnnualSpending = totalCurrentMonthlySpending * 12; const totalProjectedAnnualSavings = totalProjectedMonthlySavings * 12; const newProjectedAnnualSpending = totalCurrentAnnualSpending - totalProjectedAnnualSavings; const percentageSaved = totalCurrentAnnualSpending > 0 ? (totalProjectedAnnualSavings / totalCurrentAnnualSpending * 100) : 0; summaryArea.innerHTML = `

Overall Plan Metrics

Total Current Annual Spending: $${totalCurrentAnnualSpending.toFixed(2)}

Total Projected Annual Savings: $${totalProjectedAnnualSavings.toFixed(2)}

New Projected Annual Spending: $${newProjectedAnnualSpending.toFixed(2)}

Projected Percentage Saved: ${percentageSaved.toFixed(1)}%

`; let tableHTML = `

Detailed Reduction Plan:

`; if (acrp_spendingCategories.length === 0) { tableHTML += ``; } else { acrp_spendingCategories.forEach(cat => { const currentAnnual = cat.currentMonthlySpending * 12; const { annual: annualSaving } = acrp_getCategoryProjectedSavings(cat); let targetText = cat.reductionType === 'percentage' ? `${cat.reductionValue}% reduction` : `$${cat.reductionValue.toFixed(2)}/month fixed`; if (cat.reductionValue === 0) targetText = "No target set"; tableHTML += ``; }); } tableHTML += '
CategoryCurrent Annual ($)TargetProjected Annual Saving ($)Action Items
No categories defined.
${cat.name} ${currentAnnual.toFixed(2)} ${targetText} ${annualSaving.toFixed(2)} ${cat.actionItems.split(',').map(s=>s.trim()).filter(s=>s).join('; ') || 'N/A'}
'; detailsContainer.innerHTML = tableHTML; } function acrp_generatePdf() { const { jsPDF } = window.jspdf; const doc = new jsPDF(); let yPos = 20; const primaryColor = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim(); const accentColor = getComputedStyle(document.documentElement).getPropertyValue('--accent-color').trim(); const textColor = getComputedStyle(document.documentElement).getPropertyValue('--text-color').trim(); doc.setFontSize(20); doc.setTextColor(primaryColor); doc.text("Annual Cost Reduction Plan", doc.internal.pageSize.getWidth() / 2, yPos, { align: 'center' }); yPos += 15; // Overall Summary Metrics let totalCurrentMonthlySpending = 0; let totalProjectedMonthlySavings = 0; acrp_spendingCategories.forEach(cat => { totalCurrentMonthlySpending += cat.currentMonthlySpending; const { monthly } = acrp_getCategoryProjectedSavings(cat); totalProjectedMonthlySavings += monthly; }); const totalCurrentAnnualSpending = totalCurrentMonthlySpending * 12; const totalProjectedAnnualSavings = totalProjectedMonthlySavings * 12; const newProjectedAnnualSpending = totalCurrentAnnualSpending - totalProjectedAnnualSavings; const percentageSaved = totalCurrentAnnualSpending > 0 ? (totalProjectedAnnualSavings / totalCurrentAnnualSpending * 100) : 0; doc.setFontSize(14); doc.setTextColor(primaryColor); doc.text("Plan Overview", 14, yPos); yPos += 8; doc.setFontSize(11); doc.setTextColor(textColor); doc.text(`Total Current Annual Spending: $${totalCurrentAnnualSpending.toFixed(2)}`, 14, yPos); yPos += 7; doc.setTextColor(accentColor); doc.text(`Total Projected Annual Savings: $${totalProjectedAnnualSavings.toFixed(2)}`, 14, yPos); yPos += 7; doc.setTextColor(textColor); doc.text(`New Projected Annual Spending: $${newProjectedAnnualSpending.toFixed(2)}`, 14, yPos); yPos += 7; doc.setTextColor(accentColor); doc.text(`Projected Percentage Saved: ${percentageSaved.toFixed(1)}%`, 14, yPos); yPos += 10; doc.setTextColor(textColor); // Detailed Plan Table if (acrp_spendingCategories.length > 0) { if (yPos > 250) { doc.addPage(); yPos = 20; } doc.setFontSize(14); doc.setTextColor(primaryColor); doc.text("Detailed Reduction Plan", 14, yPos); yPos += 8; const tableBody = acrp_spendingCategories.map(cat => { const currentAnnual = cat.currentMonthlySpending * 12; const { annual: annualSaving } = acrp_getCategoryProjectedSavings(cat); let targetText = cat.reductionType === 'percentage' ? `${cat.reductionValue}%` : `$${cat.reductionValue.toFixed(2)}/mo`; if (cat.reductionValue === 0 || isNaN(cat.reductionValue)) targetText = "-"; return [ cat.name, `$${currentAnnual.toFixed(2)}`, targetText, `$${annualSaving.toFixed(2)}`, cat.actionItems.split(',').map(s=>s.trim()).filter(s=>s).join('; ') || "-" ]; }); doc.autoTable({ startY: yPos, head: [['Category', 'Current Annual ($)', 'Target', 'Projected Annual Saving ($)', 'Action Items']], body: tableBody, theme: 'grid', headStyles: { fillColor: primaryColor, textColor: '#ffffff' }, styles: { fontSize: 9, cellPadding: 1.5 }, columnStyles: { 4: { cellWidth: 'wrap', overflow: 'linebreak', minCellWidth: 40 } }, didDrawPage: (data) => { yPos = data.cursor.y; } }); // yPos = doc.lastAutoTable.finalY + 10; // Not needed if nothing follows table } else { doc.setFontSize(11); doc.text("No detailed plan items defined.", 14, yPos); } doc.save('annual_cost_reduction_plan.pdf'); } // Initialize document.addEventListener('DOMContentLoaded', () => { acrp_showTab(0); acrp_renderSpendingCategoriesTable(); acrp_updateTotalCurrentSpendingDisplay(); // Demo data acrp_spendingCategories.push({id: 'cat_001', name: 'Groceries', currentMonthlySpending: 400, reductionType: 'percentage', reductionValue: 10, actionItems: 'Buy generic brands, Plan meals'}); acrp_spendingCategories.push({id: 'cat_002', name: 'Dining Out', currentMonthlySpending: 150, reductionType: 'fixed', reductionValue: 50, actionItems: 'Limit to once a week, Pack lunch'}); acrp_spendingCategories.push({id: 'cat_003', name: 'Subscriptions', currentMonthlySpending: 60, reductionType: 'percentage', reductionValue: 20, actionItems: 'Cancel unused ones, Share accounts'}); acrp_renderSpendingCategoriesTable(); acrp_updateTotalCurrentSpendingDisplay(); });
Scroll to Top