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; protected $pax;
/**
* @var string
*/
protected $children;
/** /**
* @var array * @var array
*/ */
@@ -297,6 +302,22 @@ class GroupsPriceInquiry
$this->pax = $pax; $this->pax = $pax;
} }
/**
* @return string
*/
public function getChildren()
{
return $this->children;
}
/**
* @param string $pax
*/
public function setChildren($children)
{
$this->children = $children;
}
/** /**
* @return array * @return array
*/ */
@@ -16,20 +16,38 @@
Einzelne Nächte sind nur auf Anfrage buchbar Einzelne Nächte sind nur auf Anfrage buchbar
</p> </p>
</div> </div>
<div class="mb-8" <div class="mb-8 grid sm:grid-cols-2 gap-8"
v-show="!submitted"> v-show="!submitted">
<label class="mb-2 font-bold"> <div>
Personenzahl <label class="mb-2 font-bold">
</label> Personenzahl
<input type="number" </label>
class="form-field" <input type="number"
v-model.number="selectedPax" class="form-field"
@change="onPaxUpdated()" min="30"
v-show="nightsCount > 0"/> v-model.number="selectedPax"
<p class="text-sm italic" @change="onPaxUpdated()"
v-show="nightsCount === 0"> v-show="nightsCount > 0"/>
Bitte zuerst einen Zeitraum wählen <p class="text-sm italic"
</p> 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>
<div class="mb-8" <div class="mb-8"
v-show="options.length > 0 && !submitted"> v-show="options.length > 0 && !submitted">
@@ -350,6 +368,7 @@ export default {
selectedTo: null, selectedTo: null,
selectedRange: [], selectedRange: [],
selectedPax: 30, selectedPax: 30,
childrenCount: 0,
selectedOptions: [], selectedOptions: [],
selectedBoard: null, selectedBoard: null,
name: null, name: null,
@@ -393,14 +412,14 @@ export default {
price.EUR = optionPriceEUR; price.EUR = optionPriceEUR;
price.CHF = optionPriceCHF; price.CHF = optionPriceCHF;
} else if (2 === option.type) { } else if (2 === option.type) {
price.EUR = optionPriceEUR * this.selectedPax; price.EUR = optionPriceEUR * this.paxCount;
price.CHF = optionPriceCHF * this.selectedPax; price.CHF = optionPriceCHF * this.paxCount;
} else if (3 === option.type) { } else if (3 === option.type) {
price.EUR = optionPriceEUR * this.nightsCount; price.EUR = optionPriceEUR * this.nightsCount;
price.CHF = optionPriceCHF * this.nightsCount; price.CHF = optionPriceCHF * this.nightsCount;
} else if (4 === option.type) { } else if (4 === option.type) {
price.EUR = optionPriceEUR * this.nightsCount * this.selectedPax; price.EUR = optionPriceEUR * this.nightsCount * this.paxCount;
price.CHF = optionPriceCHF * this.nightsCount * this.selectedPax; price.CHF = optionPriceCHF * this.nightsCount * this.paxCount;
} }
return price; return price;
}, },
@@ -462,6 +481,7 @@ export default {
'tx_epproducts_ajax[groupsPriceInquiry][dateFrom]': this.selectedFrom.format('DD.MM.YYYY'), '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][dateTo]': this.selectedTo.format('DD.MM.YYYY'),
'tx_epproducts_ajax[groupsPriceInquiry][pax]': this.selectedPax, '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][paxBase]': this.formatCurrency(this.pricePax.base),
'tx_epproducts_ajax[groupsPriceInquiry][summary][paxAdditional]': this.formatCurrency(this.pricePax.additional), 'tx_epproducts_ajax[groupsPriceInquiry][summary][paxAdditional]': this.formatCurrency(this.pricePax.additional),
'tx_epproducts_ajax[groupsPriceInquiry][summary][undersubscription]': this.formatCurrency(this.pricePax.undersubscription), 'tx_epproducts_ajax[groupsPriceInquiry][summary][undersubscription]': this.formatCurrency(this.pricePax.undersubscription),
@@ -498,6 +518,10 @@ export default {
}, },
}, },
computed: { computed: {
paxCount() {
// subtract number of children from pax for price calculation, but minimum 30 pax
return Math.max(this.selectedPax - this.childrenCount, 30)
},
nightsCount() { nightsCount() {
return this.selectedRange.length; return this.selectedRange.length;
}, },
@@ -530,7 +554,7 @@ export default {
base.EUR += config.price.EUR base.EUR += config.price.EUR
base.CHF += config.price.CHF base.CHF += config.price.CHF
let included = config.personsIncluded let included = config.personsIncluded
let additionalPax = this.selectedPax - included let additionalPax = this.paxCount - included
if (this.selectedPax > included) { if (this.selectedPax > included) {
additional.EUR += additionalPax * config.priceAdditionalPerson.EUR additional.EUR += additionalPax * config.priceAdditionalPerson.EUR
additional.CHF += additionalPax * config.priceAdditionalPerson.CHF additional.CHF += additionalPax * config.priceAdditionalPerson.CHF
@@ -538,12 +562,12 @@ export default {
} }
} }
} }
if (this.selectedBoard && this.selectedPax < 40) { if (this.selectedBoard && this.paxCount < 40) {
undersubscription.EUR = this.selectedPax * this.undersubscription30Eur * this.selectedRange.length undersubscription.EUR = this.paxCount * this.undersubscription30Eur * this.selectedRange.length
undersubscription.CHF = this.selectedPax * this.undersubscription30Chf * this.selectedRange.length undersubscription.CHF = this.paxCount * this.undersubscription30Chf * this.selectedRange.length
} else if (this.selectedBoard && this.selectedPax < 50) { } else if (this.selectedBoard && this.paxCount < 50) {
undersubscription.EUR = this.selectedPax * this.undersubscription40Eur * this.selectedRange.length undersubscription.EUR = this.paxCount * this.undersubscription40Eur * this.selectedRange.length
undersubscription.CHF = this.selectedPax * this.undersubscription40Chf * this.selectedRange.length undersubscription.CHF = this.paxCount * this.undersubscription40Chf * this.selectedRange.length
} }
return {base, additional, undersubscription} return {base, additional, undersubscription}
@@ -566,8 +590,8 @@ export default {
CHF: 0, CHF: 0,
} }
if (this.selectedBoard) { if (this.selectedBoard) {
price.EUR = this.selectedBoard.price.EUR * this.nightsCount * this.selectedPax; price.EUR = this.selectedBoard.price.EUR * this.nightsCount * this.paxCount;
price.CHF = this.selectedBoard.price.CHF * this.nightsCount * this.selectedPax; price.CHF = this.selectedBoard.price.CHF * this.nightsCount * this.paxCount;
} }
return price return price
}, },
@@ -54,6 +54,10 @@
<th>Anzahl der Personen</th> <th>Anzahl der Personen</th>
<td>{pax -> v:or(alternative: '-')}</td> <td>{pax -> v:or(alternative: '-')}</td>
</tr> </tr>
<tr>
<th>Anzahl Kinder 0-3 Jahre</th>
<td>{children -> v:or(alternative: '-')}</td>
</tr>
<tr> <tr>
<th>Verpflegung</th> <th>Verpflegung</th>
<td> <td>