feat: exclude children from price calculation except for running costs

closes #8698nak2f
This commit is contained in:
Björn Fromme
2025-04-23 09:21:12 +02:00
parent fbf3a5170d
commit 1843a67a00
3 changed files with 75 additions and 26 deletions
@@ -97,6 +97,11 @@ class GroupsPriceInquiry
*/
protected $pax;
/**
* @var string
*/
protected $children;
/**
* @var array
*/
@@ -297,6 +302,22 @@ class GroupsPriceInquiry
$this->pax = $pax;
}
/**
* @return string
*/
public function getChildren()
{
return $this->children;
}
/**
* @param string $pax
*/
public function setChildren($children)
{
$this->children = $children;
}
/**
* @return array
*/
@@ -16,20 +16,38 @@
Einzelne Nächte sind nur auf Anfrage buchbar
</p>
</div>
<div class="mb-8"
<div class="mb-8 grid sm:grid-cols-2 gap-8"
v-show="!submitted">
<label class="mb-2 font-bold">
Personenzahl
</label>
<input type="number"
class="form-field"
v-model.number="selectedPax"
@change="onPaxUpdated()"
v-show="nightsCount > 0"/>
<p class="text-sm italic"
v-show="nightsCount === 0">
Bitte zuerst einen Zeitraum wählen
</p>
<div>
<label class="mb-2 font-bold">
Personenzahl
</label>
<input type="number"
class="form-field"
min="30"
v-model.number="selectedPax"
@change="onPaxUpdated()"
v-show="nightsCount > 0"/>
<p class="text-sm italic"
v-show="nightsCount === 0">
Bitte zuerst einen Zeitraum wählen
</p>
</div>
<div>
<label class="mb-2 font-bold">
davon Kinder 0-3 Jahre
</label>
<input type="number"
class="form-field"
min="0"
v-model.number="childrenCount"
@change="onPaxUpdated()"
v-show="nightsCount > 0"/>
<p class="text-sm italic"
v-show="nightsCount === 0">
Bitte zuerst einen Zeitraum wählen
</p>
</div>
</div>
<div class="mb-8"
v-show="options.length > 0 && !submitted">
@@ -350,6 +368,7 @@ export default {
selectedTo: null,
selectedRange: [],
selectedPax: 30,
childrenCount: 0,
selectedOptions: [],
selectedBoard: null,
name: null,
@@ -393,14 +412,14 @@ export default {
price.EUR = optionPriceEUR;
price.CHF = optionPriceCHF;
} else if (2 === option.type) {
price.EUR = optionPriceEUR * this.selectedPax;
price.CHF = optionPriceCHF * this.selectedPax;
price.EUR = optionPriceEUR * this.paxCount;
price.CHF = optionPriceCHF * this.paxCount;
} 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.selectedPax;
price.CHF = optionPriceCHF * this.nightsCount * this.selectedPax;
price.EUR = optionPriceEUR * this.nightsCount * this.paxCount;
price.CHF = optionPriceCHF * this.nightsCount * this.paxCount;
}
return price;
},
@@ -462,6 +481,7 @@ export default {
'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.selectedPax,
'tx_epproducts_ajax[groupsPriceInquiry][children]': this.childrenCount,
'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),
@@ -498,6 +518,10 @@ export default {
},
},
computed: {
paxCount() {
// subtract number of children from pax for price calculation, but minimum 30 pax
return Math.max(this.selectedPax - this.childrenCount, 30)
},
nightsCount() {
return this.selectedRange.length;
},
@@ -530,7 +554,7 @@ export default {
base.EUR += config.price.EUR
base.CHF += config.price.CHF
let included = config.personsIncluded
let additionalPax = this.selectedPax - included
let additionalPax = this.paxCount - included
if (this.selectedPax > included) {
additional.EUR += additionalPax * config.priceAdditionalPerson.EUR
additional.CHF += additionalPax * config.priceAdditionalPerson.CHF
@@ -538,12 +562,12 @@ export default {
}
}
}
if (this.selectedBoard && this.selectedPax < 40) {
undersubscription.EUR = this.selectedPax * this.undersubscription30Eur * this.selectedRange.length
undersubscription.CHF = this.selectedPax * this.undersubscription30Chf * this.selectedRange.length
} else if (this.selectedBoard && this.selectedPax < 50) {
undersubscription.EUR = this.selectedPax * this.undersubscription40Eur * this.selectedRange.length
undersubscription.CHF = this.selectedPax * this.undersubscription40Chf * this.selectedRange.length
if (this.selectedBoard && this.paxCount < 40) {
undersubscription.EUR = this.paxCount * this.undersubscription30Eur * this.selectedRange.length
undersubscription.CHF = this.paxCount * this.undersubscription30Chf * this.selectedRange.length
} else if (this.selectedBoard && this.paxCount < 50) {
undersubscription.EUR = this.paxCount * this.undersubscription40Eur * this.selectedRange.length
undersubscription.CHF = this.paxCount * this.undersubscription40Chf * this.selectedRange.length
}
return {base, additional, undersubscription}
@@ -566,8 +590,8 @@ export default {
CHF: 0,
}
if (this.selectedBoard) {
price.EUR = this.selectedBoard.price.EUR * this.nightsCount * this.selectedPax;
price.CHF = this.selectedBoard.price.CHF * this.nightsCount * this.selectedPax;
price.EUR = this.selectedBoard.price.EUR * this.nightsCount * this.paxCount;
price.CHF = this.selectedBoard.price.CHF * this.nightsCount * this.paxCount;
}
return price
},
@@ -54,6 +54,10 @@
<th>Anzahl der Personen</th>
<td>{pax -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Anzahl Kinder 0-3 Jahre</th>
<td>{children -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Verpflegung</th>
<td>