multi-currency support in roi calculator
This commit is contained in:
parent
adc3a6b905
commit
5cc6b779c5
7 changed files with 231 additions and 45 deletions
|
|
@ -210,6 +210,85 @@ class ROICalculatorApp {
|
|||
}
|
||||
}
|
||||
|
||||
updateCurrency(value) {
|
||||
try {
|
||||
const currencyElement = document.getElementById('currency');
|
||||
if (currencyElement) {
|
||||
currencyElement.value = value;
|
||||
}
|
||||
|
||||
// Update all currency-related UI labels
|
||||
this.updateCurrencyLabels(value);
|
||||
|
||||
// Update calculations to reflect new currency formatting
|
||||
this.updateCalculations();
|
||||
} catch (error) {
|
||||
console.error('Error updating currency:', error);
|
||||
}
|
||||
}
|
||||
|
||||
updateCurrencyLabels(currency) {
|
||||
try {
|
||||
// Update investment amount prefix
|
||||
const investmentPrefix = document.getElementById('investment-currency-prefix');
|
||||
if (investmentPrefix) {
|
||||
investmentPrefix.textContent = currency;
|
||||
}
|
||||
|
||||
// Update investment min/max labels
|
||||
const investmentMinLabel = document.getElementById('investment-min-label');
|
||||
if (investmentMinLabel) {
|
||||
investmentMinLabel.textContent = `${currency} 100K`;
|
||||
}
|
||||
|
||||
const investmentMaxLabel = document.getElementById('investment-max-label');
|
||||
if (investmentMaxLabel) {
|
||||
investmentMaxLabel.textContent = `${currency} 2M`;
|
||||
}
|
||||
|
||||
// Update revenue per instance suffix
|
||||
const revenueSuffix = document.getElementById('revenue-currency-suffix');
|
||||
if (revenueSuffix) {
|
||||
revenueSuffix.textContent = `${currency}/month`;
|
||||
}
|
||||
|
||||
// Update core service revenue suffix (it's a direct span, not ID-based)
|
||||
const coreRevenueInput = document.getElementById('core-service-revenue');
|
||||
if (coreRevenueInput) {
|
||||
const coreRevenueSpan = coreRevenueInput.parentElement.querySelector('.input-group-text');
|
||||
if (coreRevenueSpan) {
|
||||
coreRevenueSpan.textContent = `${currency}/month`;
|
||||
}
|
||||
}
|
||||
|
||||
// Update all other currency labels throughout the interface
|
||||
const currencyLabels = document.querySelectorAll('.currency-label');
|
||||
currencyLabels.forEach(label => {
|
||||
label.textContent = currency;
|
||||
});
|
||||
|
||||
// Update range slider labels with currency
|
||||
const revenueLabel = document.querySelector('label[for="revenue-per-instance"]');
|
||||
if (revenueLabel) {
|
||||
revenueLabel.innerHTML = revenueLabel.innerHTML.replace(/(CHF|EUR)/, currency);
|
||||
}
|
||||
|
||||
const coreRevenueLabel = document.querySelector('label[for="core-service-revenue"]');
|
||||
if (coreRevenueLabel) {
|
||||
coreRevenueLabel.innerHTML = coreRevenueLabel.innerHTML.replace(/(CHF|EUR)/, currency);
|
||||
}
|
||||
|
||||
// Update investment amount field display if it has a value
|
||||
const investmentInput = document.getElementById('investment-amount');
|
||||
if (investmentInput && investmentInput.getAttribute('data-value')) {
|
||||
const currentValue = investmentInput.getAttribute('data-value');
|
||||
investmentInput.value = InputUtils.formatNumberWithCommas(currentValue, currency);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error updating currency labels:', error);
|
||||
}
|
||||
}
|
||||
|
||||
updateScenarioChurn(scenarioKey, churnRate) {
|
||||
try {
|
||||
if (this.calculator && this.calculator.scenarios[scenarioKey]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue