feat: remove age based price groups, format currency in calculator

This commit is contained in:
Björn Fromme
2025-02-28 10:40:58 +01:00
parent 5c1b2bf245
commit 061781155e
5 changed files with 38 additions and 408 deletions
@@ -25,30 +25,7 @@
class="form-field"
v-model.number="selectedPax"
@change="onPaxUpdated()"
v-show="nightsCount > 0 && !includesBonusCard"/>
<div class="flex space-x-4" v-show="nightsCount > 0 && includesBonusCard">
<div class="w-1/3 flex flex-col space-y-1">
<span>ab 15 Jahre</span>
<input type="number"
class="form-control"
v-model.number="selectedPaxGroup3"
@change="onPaxUpdated()"/>
</div>
<div class="w-1/3 flex flex-col space-y-1">
<span>7-14 Jahre</span>
<input type="number"
class="form-control"
v-model.number="selectedPaxGroup2"
@change="onPaxUpdated()"/>
</div>
<div class="w-1/3 flex flex-col space-y-1">
<span>4-6 Jahre</span>
<input type="number"
class="form-control"
v-model.number="selectedPaxGroup1"
@change="onPaxUpdated()"/>
</div>
</div>
v-show="nightsCount > 0"/>
<p class="text-sm italic"
v-show="nightsCount === 0">
Bitte zuerst einen Zeitraum wählen
@@ -78,7 +55,7 @@
</label>
<select class="form-field"
v-model="selectedBoard"
v-if="totalPax >= 30">
v-if="selectedPax >= 30">
<option :value="null">Keine Auswahl</option>
<option v-for="board of boards"
:value="board"
@@ -86,7 +63,7 @@
{{ board.title }} ({{ formatCurrency(board.price) }} pro Person und Nacht)
</option>
</select>
<div v-show="totalPax < 30">
<div v-show="selectedPax < 30">
<span class="text-red-600">Erst ab 30 Personen buchbar.</span>
</div>
</div>
@@ -115,15 +92,6 @@
<th class="text-left py-2">Aufpreis Kurzzeit</th>
<td>{{ formatCurrency(priceShortTerm) }}</td>
</tr>
<tr class="odd:bg-zinc-100"
v-if="includesBonusCard">
<th class="text-left py-2">Inklusivleistungen</th>
<td>
<a href="https://www.saalbach.com/de/sommer/joker-card" target="_blank" class="uppercase">
Joker Card
</a>
</td>
</tr>
<tr class="odd:bg-zinc-100"
v-if="selectedOptions.length > 0">
<th class="text-left py-2">Zusatzleistungen</th>
@@ -374,9 +342,17 @@ export default {
let price
if ('CH' === this.countryCode && 0 < CHF) {
price = `${parseFloat(CHF).toFixed(2).replace(/\./, ',')} CHF`
let formatter = new Intl.NumberFormat('de-DE', {
style: 'currency',
currency: 'CHF',
})
price = formatter.format(CHF)
} else {
price = parseFloat(EUR).toFixed(2).replace(/\./, ',') + ' €'
let formatter = new Intl.NumberFormat('de-DE', {
style: 'currency',
currency: 'EUR',
})
price = formatter.format(EUR)
}
return price
@@ -420,7 +396,7 @@ export default {
this.selectedRange = range;
},
onPaxUpdated() {
if (this.totalPax < 30) {
if (this.selectedPax < 30) {
this.selectedBoard = null;
}
},
@@ -436,10 +412,7 @@ export default {
'tx_epproducts_ajax[groupsPriceInquiry][remarks]': this.remarks,
'tx_epproducts_ajax[groupsPriceInquiry][dateFrom]': this.selectedFrom.format('DD.MM.YYYY'),
'tx_epproducts_ajax[groupsPriceInquiry][dateTo]': this.selectedTo.format('DD.MM.YYYY'),
'tx_epproducts_ajax[groupsPriceInquiry][pax]': this.includesBonusCard ? '' : this.selectedPax,
'tx_epproducts_ajax[groupsPriceInquiry][paxGroup1]': this.includesBonusCard ? this.selectedPaxGroup1 : '',
'tx_epproducts_ajax[groupsPriceInquiry][paxGroup2]': this.includesBonusCard ? this.selectedPaxGroup2 : '',
'tx_epproducts_ajax[groupsPriceInquiry][paxGroup3]': this.includesBonusCard ? this.selectedPaxGroup3 : '',
'tx_epproducts_ajax[groupsPriceInquiry][pax]': this.selectedPax,
'tx_epproducts_ajax[groupsPriceInquiry][summary][paxBase]': this.formatCurrency(this.pricePax.base),
'tx_epproducts_ajax[groupsPriceInquiry][summary][paxAdditional]': this.formatCurrency(this.pricePax.additional),
'tx_epproducts_ajax[groupsPriceInquiry][summary][undersubscription]': this.formatCurrency(this.pricePax.undersubscription),
@@ -489,19 +462,6 @@ export default {
return this.selectedFrom.format('DD.MM.YYYY') + ' - ' + this.selectedTo.format('DD.MM.YYYY');
},
includesBonusCard() {
let included = false
for (let date of this.selectedRange) {
for (let config of this.configs) {
if (date >= dayjs(config.dateFrom) && date < dayjs(config.dateTo)) {
if (config.bonusCardIncluded) {
included = true
}
}
}
}
return included
},
pricePax() {
let base = {
EUR: 0,
@@ -520,47 +480,22 @@ export default {
if (date >= dayjs(config.dateFrom) && date < dayjs(config.dateTo)) {
base.EUR += config.price.EUR
base.CHF += config.price.CHF
if (this.totalPax > config.personsIncluded) {
if (false === config.bonusCardIncluded) {
additional.EUR += (this.selectedPax - config.personsIncluded) * config.priceAdditionalPerson.EUR;
additional.CHF += (this.selectedPax - config.personsIncluded) * config.priceAdditionalPerson.CHF;
} else {
// Distribute additional persons costs by group
let included = config.personsIncluded
if (this.selectedPaxGroup3 <= included) {
included -= this.selectedPaxGroup3
} else {
additional.EUR += (this.selectedPaxGroup3 - included) * config.priceAdditionalPersonByGroup[3].EUR
additional.CHF += (this.selectedPaxGroup3 - included) * config.priceAdditionalPersonByGroup[3].EUR
included = 0
}
if (this.selectedPaxGroup2 <= included) {
included -= this.selectedPaxGroup2
} else {
additional.EUR += (this.selectedPaxGroup2 - included) * config.priceAdditionalPersonByGroup[2].EUR
additional.CHF += (this.selectedPaxGroup2 - included) * config.priceAdditionalPersonByGroupCHF[2].CHF
included = 0
}
if (this.selectedPaxGroup1 > included) {
additional.EUR += (this.selectedPaxGroup1 - included) * config.priceAdditionalPersonByGroup[1].EUR
additional.CHF += (this.selectedPaxGroup1 - included) * config.priceAdditionalPersonByGroupCHF[1].CHF
}
}
let included = config.personsIncluded
let additionalPax = this.selectedPax - included
if (this.selectedPax > included) {
additional.EUR += additionalPax * config.priceAdditionalPerson.EUR
additional.CHF += additionalPax * config.priceAdditionalPerson.CHF
}
}
}
}
if (this.selectedBoard && this.totalPax < 50) {
undersubscription.EUR = this.totalPax * this.undersubscriptionEur * this.selectedRange.length
undersubscription.CHF = this.totalPax * this.undersubscriptionChf * this.selectedRange.length
if (this.selectedBoard && this.selectedPax < 50) {
undersubscription.EUR = this.selectedPax * this.undersubscriptionEur * this.selectedRange.length
undersubscription.CHF = this.selectedPax * this.undersubscriptionChf * this.selectedRange.length
}
return {base, additional, undersubscription}
},
totalPax() {
return this.includesBonusCard ?
this.selectedPaxGroup1 + this.selectedPaxGroup2 + this.selectedPaxGroup3 : this.selectedPax
},
priceOptions() {
let price = {
EUR: 0,
@@ -577,14 +512,14 @@ export default {
price.EUR += optionPriceEUR;
price.CHF += optionPriceCHF;
} else if (2 === option.type) {
price.EUR += optionPriceEUR * this.totalPax;
price.CHF += optionPriceCHF * this.totalPax;
price.EUR += optionPriceEUR * this.selectedPax;
price.CHF += optionPriceCHF * this.selectedPax;
} else if (3 === option.type) {
price.EUR += optionPriceEUR * this.nightsCount;
price.CHF += optionPriceCHF * this.nightsCount;
} else if (4 === option.type) {
price.EUR += optionPriceEUR * this.nightsCount * this.totalPax;
price.CHF += optionPriceCHF * this.nightsCount * this.totalPax;
price.EUR += optionPriceEUR * this.nightsCount * this.selectedPax;
price.CHF += optionPriceCHF * this.nightsCount * this.selectedPax;
}
}
return price;
@@ -595,8 +530,8 @@ export default {
CHF: 0,
}
if (this.selectedBoard) {
price.EUR = this.selectedBoard.price.EUR * this.nightsCount * this.totalPax;
price.CHF = this.selectedBoard.price.CHF * this.nightsCount * this.totalPax;
price.EUR = this.selectedBoard.price.EUR * this.nightsCount * this.selectedPax;
price.CHF = this.selectedBoard.price.CHF * this.nightsCount * this.selectedPax;
}
return price
},
@@ -619,11 +554,11 @@ export default {
// calculate CHF price when pax price in CHF is available since CHF prices may not be provided via CMS yet
if (0 < this.pricePax.base.CHF) {
CHF = this.nightsCount * this.totalPax * this.runningCostsFactorChf
CHF = this.nightsCount * this.selectedPax * this.runningCostsFactorChf
}
return {
EUR: this.nightsCount * this.totalPax * this.runningCostsFactorEur,
EUR: this.nightsCount * this.selectedPax * this.runningCostsFactorEur,
CHF
}
},
@@ -54,18 +54,6 @@
<th>Anzahl der Personen</th>
<td>{pax -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Anzahl der Personen (ab 15 Jahre)</th>
<td>{paxGroup3 -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Anzahl der Personen (7-14 Jahre)</th>
<td>{paxGroup2 -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Anzahl der Personen (4-6 Jahre)</th>
<td>{paxGroup1 -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Verpflegung</th>
<td>