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