feat: remove age based price groups, format currency in calculator

This commit is contained in:
Björn Fromme
2025-02-28 10:40:58 +01:00
parent 5c1b2bf245
commit 061781155e
5 changed files with 38 additions and 408 deletions
@@ -1,6 +1,8 @@
<?php
namespace EP\EpProducts\Domain\Model\Dto;
use EP\EpProducts\Domain\Model\GroupsPriceBoard;
/***************************************************************
*
* Copyright notice
@@ -89,28 +91,13 @@ class GroupsPriceInquiry
*/
protected $pax;
/**
* @var string
*/
protected $paxGroup1;
/**
* @var string
*/
protected $paxGroup2;
/**
* @var string
*/
protected $paxGroup3;
/**
* @var array
*/
protected $options = [];
/**
* @var \EP\EpProducts\Domain\Model\GroupsPriceBoard
* @var GroupsPriceBoard
*/
protected $board;
@@ -288,54 +275,6 @@ class GroupsPriceInquiry
$this->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;
}
@@ -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(),
];
}
}
@@ -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',
],
],
],
];
@@ -25,30 +25,7 @@
class="form-field"
v-model.number="selectedPax"
@change="onPaxUpdated()"
v-show="nightsCount > 0 && !includesBonusCard"/>
<div class="flex space-x-4" v-show="nightsCount > 0 && includesBonusCard">
<div class="w-1/3 flex flex-col space-y-1">
<span>ab 15 Jahre</span>
<input type="number"
class="form-control"
v-model.number="selectedPaxGroup3"
@change="onPaxUpdated()"/>
</div>
<div class="w-1/3 flex flex-col space-y-1">
<span>7-14 Jahre</span>
<input type="number"
class="form-control"
v-model.number="selectedPaxGroup2"
@change="onPaxUpdated()"/>
</div>
<div class="w-1/3 flex flex-col space-y-1">
<span>4-6 Jahre</span>
<input type="number"
class="form-control"
v-model.number="selectedPaxGroup1"
@change="onPaxUpdated()"/>
</div>
</div>
v-show="nightsCount > 0"/>
<p class="text-sm italic"
v-show="nightsCount === 0">
Bitte zuerst einen Zeitraum wählen
@@ -78,7 +55,7 @@
</label>
<select class="form-field"
v-model="selectedBoard"
v-if="totalPax >= 30">
v-if="selectedPax >= 30">
<option :value="null">Keine Auswahl</option>
<option v-for="board of boards"
:value="board"
@@ -86,7 +63,7 @@
{{ board.title }} ({{ formatCurrency(board.price) }} pro Person und Nacht)
</option>
</select>
<div v-show="totalPax < 30">
<div v-show="selectedPax < 30">
<span class="text-red-600">Erst ab 30 Personen buchbar.</span>
</div>
</div>
@@ -115,15 +92,6 @@
<th class="text-left py-2">Aufpreis Kurzzeit</th>
<td>{{ formatCurrency(priceShortTerm) }}</td>
</tr>
<tr class="odd:bg-zinc-100"
v-if="includesBonusCard">
<th class="text-left py-2">Inklusivleistungen</th>
<td>
<a href="https://www.saalbach.com/de/sommer/joker-card" target="_blank" class="uppercase">
Joker Card
</a>
</td>
</tr>
<tr class="odd:bg-zinc-100"
v-if="selectedOptions.length > 0">
<th class="text-left py-2">Zusatzleistungen</th>
@@ -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
}
},
@@ -54,18 +54,6 @@
<th>Anzahl der Personen</th>
<td>{pax -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Anzahl der Personen (ab 15 Jahre)</th>
<td>{paxGroup3 -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Anzahl der Personen (7-14 Jahre)</th>
<td>{paxGroup2 -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Anzahl der Personen (4-6 Jahre)</th>
<td>{paxGroup1 -> v:or(alternative: '-')}</td>
</tr>
<tr>
<th>Verpflegung</th>
<td>