From 061781155e82b001048786b43539a9b12224aea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 28 Feb 2025 10:40:58 +0100 Subject: [PATCH] feat: remove age based price groups, format currency in calculator --- .../Domain/Model/Dto/GroupsPriceInquiry.php | 73 +------- .../Domain/Model/GroupsPriceConfig.php | 162 ------------------ ...roducts_domain_model_groupspriceconfig.php | 72 +------- .../js/components/GroupsPriceCalculator.vue | 127 ++++---------- .../Private/Templates/Email/GroupsPrice.html | 12 -- 5 files changed, 38 insertions(+), 408 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 ba0c49dd..5d01060d 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 @@ -1,6 +1,8 @@ pax = $pax; } - /** - * @return string - */ - public function getPaxGroup1() - { - return $this->paxGroup1; - } - - /** - * @param string $paxGroup1 - */ - public function setPaxGroup1($paxGroup1) - { - $this->paxGroup1 = $paxGroup1; - } - - /** - * @return string - */ - public function getPaxGroup2() - { - return $this->paxGroup2; - } - - /** - * @param string $paxGroup2 - */ - public function setPaxGroup2($paxGroup2) - { - $this->paxGroup2 = $paxGroup2; - } - - /** - * @return string - */ - public function getPaxGroup3() - { - return $this->paxGroup3; - } - - /** - * @param string $paxGroup3 - */ - public function setPaxGroup3($paxGroup3) - { - $this->paxGroup3 = $paxGroup3; - } - /** * @return array */ @@ -353,7 +292,7 @@ class GroupsPriceInquiry } /** - * @return \EP\EpProducts\Domain\Model\GroupsPriceBoard + * @return GroupsPriceBoard */ public function getBoard() { @@ -361,9 +300,9 @@ class GroupsPriceInquiry } /** - * @param \EP\EpProducts\Domain\Model\GroupsPriceBoard $board + * @param GroupsPriceBoard $board */ - public function setBoard(\EP\EpProducts\Domain\Model\GroupsPriceBoard $board = null) + public function setBoard(GroupsPriceBoard $board = null) { $this->board = $board; } diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceConfig.php b/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceConfig.php index c6a8488a..dc8a8d0c 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceConfig.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceConfig.php @@ -66,41 +66,6 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable */ protected $priceAdditionalPersonChf; - /** - * @var float - */ - protected $priceAdditionalPersonGroup1; - - /** - * @var float - */ - protected $priceAdditionalPersonGroup1Chf; - - /** - * @var float - */ - protected $priceAdditionalPersonGroup2; - - /** - * @var float - */ - protected $priceAdditionalPersonGroup2Chf; - - /** - * @var float - */ - protected $priceAdditionalPersonGroup3; - - /** - * @var float - */ - protected $priceAdditionalPersonGroup3Chf; - - /** - * @var bool - */ - protected $bonusCardIncluded = false; - /** * @return \DateTime */ @@ -213,118 +178,6 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable $this->priceAdditionalPersonChf = $priceAdditionalPerson; } - /** - * @return float - */ - public function getPriceAdditionalPersonGroup1(): ?float - { - return $this->priceAdditionalPersonGroup1; - } - - /** - * @param float $priceAdditionalPersonGroup1 - */ - public function setPriceAdditionalPersonGroup1(float $priceAdditionalPersonGroup1): void - { - $this->priceAdditionalPersonGroup1 = $priceAdditionalPersonGroup1; - } - - /** - * @return float - */ - public function getPriceAdditionalPersonGroup1Chf(): ?float - { - return $this->priceAdditionalPersonGroup1Chf; - } - - /** - * @param float $priceAdditionalPersonGroup1 - */ - public function setPriceAdditionalPersonGroup1Chf(float $priceAdditionalPersonGroup1): void - { - $this->priceAdditionalPersonGroup1Chf = $priceAdditionalPersonGroup1; - } - - /** - * @return float - */ - public function getPriceAdditionalPersonGroup2(): ?float - { - return $this->priceAdditionalPersonGroup2; - } - - /** - * @param float $priceAdditionalPersonGroup2 - */ - public function setPriceAdditionalPersonGroup2(float $priceAdditionalPersonGroup2): void - { - $this->priceAdditionalPersonGroup2 = $priceAdditionalPersonGroup2; - } - - /** - * @return float - */ - public function getPriceAdditionalPersonGroup2Chf(): ?float - { - return $this->priceAdditionalPersonGroup2Chf; - } - - /** - * @param float $priceAdditionalPersonGroup2 - */ - public function setPriceAdditionalPersonGroup2Chf(float $priceAdditionalPersonGroup2): void - { - $this->priceAdditionalPersonGroup2Chf = $priceAdditionalPersonGroup2; - } - - /** - * @return float - */ - public function getPriceAdditionalPersonGroup3(): ?float - { - return $this->priceAdditionalPersonGroup3; - } - - /** - * @param float $priceAdditionalPersonGroup3 - */ - public function setPriceAdditionalPersonGroup3(float $priceAdditionalPersonGroup3): void - { - $this->priceAdditionalPersonGroup3 = $priceAdditionalPersonGroup3; - } - - /** - * @return float - */ - public function getPriceAdditionalPersonGroup3Chf(): ?float - { - return $this->priceAdditionalPersonGroup3Chf; - } - - /** - * @param float $priceAdditionalPersonGroup3 - */ - public function setPriceAdditionalPersonGroup3Chf(float $priceAdditionalPersonGroup3): void - { - $this->priceAdditionalPersonGroup3Chf = $priceAdditionalPersonGroup3; - } - - /** - * @return bool - */ - public function isBonusCardIncluded(): bool - { - return $this->bonusCardIncluded; - } - - /** - * @param bool $bonusCardIncluded - */ - public function setBonusCardIncluded(bool $bonusCardIncluded): void - { - $this->bonusCardIncluded = $bonusCardIncluded; - } - /** * @return array */ @@ -343,21 +196,6 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable 'EUR' => $this->getPriceAdditionalPerson(), 'CHF' => $this->getPriceAdditionalPersonChf(), ], - 'priceAdditionalPersonByGroup' => [ - 1 => [ - 'EUR' => $this->getPriceAdditionalPersonGroup1(), - 'CHF' => $this->getPriceAdditionalPersonGroup1Chf(), - ], - 2 => [ - 'EUR' => $this->getPriceAdditionalPersonGroup2(), - 'CHF' => $this->getPriceAdditionalPersonGroup2Chf(), - ], - 3 => [ - 'EUR' => $this->getPriceAdditionalPersonGroup3(), - 'CHF' => $this->getPriceAdditionalPersonGroup3Chf(), - ], - ], - 'bonusCardIncluded' => $this->isBonusCardIncluded(), ]; } } diff --git a/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceconfig.php b/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceconfig.php index a7b78049..68328b08 100644 --- a/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceconfig.php +++ b/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceconfig.php @@ -30,11 +30,8 @@ return [ ], 'palettes' => [ 'dates' => ['showitem' => 'date_from, date_to'], - 'included' => ['showitem' => 'bonus_card_included, persons_included'], + 'included' => ['showitem' => 'persons_included'], 'prices' => ['showitem' => 'price, price_chf, price_additional_person, price_additional_person_chf'], - 'prices_groups' => ['showitem' => 'price_additional_person_group_1, price_additional_person_group_1_chf, - --linebreak--, price_additional_person_group_2, price_additional_person_group_2_chf, - --linebreak--, price_additional_person_group_3, price_additional_person_group_3_chf'], ], 'columns' => [ @@ -186,72 +183,5 @@ return [ 'eval' => 'double2', ] ], - 'price_additional_person_group_1' => [ - 'exclude' => false, - 'label' => 'Preis weitere Person', - 'description' => 'mit Jokercard, 4-6 Jahre', - 'config' => [ - 'type' => 'input', - 'size' => 8, - 'eval' => 'double2', - ] - ], - 'price_additional_person_group_1_chf' => [ - 'exclude' => false, - 'label' => 'Preis weitere Person in CHF', - 'description' => 'mit Jokercard, 4-6 Jahre', - 'config' => [ - 'type' => 'input', - 'size' => 8, - 'eval' => 'double2', - ] - ], - 'price_additional_person_group_2' => [ - 'exclude' => false, - 'label' => 'Preis weitere Person', - 'description' => 'mit Jokercard, 7-14 Jahre', - 'config' => [ - 'type' => 'input', - 'size' => 8, - 'eval' => 'double2', - ] - ], - 'price_additional_person_group_2_chf' => [ - 'exclude' => false, - 'label' => 'Preis weitere Person in CHF', - 'description' => 'mit Jokercard, 7-14 Jahre', - 'config' => [ - 'type' => 'input', - 'size' => 8, - 'eval' => 'double2', - ] - ], - 'price_additional_person_group_3' => [ - 'exclude' => false, - 'label' => 'Preis weitere Person', - 'description' => 'mit Jokercard, ab 15 Jahre', - 'config' => [ - 'type' => 'input', - 'size' => 8, - 'eval' => 'double2', - ] - ], - 'price_additional_person_group_3_chf' => [ - 'exclude' => false, - 'label' => 'Preis weitere Person in CHF', - 'description' => 'mit Jokercard, ab 15 Jahre', - 'config' => [ - 'type' => 'input', - 'size' => 8, - 'eval' => 'double2', - ] - ], - 'bonus_card_included' => [ - 'exclude' => 0, - 'label' => 'Jokercard inklusive', - 'config' => [ - 'type' => 'check', - ], - ], ], ]; 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 802586a6..2a9aee95 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 @@ -25,30 +25,7 @@ class="form-field" v-model.number="selectedPax" @change="onPaxUpdated()" - v-show="nightsCount > 0 && !includesBonusCard"/> -
-
- ab 15 Jahre - -
-
- 7-14 Jahre - -
-
- 4-6 Jahre - -
-
+ v-show="nightsCount > 0"/>

Bitte zuerst einen Zeitraum wählen @@ -78,7 +55,7 @@ -

+
Erst ab 30 Personen buchbar.
@@ -115,15 +92,6 @@ Aufpreis Kurzzeit {{ formatCurrency(priceShortTerm) }} - - Inklusivleistungen - - - Joker Card - - - Zusatzleistungen @@ -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 } }, 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 318faf3c..89960989 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,18 +54,6 @@ Anzahl der Personen {pax -> v:or(alternative: '-')} - - Anzahl der Personen (ab 15 Jahre) - {paxGroup3 -> v:or(alternative: '-')} - - - Anzahl der Personen (7-14 Jahre) - {paxGroup2 -> v:or(alternative: '-')} - - - Anzahl der Personen (4-6 Jahre) - {paxGroup1 -> v:or(alternative: '-')} - Verpflegung