From 1843a67a001ae3ee7d9f724bad76e9264539b0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Wed, 23 Apr 2025 09:21:12 +0200 Subject: [PATCH] feat: exclude children from price calculation except for running costs closes #8698nak2f --- .../Domain/Model/Dto/GroupsPriceInquiry.php | 21 +++++ .../js/components/GroupsPriceCalculator.vue | 76 ++++++++++++------- .../Private/Templates/Email/GroupsPrice.html | 4 + 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Model/Dto/GroupsPriceInquiry.php b/public/typo3conf/ext/ep_products/Classes/Domain/Model/Dto/GroupsPriceInquiry.php index 99bbfdb7..224f077c 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Model/Dto/GroupsPriceInquiry.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Model/Dto/GroupsPriceInquiry.php @@ -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 */ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/GroupsPriceCalculator.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/GroupsPriceCalculator.vue index e659cadc..1aa19547 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/GroupsPriceCalculator.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/GroupsPriceCalculator.vue @@ -16,20 +16,38 @@ Einzelne Nächte sind nur auf Anfrage buchbar

-
- - -

- Bitte zuerst einen Zeitraum wählen -

+
+ + +

+ Bitte zuerst einen Zeitraum wählen +

+
+
+ + +

+ Bitte zuerst einen Zeitraum wählen +

+
@@ -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 }, diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Email/GroupsPrice.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Email/GroupsPrice.html index 42a07ae4..c72ad853 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Email/GroupsPrice.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Email/GroupsPrice.html @@ -54,6 +54,10 @@ Anzahl der Personen {pax -> v:or(alternative: '-')} + + Anzahl Kinder 0-3 Jahre + {children -> v:or(alternative: '-')} + Verpflegung