Recovery Rate Calculator - Calculate Debt Recovery Percentage
Recovery Analysis
Time-Adjusted Recovery
0%
Annualized rate
`;
}
updateURL(results) {
if (!results) return;
const params = new URLSearchParams({
total: results.total,
recovered: results.recovered,
costs: results.costs,
time: results.timePeriod,
method: results.method
});
const newUrl = `${window.location.pathname}?${params.toString()}`;
window.history.replaceState({}, '', newUrl);
}
loadFromURL() {
const params = new URLSearchParams(window.location.search);
if (params.has('total')) {
this.elements.totalAmount.value = params.get('total');
this.elements.recoveredAmount.value = params.get('recovered') || '0';
this.elements.recoveryCosts.value = params.get('costs') || '0';
const timePeriod = params.get('time') || '30';
document.querySelector(`input[name="timePeriod"][value="${timePeriod}"]`).checked = true;
const method = params.get('method') || 'legal';
document.getElementById('recoveryMethod').value = method;
// Auto-calculate after a brief delay
setTimeout(() => this.calculate(), 500);
}
}
showToast(message, type = 'info') {
const toast = this.elements.toast;
toast.textContent = message;
toast.className = `toast ${type}`;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
}
// Initialize calculator when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
new RecoveryRateCalculator();
});
} else {
new RecoveryRateCalculator();
}