redone investment scaling logic for incentiving higher investments

This commit is contained in:
Tobias Brunner 2025-07-23 19:58:21 +02:00
parent 59c9fff27d
commit 82e362b532
Signed by: tobru
SSH key fingerprint: SHA256:kOXg1R6c11XW3/Pt9dbLdQvOJGFAy+B2K6v6PtRWBGQ
4 changed files with 283 additions and 45 deletions

View file

@ -122,6 +122,97 @@ class ROICalculatorApp {
updateCalculations() {
if (this.calculator) {
this.calculator.updateCalculations();
this.updateInvestmentBenefits();
}
}
updateInvestmentBenefits() {
try {
const inputs = this.calculator.getInputValues();
const investmentAmount = inputs.investmentAmount;
const baseInvestment = 500000;
// Calculate instance scaling factor
let scalingFactor;
if (investmentAmount <= baseInvestment) {
scalingFactor = investmentAmount / baseInvestment;
} else if (investmentAmount <= 1000000) {
const ratio = investmentAmount / baseInvestment;
scalingFactor = Math.pow(ratio, 1.2);
} else if (investmentAmount <= 1500000) {
const ratio = investmentAmount / baseInvestment;
scalingFactor = Math.pow(ratio, 1.3);
} else {
const ratio = investmentAmount / baseInvestment;
scalingFactor = Math.pow(ratio, 1.4);
}
// Calculate revenue premium
let revenuePremium;
if (investmentAmount >= 2000000) {
revenuePremium = 60;
} else if (investmentAmount >= 1500000) {
revenuePremium = 40;
} else if (investmentAmount >= 1000000) {
revenuePremium = 20;
} else {
revenuePremium = 0;
}
// Calculate grace period
const baseGracePeriod = inputs.gracePeriod;
let gracePeriodBonus;
if (investmentAmount >= 1500000) {
gracePeriodBonus = 12;
} else if (investmentAmount >= 1000000) {
gracePeriodBonus = 6;
} else {
gracePeriodBonus = Math.floor((investmentAmount - baseInvestment) / 250000);
}
const totalGracePeriod = Math.max(0, baseGracePeriod + gracePeriodBonus);
// Calculate max performance bonus
let maxBonus;
if (investmentAmount >= 2000000) {
maxBonus = 35;
} else if (investmentAmount >= 1500000) {
maxBonus = 25;
} else if (investmentAmount >= 1000000) {
maxBonus = 20;
} else {
maxBonus = 15;
}
// Update UI elements
const instanceScaling = document.getElementById('instance-scaling');
if (instanceScaling) {
instanceScaling.textContent = scalingFactor.toFixed(1) + 'x';
instanceScaling.className = scalingFactor >= 2.0 ? 'benefit-value text-success fw-bold' :
scalingFactor >= 1.5 ? 'benefit-value text-primary fw-bold' : 'benefit-value text-secondary fw-bold';
}
const revenuePremiumEl = document.getElementById('revenue-premium');
if (revenuePremiumEl) {
revenuePremiumEl.textContent = '+' + revenuePremium + '%';
revenuePremiumEl.className = revenuePremium >= 40 ? 'benefit-value text-success fw-bold' :
revenuePremium >= 20 ? 'benefit-value text-warning fw-bold' : 'benefit-value text-secondary fw-bold';
}
const gracePeriodEl = document.getElementById('grace-period-display');
if (gracePeriodEl) {
gracePeriodEl.textContent = totalGracePeriod + ' months';
gracePeriodEl.className = totalGracePeriod >= 12 ? 'benefit-value text-success fw-bold' :
totalGracePeriod >= 9 ? 'benefit-value text-info fw-bold' : 'benefit-value text-secondary fw-bold';
}
const maxBonusEl = document.getElementById('max-bonus');
if (maxBonusEl) {
maxBonusEl.textContent = maxBonus + '%';
maxBonusEl.className = maxBonus >= 30 ? 'benefit-value text-success fw-bold' :
maxBonus >= 20 ? 'benefit-value text-warning fw-bold' : 'benefit-value text-secondary fw-bold';
}
} catch (error) {
console.error('Error updating investment benefits:', error);
}
}