From 0df2677b1b85d903683b214ed935e2884b240298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Wed, 14 Apr 2021 19:39:05 +0200 Subject: [PATCH] [pricelist](issue #4) add warning when price is less then min_price --- .../CalculationTable/DrinkPriceVolumes.vue | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue index c5627b1..0c20c09 100644 --- a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue +++ b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue @@ -84,6 +84,9 @@ +
+ Einer der Preise ist unterhalb des niedrigsten minimal Preises. +
Preis hinzufügen @@ -269,6 +272,24 @@ export default defineComponent({ emit('update:modelValue', volumes.value); } + const isUnderMinPrice = computed(() => { + if (volumes.value) { + const this_volume = volumes.value.find(a => a.id === volume.value) + if (this_volume) { + if (this_volume.min_prices.length > 0) { + const min_price = this_volume.min_prices.sort((a, b) => { + if (a.price > b.price) return 1 + if (a.price < b.price) return -1 + return 0 + })[0] + console.log('min_price', min_price) + return this_volume.prices.some(a => a.price < min_price.price) + } + } + } + return false + }) + return { volumes, volume, @@ -282,9 +303,14 @@ export default defineComponent({ deleteVolume, deleteIngredient, change, + isUnderMinPrice }; }, }); - +