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:
| Category | Current Annual ($) | Target | Projected 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'} |
