function IPVoicePriceCalculator() { this.clipMonthlyPrice = 0; this.clipYearlyPrice = 0; this.clipOneTimePrice = 0; this.durchMonthlyPrice = 0; this.durchYearlyPrice = 0; this.durchOneTimePrice = 0; this.shortBy1MonthlyPrice = 0; this.shortBy1YearlyPrice = 0; this.shortBy1OneTimePrice = 0; this.shortBy2MonthlyPrice = 0; this.shortBy2YearlyPrice = 0; this.shortBy2OneTimePrice = 0; this.phoneNumbers = [ ]; this.recalculate = function(phoneIndex, isDurch, isClip, shortCharge) { if(!Boolean(this.phoneNumbers[phoneIndex])) { phoneIndex = 0; } var monthlyPrice = this.phoneNumbers[phoneIndex].monthly; var yearlyPrice = this.phoneNumbers[phoneIndex].yearly; var oneTimePrice = this.phoneNumbers[phoneIndex].oneTime; if (Boolean(isClip)) { monthlyPrice += this.clipMonthlyPrice; yearlyPrice += this.clipYearlyPrice; oneTimePrice += this.clipOneTimePrice; } if (Boolean(isDurch)) { monthlyPrice += this.durchMonthlyPrice; yearlyPrice += this.durchYearlyPrice; oneTimePrice += this.durchOneTimePrice; } const $vc30 = $('#SPO_IP_VOICE_VOICE_CHANNELS_30SK_2021'); if (!Boolean($vc30) || !$vc30.is(':checked')) { if ('ONE' === shortCharge) { monthlyPrice += this.shortBy1MonthlyPrice; yearlyPrice += this.shortBy1YearlyPrice; oneTimePrice += this.shortBy1OneTimePrice; } if ('TWO' === shortCharge) { monthlyPrice += this.shortBy2MonthlyPrice; yearlyPrice += this.shortBy2YearlyPrice; oneTimePrice += this.shortBy2OneTimePrice; } } phoneIndex += 1; document.getElementById("monthlyPrice" + phoneIndex).innerHTML = "€ " + this.formatNumber(monthlyPrice); document.getElementById("yearlyPrice" + phoneIndex).innerHTML = "€ " + this.formatNumber(yearlyPrice); document.getElementById("oneTimePrice" + phoneIndex).innerHTML = "€ " + this.formatNumber(oneTimePrice); } this.formatNumber = function(value) { return value.toLocaleString('de-DE', {minimumFractionDigits: 2, maximumFractionDigits: 2}); } }