fix: correctly calculate option price per person
closes #8697b8j0m
This commit is contained in:
+31
-18
@@ -95,7 +95,7 @@
|
||||
<tr class="odd:bg-zinc-100"
|
||||
v-for="selectedOption in selectedOptions">
|
||||
<th class="text-left py-2">{{ selectedOption.title }}</th>
|
||||
<td>{{ formatCurrency(selectedOption.price) }}</td>
|
||||
<td>{{ formatCurrency(calculateOptionPrice(selectedOption)) }}</td>
|
||||
</tr>
|
||||
<tr class="odd:bg-zinc-100"
|
||||
v-if="priceBoard.EUR > 0 || priceBoard.CHF > 0">
|
||||
@@ -114,8 +114,11 @@
|
||||
</tr>
|
||||
<tr class="odd:bg-zinc-100">
|
||||
<th class="text-left py-2">Gesamtpreis</th>
|
||||
<td><strong>{{ formatCurrency(priceTotal) }}</strong><br><small>zzgl. vor Ort zu entrichtender
|
||||
Ortstaxe</small></td>
|
||||
<td>
|
||||
<strong>{{ formatCurrency(priceTotal) }}</strong>
|
||||
<br>
|
||||
<small>zzgl. vor Ort zu entrichtender Ortstaxe</small>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -371,6 +374,28 @@ export default {
|
||||
|
||||
return price
|
||||
},
|
||||
calculateOptionPrice(option) {
|
||||
let price = {
|
||||
EUR: 0,
|
||||
CHF: 0,
|
||||
};
|
||||
let optionPriceEUR = option.price.EUR
|
||||
let optionPriceCHF = option.price.CHF
|
||||
if (1 === option.type) {
|
||||
price.EUR = optionPriceEUR;
|
||||
price.CHF = optionPriceCHF;
|
||||
} else if (2 === option.type) {
|
||||
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.selectedPax;
|
||||
price.CHF = optionPriceCHF * this.nightsCount * this.selectedPax;
|
||||
}
|
||||
return price;
|
||||
},
|
||||
formatOptionPriceType(option) {
|
||||
if (2 === option.type) {
|
||||
return ` (${this.formatCurrency(option.price)} pro Person)`
|
||||
@@ -518,21 +543,9 @@ export default {
|
||||
CHF: 0,
|
||||
};
|
||||
for (let option of this.selectedOptions) {
|
||||
let optionPriceEUR = option.price.EUR
|
||||
let optionPriceCHF = option.price.CHF
|
||||
if (1 === option.type) {
|
||||
price.EUR += optionPriceEUR;
|
||||
price.CHF += optionPriceCHF;
|
||||
} else if (2 === option.type) {
|
||||
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.selectedPax;
|
||||
price.CHF += optionPriceCHF * this.nightsCount * this.selectedPax;
|
||||
}
|
||||
let optionPrice = this.calculateOptionPrice(option)
|
||||
price.EUR += optionPrice.EUR;
|
||||
price.CHF += optionPrice.CHF;
|
||||
}
|
||||
return price;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user