Debt Restructuring Scenario Planner

Debt Restructuring Scenario Planner

Plan and predict outcomes for different debt restructuring scenarios.

1. Current Debt Information

Enter the current details of your outstanding debt.

If empty, calculated as Debt * Interest Rate for simplicity.

2. Proposed Restructuring Actions

Specify the changes you want to simulate in this scenario.

e.g., -1.0 for a 1% decrease, 0.5 for a 0.5% increase.

e.g., 2 for an additional 2 years, -0.5 for 6-month reduction.

e.g., 10 for a 10% reduction in principal amount.

Capital raised from new equity investors.

3. ML Model Parameters (Adjust Impact Weights)

Customize the relative importance of each action for predicting restructuring success. Weights sum to 100%.

Total Weights: 100%

Starting probability before considering specific actions.

New Annual Debt Service: $${lastCalculatedResults.newAnnualDebtService.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}

`; const changeDebtServiceColor = lastCalculatedResults.changeInDebtService > 0 ? '#047857' : '#b91c1c'; pdfHtmlContent += `

Change in Debt Service: $${lastCalculatedResults.changeInDebtService.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} (${(lastCalculatedResults.changeInDebtService / lastCalculatedInputs.currentAnnualDebtService * 100).toFixed(2)}%)

`; const cashFlowImpactColor = lastCalculatedResults.estimatedCashFlowImpact > 0 ? '#047857' : '#b91c1c'; pdfHtmlContent += `

Estimated Cash Flow Impact:

`; pdfHtmlContent += `

$${lastCalculatedResults.estimatedCashFlowImpact.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}

`; pdfHtmlContent += `

Positive value indicates cash savings/inflow, negative indicates outflow.

`; const probColor = getProbabilityColor(lastCalculatedResults.finalSuccessProb); pdfHtmlContent += `

Predicted Restructuring Success Probability:

`; pdfHtmlContent += `

${lastCalculatedResults.finalSuccessProb.toFixed(2)}%

`; pdfHtmlContent += `

Assessment: ${lastCalculatedResults.successAssessment}

`; pdfHtmlContent += `

This prediction is based on your defined impact weights for each action.

`; pdfRenderContainer.innerHTML = pdfHtmlContent; try { const canvas = await html2canvas(pdfRenderContainer, { useCORS: true, scale: 2, logging: false }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'mm', 'a4'); const imgWidth = 210; const pageHeight = 297; const imgHeight = canvas.height * imgWidth / canvas.width; let heightLeft = imgHeight; let position = 0; pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; while (heightLeft >= 0) { position = heightLeft - imgHeight; pdf.addPage(); pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; } pdf.save('debt_restructuring_report.pdf'); } catch (error) { console.error('Error generating PDF:', error); alertUser('Failed to generate PDF. Please try again or check console for errors.'); } finally { pdfRenderContainer.innerHTML = ''; } }); // Helper function to get color based on probability function getProbabilityColor(prob) { if (prob >= 80) { return '#047857'; // Tailwind green-700 } else if (prob >= 60) { return '#4338ca'; // Tailwind indigo-700 } else if (prob >= 40) { return '#d97706'; // Tailwind orange-700 } else { return '#b91c1c'; // Tailwind red-700 } } // --- Custom Alert Function --- function alertUser(message) { let msgBox = document.getElementById('user-message-box'); let messageTextSpan; let closeButton; if (!msgBox) { msgBox = document.createElement('div'); msgBox.id = 'user-message-box'; msgBox.className = 'fixed inset-x-0 top-0 flex items-center justify-center p-4 z-50'; msgBox.innerHTML = ` `; document.body.appendChild(msgBox); // Now query within msgBox, after it's in the DOM messageTextSpan = msgBox.querySelector('#user-message-text'); closeButton = msgBox.querySelector('#close-user-message'); closeButton.addEventListener('click', () => { msgBox.classList.add('hidden'); }); } else { // If msgBox already exists, just get references to its children messageTextSpan = msgBox.querySelector('#user-message-text'); closeButton = msgBox.querySelector('#close-user-message'); } messageTextSpan.innerHTML = message; // Use innerHTML to allow line breaks msgBox.classList.remove('hidden'); setTimeout(() => { msgBox.classList.add('hidden'); }, 5000); } });
Scroll to Top