From 1bd61e88072fdaaf3029418d1ff69a2f1ad3fab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Wed, 12 Feb 2025 09:24:42 +0100 Subject: [PATCH] feat: additional currency CHF in price calculator for Swiss hotels closes #8697b8j20 --- .../Controller/GroupsPriceController.php | 6 +- .../Classes/Domain/Model/GroupsPriceBoard.php | 30 ++- .../Domain/Model/GroupsPriceConfig.php | 132 ++++++++++++- .../Domain/Model/GroupsPriceOption.php | 28 ++- .../flexform_groups_price_calculator.xml | 41 +++- ...products_domain_model_groupspriceboard.php | 11 +- ...roducts_domain_model_groupspriceconfig.php | 56 +++++- ...roducts_domain_model_groupspriceoption.php | 11 +- .../typo3conf/ext/ep_products/ext_tables.sql | 69 ++++--- .../js/components/GroupsPriceCalculator.vue | 176 ++++++++++++------ .../Private/Templates/GroupsPrice/Index.html | 6 +- 11 files changed, 457 insertions(+), 109 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/GroupsPriceController.php b/public/typo3conf/ext/ep_products/Classes/Controller/GroupsPriceController.php index c3213fe0..783f3266 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/GroupsPriceController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/GroupsPriceController.php @@ -41,7 +41,11 @@ class GroupsPriceController extends ActionController }); $this->view->assign('hotel', $hotel); - $this->view->assign('runningCosts', $this->settings['runningCosts']); + $this->view->assign('runningCostsEUR', $this->settings['runningCostsEUR']); + $this->view->assign('runningCostsCHF', $this->settings['runningCostsCHF']); + $this->view->assign('undersubscriptionEUR', $this->settings['undersubscriptionEUR']); + $this->view->assign('undersubscriptionCHF', $this->settings['undersubscriptionCHF']); + $this->view->assign('countryCode', $hotel->getCountry()->getCode()); $this->view->assign('configs', json_encode(array_values($configs), JSON_HEX_APOS)); $this->view->assign('boards', json_encode($hotel->getGroupsPriceBoards()->toArray(), JSON_HEX_APOS)); $this->view->assign('options', json_encode($hotel->getGroupsPriceOptions()->toArray(), JSON_HEX_APOS)); diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceBoard.php b/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceBoard.php index 97e67129..f05e0bb0 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceBoard.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceBoard.php @@ -41,6 +41,11 @@ class GroupsPriceBoard extends AbstractEntity implements \JsonSerializable */ protected $price; + /** + * @var float + */ + protected $priceChf; + /** * @return string */ @@ -73,15 +78,34 @@ class GroupsPriceBoard extends AbstractEntity implements \JsonSerializable $this->price = $price; } + /** + * @return float + */ + public function getPriceChf(): ?float + { + return $this->priceChf; + } + + /** + * @param float $price + */ + public function setPriceChf(float $price): void + { + $this->priceChf = $price; + } + /** * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'uid' => $this->getUid(), 'title' => $this->getTitle(), - 'price' => $this->getPrice(), + 'price' => [ + 'EUR' => $this->getPrice(), + 'CHF' => $this->getPriceChf(), + ], ]; } -} \ No newline at end of file +} 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 4f9cd902..c6a8488a 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceConfig.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceConfig.php @@ -51,26 +51,51 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable */ protected $price; + /** + * @var float + */ + protected $priceChf; + /** * @var float */ protected $priceAdditionalPerson; + /** + * @var float + */ + 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 */ @@ -140,6 +165,22 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable $this->price = $price; } + /** + * @return float + */ + public function getPriceChf(): ?float + { + return $this->priceChf; + } + + /** + * @param float $price + */ + public function setPriceChf(float $price): void + { + $this->priceChf = $price; + } + /** * @return float */ @@ -156,6 +197,22 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable $this->priceAdditionalPerson = $priceAdditionalPerson; } + /** + * @return float + */ + public function getPriceAdditionalPersonChf(): ?float + { + return $this->priceAdditionalPersonChf; + } + + /** + * @param float $priceAdditionalPerson + */ + public function setPriceAdditionalPersonChf(float $priceAdditionalPerson): void + { + $this->priceAdditionalPersonChf = $priceAdditionalPerson; + } + /** * @return float */ @@ -172,6 +229,22 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable $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 */ @@ -188,6 +261,22 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable $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 */ @@ -204,6 +293,22 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable $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 */ @@ -223,19 +328,34 @@ class GroupsPriceConfig extends AbstractEntity implements \JsonSerializable /** * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'uid' => $this->getUid(), 'dateFrom' => $this->getDateFrom()->format('Y-m-d'), 'dateTo' => $this->getDateTo()->format('Y-m-d'), 'personsIncluded' => $this->getPersonsIncluded(), - 'price' => $this->getPrice(), - 'priceAdditionalPerson' => $this->getPriceAdditionalPerson(), + 'price' => [ + 'EUR' => $this->getPrice(), + 'CHF' => $this->getPriceChf(), + ], + 'priceAdditionalPerson' => [ + 'EUR' => $this->getPriceAdditionalPerson(), + 'CHF' => $this->getPriceAdditionalPersonChf(), + ], 'priceAdditionalPersonByGroup' => [ - 1 => $this->getPriceAdditionalPersonGroup1(), - 2 => $this->getPriceAdditionalPersonGroup2(), - 3 => $this->getPriceAdditionalPersonGroup3(), + 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/Classes/Domain/Model/GroupsPriceOption.php b/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceOption.php index 36cc4e4e..d61da7d3 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceOption.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Model/GroupsPriceOption.php @@ -46,6 +46,11 @@ class GroupsPriceOption extends AbstractEntity implements \JsonSerializable */ protected $price; + /** + * @var float + */ + protected $priceChf; + /** * @var int */ @@ -88,6 +93,22 @@ class GroupsPriceOption extends AbstractEntity implements \JsonSerializable $this->price = $price; } + /** + * @return float + */ + public function getPriceChf(): ?float + { + return $this->priceChf; + } + + /** + * @param float $price + */ + public function setPriceChf(float $price): void + { + $this->priceChf = $price; + } + /** * @return int */ @@ -123,12 +144,15 @@ class GroupsPriceOption extends AbstractEntity implements \JsonSerializable /** * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'uid' => $this->getUid(), 'title' => $this->getTitle(), - 'price' => $this->getPrice(), + 'price' => [ + 'EUR' => $this->getPrice(), + 'CHF' => $this->getPriceChf(), + ], 'type' => $this->getType(), 'ignoreWithBoard' => $this->isIgnoreWithBoard(), ]; diff --git a/public/typo3conf/ext/ep_products/Configuration/FlexForms/flexform_groups_price_calculator.xml b/public/typo3conf/ext/ep_products/Configuration/FlexForms/flexform_groups_price_calculator.xml index 9e172992..67cb1a72 100644 --- a/public/typo3conf/ext/ep_products/Configuration/FlexForms/flexform_groups_price_calculator.xml +++ b/public/typo3conf/ext/ep_products/Configuration/FlexForms/flexform_groups_price_calculator.xml @@ -10,17 +10,50 @@ array - + 0 - + input - 1.7 + 2.5 double2,required - + + + + 0 + + + input + 2.9 + double2,required + + + + + + 0 + + + input + 5.0 + double2,required + + + + + + 0 + + + input + 5.0 + double2,required + + + diff --git a/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceboard.php b/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceboard.php index f79aaa7e..8a72f8c9 100644 --- a/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceboard.php +++ b/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceboard.php @@ -25,7 +25,7 @@ return [ ], 'types' => [ '1' => [ - 'showitem' => 'title, price', + 'showitem' => 'title, price, price_chf', ], ], 'palettes' => [ @@ -130,6 +130,15 @@ return [ 'eval' => 'double2,required', ] ], + 'price_chf' => [ + 'exclude' => false, + 'label' => 'Preis pro Person/Nacht in CHF', + 'config' => [ + 'type' => 'input', + 'size' => 8, + 'eval' => 'double2', + ] + ], 'sorting' => [ 'config' => [ 'type' => 'passthrough' 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 b91879e4..51f8ae6f 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 @@ -31,9 +31,10 @@ return [ 'palettes' => [ 'dates' => ['showitem' => 'date_from, date_to'], 'included' => ['showitem' => 'bonus_card_included, persons_included'], - 'prices' => ['showitem' => 'price, price_additional_person'], - 'prices_groups' => ['showitem' => 'price_additional_person_group_1, price_additional_person_group_2, - --linebreak--, price_additional_person_group_3'], + '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' => [ @@ -156,6 +157,15 @@ return [ 'eval' => 'double2,required', ] ], + 'price_chf' => [ + 'exclude' => false, + 'label' => 'Preis pro Nacht in CHF', + 'config' => [ + 'type' => 'input', + 'size' => 8, + 'eval' => 'double2', + ] + ], 'price_additional_person' => [ 'exclude' => false, 'label' => 'Preis weitere Person', @@ -166,6 +176,16 @@ return [ 'eval' => 'double2', ] ], + 'price_additional_person_chf' => [ + 'exclude' => false, + 'label' => 'Preis weitere Person', + 'description' => 'ohne Jokercard, alle Altersgruppen', + 'config' => [ + 'type' => 'input', + 'size' => 8, + 'eval' => 'double2', + ] + ], 'price_additional_person_group_1' => [ 'exclude' => false, 'label' => 'Preis weitere Person', @@ -176,6 +196,16 @@ return [ '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', @@ -186,6 +216,16 @@ return [ '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', @@ -196,6 +236,16 @@ return [ 'eval' => 'double2', ] ], + 'price_additional_person_group_3_chf' => [ + 'exclude' => false, + 'label' => 'Preis weitere Person', + 'description' => 'mit Jokercard, ab 15 Jahre', + 'config' => [ + 'type' => 'input', + 'size' => 8, + 'eval' => 'double2', + ] + ], 'bonus_card_included' => [ 'exclude' => 0, 'label' => 'Jokercard inklusive', diff --git a/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceoption.php b/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceoption.php index 148f654a..d00dee5e 100644 --- a/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceoption.php +++ b/public/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_groupspriceoption.php @@ -29,7 +29,7 @@ return [ ], ], 'palettes' => [ - 'priceconfig' => ['showitem' => 'price, type, ignore_with_board'], + 'priceconfig' => ['showitem' => 'price, price_chf, type, ignore_with_board'], ], 'columns' => [ @@ -131,6 +131,15 @@ return [ 'eval' => 'double2,required', ] ], + 'price_chf' => [ + 'exclude' => false, + 'label' => 'Preis in CHF', + 'config' => [ + 'type' => 'input', + 'size' => 8, + 'eval' => 'double2', + ] + ], 'type' => [ 'exclude' => false, 'label' => 'Typ', diff --git a/public/typo3conf/ext/ep_products/ext_tables.sql b/public/typo3conf/ext/ep_products/ext_tables.sql index e2e5a020..bc2fe07e 100644 --- a/public/typo3conf/ext/ep_products/ext_tables.sql +++ b/public/typo3conf/ext/ep_products/ext_tables.sql @@ -289,41 +289,46 @@ CREATE TABLE tx_epproducts_domain_model_hotel CREATE TABLE tx_epproducts_domain_model_groupspriceconfig ( - uid int(11) NOT NULL auto_increment, - pid int(11) DEFAULT '0' NOT NULL, + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, - date_from int(11) unsigned DEFAULT '0' NOT NULL, - date_to int(11) unsigned DEFAULT '0' NOT NULL, - persons_included int(11) unsigned DEFAULT '0' NOT NULL, - price float(8) unsigned DEFAULT '0' NOT NULL, - price_additional_person float(8) unsigned DEFAULT '0' NOT NULL, - price_additional_person_group_1 float(8) unsigned DEFAULT '0' NOT NULL, - price_additional_person_group_2 float(8) unsigned DEFAULT '0' NOT NULL, - price_additional_person_group_3 float(8) unsigned DEFAULT '0' NOT NULL, - bonus_card_included tinyint(4) unsigned DEFAULT '0' NOT NULL, - hotel int(11) unsigned DEFAULT '0', + date_from int(11) unsigned DEFAULT '0' NOT NULL, + date_to int(11) unsigned DEFAULT '0' NOT NULL, + persons_included int(11) unsigned DEFAULT '0' NOT NULL, + price float(8) unsigned DEFAULT '0' NOT NULL, + price_chf float(8) unsigned DEFAULT '0' NOT NULL, + price_additional_person float(8) unsigned DEFAULT '0' NOT NULL, + price_additional_person_chf float(8) unsigned DEFAULT '0' NOT NULL, + price_additional_person_group_1 float(8) unsigned DEFAULT '0' NOT NULL, + price_additional_person_group_1_chf float(8) unsigned DEFAULT '0' NOT NULL, + price_additional_person_group_2 float(8) unsigned DEFAULT '0' NOT NULL, + price_additional_person_group_2_chf float(8) unsigned DEFAULT '0' NOT NULL, + price_additional_person_group_3 float(8) unsigned DEFAULT '0' NOT NULL, + price_additional_person_group_3_chf float(8) unsigned DEFAULT '0' NOT NULL, + bonus_card_included tinyint(4) unsigned DEFAULT '0' NOT NULL, + hotel int(11) unsigned DEFAULT '0', - tstamp int(11) unsigned DEFAULT '0' NOT NULL, - crdate int(11) unsigned DEFAULT '0' NOT NULL, - cruser_id int(11) unsigned DEFAULT '0' NOT NULL, - deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, - hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, - starttime int(11) unsigned DEFAULT '0' NOT NULL, - endtime int(11) unsigned DEFAULT '0' NOT NULL, + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + starttime int(11) unsigned DEFAULT '0' NOT NULL, + endtime int(11) unsigned DEFAULT '0' NOT NULL, - t3ver_oid int(11) DEFAULT '0' NOT NULL, - t3ver_id int(11) DEFAULT '0' NOT NULL, - t3ver_wsid int(11) DEFAULT '0' NOT NULL, - t3ver_label varchar(255) DEFAULT '' NOT NULL, - t3ver_state tinyint(4) DEFAULT '0' NOT NULL, - t3ver_stage int(11) DEFAULT '0' NOT NULL, - t3ver_count int(11) DEFAULT '0' NOT NULL, - t3ver_tstamp int(11) DEFAULT '0' NOT NULL, - t3ver_move_id int(11) DEFAULT '0' NOT NULL, + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, - sys_language_uid int(11) DEFAULT '0' NOT NULL, - l10n_parent int(11) DEFAULT '0' NOT NULL, - l10n_diffsource mediumblob, + sys_language_uid int(11) DEFAULT '0' NOT NULL, + l10n_parent int(11) DEFAULT '0' NOT NULL, + l10n_diffsource mediumblob, PRIMARY KEY (uid), KEY parent (pid), @@ -343,6 +348,7 @@ CREATE TABLE tx_epproducts_domain_model_groupspriceoption title varchar(255) DEFAULT '' NOT NULL, price float(8) unsigned DEFAULT '0' NOT NULL, + price_chf float(8) unsigned DEFAULT '0' NOT NULL, type tinyint(4) unsigned DEFAULT '0' NOT NULL, ignore_with_board tinyint(4) unsigned DEFAULT '0' NOT NULL, hotel int(11) unsigned DEFAULT '0', @@ -388,6 +394,7 @@ CREATE TABLE tx_epproducts_domain_model_groupspriceboard title varchar(255) DEFAULT '' NOT NULL, price float(8) unsigned DEFAULT '0' NOT NULL, + price_chf float(8) unsigned DEFAULT '0' NOT NULL, hotel int(11) unsigned DEFAULT '0', sorting int(11) DEFAULT '0' NOT NULL, 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 c9597eef..384d0e68 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 @@ -103,12 +103,12 @@ {{ formatCurrency(pricePax.base) }} + v-if="pricePax.additional.EUR > 0"> Aufpreis Personenzahl {{ formatCurrency(pricePax.additional) }} + v-if="priceShortTerm.EUR > 0"> Aufpreis Kurzzeit {{ formatCurrency(priceShortTerm) }} @@ -127,17 +127,17 @@ {{ formatCurrency(priceOptions) }} + v-if="priceBoard.EUR > 0"> Verpflegung {{ formatCurrency(priceBoard) }} + v-if="pricePax.undersubscription.EUR > 0"> Kleingruppen-Verpflegungszuschlag {{ formatCurrency(pricePax.undersubscription) }} + v-if="priceRunningCosts.EUR > 0"> Strom- und Abfallgebühren {{ formatCurrency(priceRunningCosts) }} @@ -286,9 +286,25 @@ export default { type: String, required: true }, - runningCostsFactor: { + runningCostsFactorEur: { type: Number, - default: 1.7, + default: 2.5, + }, + runningCostsFactorChf: { + type: Number, + default: 2.9, + }, + undersubscriptionEur: { + type: Number, + default: 5.0, + }, + undersubscriptionChf: { + type: Number, + default: 5.0, + }, + countryCode: { + type: String, + required: true }, shortTermFactors: { type: Array, @@ -323,28 +339,33 @@ export default { email: null, phone: null, remarks: null, + group: null, + address: null, mode: 'inquiry', } }, methods: { - formatCurrency(value) { - if (0 === value) { - return '-'; + formatCurrency({ EUR, CHF }) { + let price = parseFloat(EUR).toFixed(2).replace(/\./, ',') + ' €' + + if ('CH' === this.countryCode && null !== CHF) { + price += `/${parseFloat(CHF).toFixed(2).replace(/\./, ',')} CHF` } - return parseFloat(value).toFixed(2).replace(/\./, ',') + ' €'; + + return price }, formatOptionPriceType(option) { if (2 === option.type) { - return ' (' + this.formatCurrency(option.price) + ' pro Person)'; + return ` (${this.formatCurrency(option.price)} pro Person)` } if (3 === option.type) { - return ' (' + this.formatCurrency(option.price) + ' pro Nacht)'; + return ` (${this.formatCurrency(option.price)} pro Nacht)` } if (4 === option.type) { - return ' (' + this.formatCurrency(option.price) + ' pro Person und Nacht)'; + return ` (${this.formatCurrency(option.price)} pro Person und Nacht)` } - return ' (' + this.formatCurrency(option.price) + ')'; + return ` (${this.formatCurrency(option.price)})` }, initSelectableRanges() { let enabledDates = []; @@ -425,7 +446,7 @@ export default { .finally(() => { this.processing = false }) - } + }, }, computed: { nightsCount() { @@ -455,33 +476,47 @@ export default { return included }, pricePax() { - let base = 0 - let additional = 0 - let undersubscription = 0 + let base = { + EUR: 0, + CHF: 0, + } + let additional = { + EUR: 0, + CHF: 0, + } + let undersubscription = { + EUR: 0, + CHF: 0, + } for (let date of this.selectedRange) { for (let config of this.configs) { if (date >= dayjs(config.dateFrom) && date < dayjs(config.dateTo)) { - base += config.price + base.EUR += config.price.EUR + base.CHF += config.price.CHF if (this.totalPax > config.personsIncluded) { if (false === config.bonusCardIncluded) { - additional += (this.selectedPax - config.personsIncluded) * config.priceAdditionalPerson; + 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 += (this.selectedPaxGroup3 - included) * config.priceAdditionalPersonByGroup[3] + 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 += (this.selectedPaxGroup2 - included) * config.priceAdditionalPersonByGroup[2] + 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 += (this.selectedPaxGroup1 - included) * config.priceAdditionalPersonByGroup[1] + additional.EUR += (this.selectedPaxGroup1 - included) * config.priceAdditionalPersonByGroup[1].EUR + additional.CHF += (this.selectedPaxGroup1 - included) * config.priceAdditionalPersonByGroupCHF[1].CHF } } } @@ -489,66 +524,95 @@ export default { } } if (this.selectedBoard && this.totalPax < 50) { - undersubscription = this.totalPax * 5 * this.selectedRange.length + undersubscription.EUR = this.totalPax * this.undersubscriptionEur * this.selectedRange.length + undersubscription.CHF = this.totalPax * this.undersubscriptionChf * this.selectedRange.length } - return {base, additional, undersubscription}; + + return {base, additional, undersubscription} }, totalPax() { - return this.includesBonusCard ? this.selectedPaxGroup1 + this.selectedPaxGroup2 + this.selectedPaxGroup3 : this.selectedPax + return this.includesBonusCard ? + this.selectedPaxGroup1 + this.selectedPaxGroup2 + this.selectedPaxGroup3 : this.selectedPax }, priceOptions() { - let price = 0; + let price = { + EUR: 0, + CHF: 0, + }; for (let option of this.selectedOptions) { + let optionPriceEUR = option.price.EUR + let optionPriceCHF = option.price.CHF if (true === option.ignoreWithBoard && this.selectedBoard) { - continue; + optionPriceEUR = -optionPriceEUR + optionPriceCHF = -optionPriceCHF } if (1 === option.type) { - price += option.price; + price.EUR += optionPriceEUR; + price.CHF += optionPriceCHF; } else if (2 === option.type) { - price += option.price * this.totalPax; + price.EUR += optionPriceEUR * this.totalPax; + price.CHF += optionPriceCHF * this.totalPax; } else if (3 === option.type) { - price += option.price * this.nightsCount; + price.EUR += optionPriceEUR * this.nightsCount; + price.CHF += optionPriceCHF * this.nightsCount; } else if (4 === option.type) { - price += option.price * this.nightsCount * this.totalPax; + price.EUR += optionPriceEUR * this.nightsCount * this.totalPax; + price.CHF += optionPriceCHF * this.nightsCount * this.totalPax; } } return price; }, priceBoard() { - let price = 0; - if (this.selectedBoard) { - price = this.selectedBoard.price * this.nightsCount * this.totalPax; + let price = { + EUR: 0, + CHF: 0, } - return price; + if (this.selectedBoard) { + price.EUR = this.selectedBoard.price.EUR * this.nightsCount * this.totalPax; + price.CHF = this.selectedBoard.price.CHF * this.nightsCount * this.totalPax; + } + return price }, priceShortTerm() { - let price = 0; - const totalPricePax = this.pricePax.base + this.pricePax.additional; + let price = { + EUR: 0, + CHF: 0, + } + const totalPricePax = this.pricePax.base.EUR + this.pricePax.additional.EUR; + const totalPricePaxCHF = this.pricePax.base.CHF + this.pricePax.additional.CHF; const shorTermFactor = this.shortTermFactors.find(element => element.nights === this.nightsCount); if (undefined !== shorTermFactor) { - price = totalPricePax * shorTermFactor.factor; + price.EUR = totalPricePax * shorTermFactor.factor; + price.CHF = totalPricePaxCHF * shorTermFactor.factor; } - return price; + return price }, priceRunningCosts() { - // if (this.selectedBoard) { - // return 0; - // } - return this.nightsCount * this.totalPax * this.runningCostsFactor; + return { + EUR: this.nightsCount * this.totalPax * this.runningCostsFactorEur, + CHF: this.nightsCount * this.totalPax * this.runningCostsFactorChf + } }, priceTotal() { - return this.pricePax.base + this.pricePax.additional + this.pricePax.undersubscription + this.priceOptions - + this.priceBoard + this.priceShortTerm + this.priceRunningCosts; - }, - priceSummary() { + let totalEUR = this.pricePax.base.EUR + + this.pricePax.additional.EUR + + this.pricePax.undersubscription.EUR + + this.priceOptions.EUR + + this.priceBoard.EUR + + this.priceShortTerm.EUR + + this.priceRunningCosts.EUR + + let totalCHF = this.pricePax.base.CHF + + this.pricePax.additional.CHF + + this.pricePax.undersubscription.CHF + + this.priceOptions.CHF + + this.priceBoard.CHF + + this.priceShortTerm.CHF + + this.priceRunningCosts.CHF + return { - paxBase: this.formatCurrency(this.pricePax.base), - paxAdditional: this.formatCurrency(this.pricePax.additional), - shortTerm: this.formatCurrency(this.priceShortTerm), - options: this.formatCurrency(this.priceOptions), - board: this.formatCurrency(this.priceBoard), - runningCosts: this.formatCurrency(this.priceRunningCosts), - total: this.formatCurrency(this.priceTotal) + EUR: totalEUR, + CHF: totalCHF, } } }, diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/GroupsPrice/Index.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/GroupsPrice/Index.html index 422fd5ed..e34c5a14 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/GroupsPrice/Index.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/GroupsPrice/Index.html @@ -13,7 +13,11 @@ configs-json='{configs}' boards-json='{boards}' options-json='{options}' - running-costs-factor="{runningCosts}" + running-costs-factor-eur="{runningCostsEUR}" + running-costs-factor-chf="{runningCostsCHF}" + undersubscription-eur="{undersubscriptionEUR}" + undersubscription-chf="{undersubscriptionCHF}" + country-code="{countryCode}" endpoint="{ep:uri.ajax(action: 'processForm', controller: 'AjaxGroupsPrice', pageUid: settings.defaultAjaxUid, arguments: '{hotel: hotel}')}" loader-uri="{f:uri.image(src: 'EXT:ep_theme/Resources/Public/images/ajax-loader-white.gif')}" >