release v2.0.0 #4
			
				
			
		
		
		
	|  | @ -273,10 +273,10 @@ | |||
|             /> | ||||
|           </q-popup-edit> | ||||
|         </q-td> | ||||
|         <q-td key="cost_price_package_netto" :props="drinks_props"> | ||||
|         <q-td key="cost_per_package" :props="drinks_props"> | ||||
|           {{ | ||||
|             drinks_props.row.cost_price_package_netto | ||||
|               ? `${drinks_props.row.cost_price_package_netto.toFixed(2)}€` | ||||
|             drinks_props.row.cost_per_package | ||||
|               ? `${drinks_props.row.cost_per_package.toFixed(2)}€` | ||||
|               : 'o.A.' | ||||
|           }} | ||||
|           <q-popup-edit | ||||
|  | @ -286,7 +286,7 @@ | |||
|               ) | ||||
|             " | ||||
|             v-slot="scope" | ||||
|             v-model="drinks_props.row.cost_price_package_netto" | ||||
|             v-model="drinks_props.row.cost_per_package" | ||||
|             buttons | ||||
|             label-cancel="Abbrechen" | ||||
|             label-set="Speichern" | ||||
|  | @ -305,16 +305,16 @@ | |||
|             /> | ||||
|           </q-popup-edit> | ||||
|         </q-td> | ||||
|         <q-td key="cost_price_pro_volume" :props="drinks_props"> | ||||
|         <q-td key="cost_per_volume" :props="drinks_props"> | ||||
|           {{ | ||||
|             drinks_props.row.cost_price_pro_volume | ||||
|               ? `${drinks_props.row.cost_price_pro_volume.toFixed(3)}€` | ||||
|             drinks_props.row.cost_per_volume | ||||
|               ? `${drinks_props.row.cost_per_volume.toFixed(3)}€` | ||||
|               : 'o.A.' | ||||
|           }} | ||||
|           <q-popup-edit | ||||
|             v-if=" | ||||
|               !( | ||||
|                 !!drinks_props.row.cost_price_package_netto && | ||||
|                 !!drinks_props.row.cost_per_package && | ||||
|                 !!drinks_props.row.volume && | ||||
|                 !!drinks_props.row.package_size | ||||
|               ) && | ||||
|  | @ -323,7 +323,7 @@ | |||
|               ) | ||||
|             " | ||||
|             v-slot="scope" | ||||
|             v-model="drinks_props.row.cost_price_pro_volume" | ||||
|             v-model="drinks_props.row.cost_per_volume" | ||||
|             buttons | ||||
|             label-cancel="Abbrechen" | ||||
|             label-set="Speichern" | ||||
|  | @ -467,17 +467,17 @@ export default defineComponent({ | |||
|         sort, | ||||
|       }, | ||||
|       { | ||||
|         name: 'cost_price_package_netto', | ||||
|         name: 'cost_per_package', | ||||
|         label: 'Preis Netto/Gebinde', | ||||
|         field: 'cost_price_package_netto', | ||||
|         field: 'cost_per_package', | ||||
|         format: (val: number | null) => (val ? `${val.toFixed(3)}€` : ''), | ||||
|         sortable: true, | ||||
|         sort, | ||||
|       }, | ||||
|       { | ||||
|         name: 'cost_price_pro_volume', | ||||
|         name: 'cost_per_volume', | ||||
|         label: 'Preis mit 19%/Liter', | ||||
|         field: 'cost_price_pro_volume', | ||||
|         field: 'cost_per_volume', | ||||
|         format: (val: number | null) => (val ? `${val.toFixed(3)}€` : ''), | ||||
|         sortable: true, | ||||
|         sort: (a: ComputedRef, b: ComputedRef) => sort(a.value, b.value), | ||||
|  |  | |||
|  | @ -210,8 +210,8 @@ export default defineComponent({ | |||
|     } | ||||
|     const drinks = computed(() => | ||||
|       store.drinks.filter((drink) => { | ||||
|         console.log('computed drinks', drink.name, drink.cost_price_pro_volume); | ||||
|         return drink.cost_price_pro_volume; | ||||
|         console.log('computed drinks', drink.name, drink.cost_per_volume); | ||||
|         return drink.cost_per_volume; | ||||
|       }) | ||||
|     ); | ||||
|     const extra_ingredients = computed(() => store.extraIngredients); | ||||
|  |  | |||
|  | @ -48,8 +48,7 @@ export default defineComponent({ | |||
|                     (a) => a.id === ingredient.drink_ingredient?.ingredient_id | ||||
|                   ); | ||||
|                   retVal += | ||||
|                     ingredient.drink_ingredient.volume * | ||||
|                     <number>(<unknown>_drink?.cost_price_pro_volume); | ||||
|                     ingredient.drink_ingredient.volume * <number>(<unknown>_drink?.cost_per_volume); | ||||
|                 } | ||||
|                 if (ingredient.extra_ingredient) { | ||||
|                   extraIngredientPrice += ingredient.extra_ingredient.price; | ||||
|  |  | |||
|  | @ -13,10 +13,10 @@ interface DrinkPriceVolume extends Omit<Omit<FG.DrinkPriceVolume, 'volume'>, 'mi | |||
|   min_prices: MinPrice[]; | ||||
| } | ||||
| 
 | ||||
| interface Drink extends Omit<Omit<FG.Drink, 'cost_price_pro_volume'>, 'volumes'> { | ||||
| interface Drink extends Omit<Omit<FG.Drink, 'cost_per_volume'>, 'volumes'> { | ||||
|   volumes: DrinkPriceVolume[]; | ||||
|   cost_price_pro_volume: WritableComputedRef<number | undefined>; | ||||
|   _cost_price_pro_volume?: number; | ||||
|   cost_per_volume: WritableComputedRef<number | undefined>; | ||||
|   _cost_per_volume?: number; | ||||
| } | ||||
| 
 | ||||
| class DrinkPriceVolume implements DrinkPriceVolume { | ||||
|  | @ -66,18 +66,18 @@ class Drink { | |||
|     this.name = name; | ||||
|     this.volume = volume; | ||||
|     this.cost_per_package = cost_per_package; | ||||
|     this.cost_per_volume = cost_per_volume; | ||||
|     this.cost_price_pro_volume = computed({ | ||||
|     this._cost_per_volume = cost_per_volume; | ||||
|     this.cost_per_volume = computed({ | ||||
|       get: () => { | ||||
|         if (!!this.volume && !!this.package_size && !!this.cost_per_package) { | ||||
|           const retVal = | ||||
|             ((this.cost_per_package || 0) / ((this.volume || 0) * (this.package_size || 0))) * 1.19; | ||||
|           this._cost_price_pro_volume = Math.round(retVal * 1000) / 1000; | ||||
|           this._cost_per_volume = Math.round(retVal * 1000) / 1000; | ||||
|         } | ||||
| 
 | ||||
|         return this._cost_price_pro_volume; | ||||
|         return this._cost_per_volume; | ||||
|       }, | ||||
|       set: (val) => (this._cost_price_pro_volume = val), | ||||
|       set: (val) => (this._cost_per_volume = val), | ||||
|     }); | ||||
|     this.tags = tags; | ||||
|     this.type = type; | ||||
|  | @ -208,7 +208,9 @@ export const usePricelistStore = defineStore({ | |||
|         .catch((err) => console.warn(err)); | ||||
|     }, | ||||
|     async setDrink(drink: FG.Drink) { | ||||
|       const { data } = await api.post<FG.Drink>('pricelist/drinks', drink); | ||||
|       const { data } = await api.post<FG.Drink>('pricelist/drinks', { | ||||
|         ...drink, | ||||
|       }); | ||||
|       const _drink = new Drink(data); | ||||
|       data.volumes.forEach((volume) => { | ||||
|         const _volume = new DrinkPriceVolume(volume); | ||||
|  | @ -218,7 +220,11 @@ export const usePricelistStore = defineStore({ | |||
|       this.create_min_prices(); | ||||
|     }, | ||||
|     async updateDrink(drink: Drink) { | ||||
|       const { data } = await api.put<FG.Drink>(`pricelist/drinks/${drink.id}`, drink); | ||||
|       console.log(drink); | ||||
|       const { data } = await api.put<FG.Drink>(`pricelist/drinks/${drink.id}`, { | ||||
|         ...drink, | ||||
|         cost_per_volume: drink._cost_per_volume, | ||||
|       }); | ||||
|       const index = this.drinks.findIndex((a) => a.id === data.id); | ||||
|       if (index > -1) { | ||||
|         const _drink = new Drink(data); | ||||
|  | @ -273,10 +279,10 @@ export const usePricelistStore = defineStore({ | |||
|           volume.min_prices = []; | ||||
|           this.min_prices.forEach((min_price) => { | ||||
|             let computedMinPrice: ComputedRef; | ||||
|             if (drink.cost_price_pro_volume) { | ||||
|             if (drink.cost_per_volume) { | ||||
|               computedMinPrice = computed<number>( | ||||
|                 () => | ||||
|                   (<number>(<unknown>drink.cost_price_pro_volume) * | ||||
|                   (<number>(<unknown>drink.cost_per_volume) * | ||||
|                     <number>(<unknown>volume.volume) * | ||||
|                     min_price) / | ||||
|                   100 | ||||
|  | @ -292,7 +298,7 @@ export const usePricelistStore = defineStore({ | |||
|                     ); | ||||
|                     retVal += | ||||
|                       ingredient.drink_ingredient.volume * | ||||
|                       <number>(<unknown>_drink?.cost_price_pro_volume); | ||||
|                       <number>(<unknown>_drink?.cost_per_volume); | ||||
|                   } | ||||
|                   if (ingredient.extra_ingredient) { | ||||
|                     extraIngredientPrice += ingredient.extra_ingredient.price; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue