From 14206d9117d5d682de49a9fd62fccceea6fb41ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 21 Mar 2021 23:02:25 +0100 Subject: [PATCH] [pricelist] improved add drink --- .../pricelist/components/CalculationTable.vue | 117 ++------------- .../components/CalculationTable/NewDrink.vue | 134 ++++++++++++++++++ src/plugins/pricelist/store.ts | 49 +------ 3 files changed, 143 insertions(+), 157 deletions(-) create mode 100644 src/plugins/pricelist/components/CalculationTable/NewDrink.vue diff --git a/src/plugins/pricelist/components/CalculationTable.vue b/src/plugins/pricelist/components/CalculationTable.vue index 1f33be0..33a0fc2 100644 --- a/src/plugins/pricelist/components/CalculationTable.vue +++ b/src/plugins/pricelist/components/CalculationTable.vue @@ -26,64 +26,8 @@ - -
-
Neues Getränk
-
- - - - - - - -
-
- - -
-
+ +
+ + diff --git a/src/plugins/pricelist/store.ts b/src/plugins/pricelist/store.ts index af6b06d..604efa8 100644 --- a/src/plugins/pricelist/store.ts +++ b/src/plugins/pricelist/store.ts @@ -83,50 +83,6 @@ class Drink { } } -function create_min_prices(drink: Drink, volume: DrinkPriceVolume, percentage: number) { - if (drink.name == 'Elbhang Rot') { - console.log(drink.name, drink.cost_price_pro_volume, volume.volume, drink, volume); - } - if (drink.cost_price_pro_volume?.value) { - if (volume.ingredients.every((ingredient) => !!ingredient.drink_ingredient)) { - return computed(() => { - let retVal = (drink.cost_price_pro_volume?.value || 0) * (volume.volume?.value || 0); - volume.ingredients.forEach((ingredient) => { - if (ingredient.extra_ingredient) { - retVal += ingredient.extra_ingredient.price; - } - }); - retVal = (retVal * percentage) / 100; - return retVal; - }); - } else { - return computed( - () => - ((drink.cost_price_pro_volume?.value || 0) * (volume.volume?.value || 0) * percentage) / - 100 - ); - } - } else { - return computed(() => { - let retVal = 0; - let extraIngredientPrice = 0; - volume.ingredients.forEach((ingredient) => { - if (ingredient.drink_ingredient) { - const _drink = usePricelistStore().drinks.find( - (a) => a.id === ingredient.drink_ingredient?.drink_ingredient_id - ); - retVal += - ingredient.drink_ingredient.volume * (_drink?.cost_price_pro_volume?.value || 0); - } - if (ingredient.extra_ingredient) { - extraIngredientPrice += ingredient.extra_ingredient.price; - } - }); - return (retVal * percentage) / 100 + extraIngredientPrice; - }); - } -} - export const usePricelistStore = defineStore({ id: 'pricelist', @@ -308,9 +264,6 @@ export const usePricelistStore = defineStore({ create_min_prices() { this.drinks.forEach((drink) => { drink.volumes.forEach((volume) => { - if (drink.name == 'Elbhang Rot2') { - console.log(drink.name, drink.cost_price_pro_volume, volume, drink); - } volume.min_prices = []; this.min_prices.forEach((min_price) => { let computedMinPrice: ComputedRef; @@ -350,4 +303,4 @@ export const usePricelistStore = defineStore({ }, }); -export { create_min_prices, DrinkPriceVolume, MinPrice, Drink }; +export { DrinkPriceVolume, MinPrice, Drink };