[pricelist] Same cleanup as in backend
This commit is contained in:
parent
4bd2d24e9e
commit
c362843c8e
|
@ -77,8 +77,8 @@ declare namespace FG {
|
||||||
package_size?: number;
|
package_size?: number;
|
||||||
name: string;
|
name: string;
|
||||||
volume?: number;
|
volume?: number;
|
||||||
cost_price_pro_volume?: number;
|
cost_per_volume?: number;
|
||||||
cost_price_package_netto?: number;
|
cost_per_package?: number;
|
||||||
tags?: Array<Tag>;
|
tags?: Array<Tag>;
|
||||||
type?: DrinkType;
|
type?: DrinkType;
|
||||||
volumes: Array<DrinkPriceVolume>;
|
volumes: Array<DrinkPriceVolume>;
|
||||||
|
@ -86,7 +86,7 @@ declare namespace FG {
|
||||||
interface DrinkIngredient {
|
interface DrinkIngredient {
|
||||||
id: number;
|
id: number;
|
||||||
volume: number;
|
volume: number;
|
||||||
drink_ingredient_id: number;
|
ingredient_id: number;
|
||||||
}
|
}
|
||||||
interface DrinkPrice {
|
interface DrinkPrice {
|
||||||
id: number;
|
id: number;
|
||||||
|
|
|
@ -179,7 +179,7 @@ export default defineComponent({
|
||||||
id: -1,
|
id: -1,
|
||||||
drink_ingredient: {
|
drink_ingredient: {
|
||||||
id: -1,
|
id: -1,
|
||||||
drink_ingredient_id: newIngredient.value.id,
|
ingredient_id: newIngredient.value.id,
|
||||||
volume: newIngredientVolume.value,
|
volume: newIngredientVolume.value,
|
||||||
},
|
},
|
||||||
extra_ingredient: undefined,
|
extra_ingredient: undefined,
|
||||||
|
|
|
@ -41,14 +41,14 @@
|
||||||
type="number"
|
type="number"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
v-model.number="newDrink.cost_price_package_netto"
|
v-model.number="newDrink.cost_per_package"
|
||||||
class="col-sm-4 col-xs-6 q-pa-sm"
|
class="col-sm-4 col-xs-6 q-pa-sm"
|
||||||
filled
|
filled
|
||||||
label="Preis Netto/Gebinde"
|
label="Preis Netto/Gebinde"
|
||||||
type="number"
|
type="number"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
v-model="cost_price_pro_volume"
|
v-model="cost_per_volume"
|
||||||
class="col-sm-4 col-xs-6 q-pa-sm"
|
class="col-sm-4 col-xs-6 q-pa-sm"
|
||||||
filled
|
filled
|
||||||
label="Preis mit 19%/Liter"
|
label="Preis mit 19%/Liter"
|
||||||
|
@ -78,8 +78,8 @@ export default defineComponent({
|
||||||
package_size: undefined,
|
package_size: undefined,
|
||||||
name: '',
|
name: '',
|
||||||
volume: undefined,
|
volume: undefined,
|
||||||
cost_price_pro_volume: undefined,
|
cost_per_volume: undefined,
|
||||||
cost_price_package_netto: undefined,
|
cost_per_package: undefined,
|
||||||
tags: [],
|
tags: [],
|
||||||
type: undefined,
|
type: undefined,
|
||||||
volumes: [],
|
volumes: [],
|
||||||
|
@ -87,24 +87,24 @@ export default defineComponent({
|
||||||
|
|
||||||
const calc_price_pro_volume = computed(
|
const calc_price_pro_volume = computed(
|
||||||
() =>
|
() =>
|
||||||
!!newDrink.value.cost_price_package_netto &&
|
!!newDrink.value.cost_per_package &&
|
||||||
!!newDrink.value.volume &&
|
!!newDrink.value.volume &&
|
||||||
!!newDrink.value.package_size
|
!!newDrink.value.package_size
|
||||||
);
|
);
|
||||||
const cost_price_pro_volume = computed({
|
const cost_per_volume = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
if (calc_price_pro_volume.value) {
|
if (calc_price_pro_volume.value) {
|
||||||
const retVal =
|
const retVal =
|
||||||
((newDrink.value.cost_price_package_netto || 0) /
|
((newDrink.value.cost_per_package || 0) /
|
||||||
((newDrink.value.volume || 0) * (newDrink.value.package_size || 0))) *
|
((newDrink.value.volume || 0) * (newDrink.value.package_size || 0))) *
|
||||||
1.19;
|
1.19;
|
||||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||||
newDrink.value.cost_price_pro_volume = Math.round(retVal * 1000) / 1000;
|
newDrink.value.cost_per_volume = Math.round(retVal * 1000) / 1000;
|
||||||
}
|
}
|
||||||
return newDrink.value.cost_price_pro_volume;
|
return newDrink.value.cost_per_volume;
|
||||||
},
|
},
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
newDrink.value.cost_price_pro_volume = val;
|
newDrink.value.cost_per_volume = val;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ export default defineComponent({
|
||||||
drinkTypes: computed(() => store.drinkTypes),
|
drinkTypes: computed(() => store.drinkTypes),
|
||||||
newDrink,
|
newDrink,
|
||||||
calc_price_pro_volume,
|
calc_price_pro_volume,
|
||||||
cost_price_pro_volume,
|
cost_per_volume,
|
||||||
addDrink,
|
addDrink,
|
||||||
cancelAddDrink,
|
cancelAddDrink,
|
||||||
notEmpty,
|
notEmpty,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<q-page padding>
|
||||||
|
<q-card>
|
||||||
<q-table title="Getränke" :columns="columns_drinks" :rows="drinks" row-key="name">
|
<q-table title="Getränke" :columns="columns_drinks" :rows="drinks" row-key="name">
|
||||||
<template #body-cell-volumes="props">
|
<template #body-cell-volumes="props">
|
||||||
<q-td :props="props">
|
<q-td :props="props">
|
||||||
|
@ -31,7 +32,8 @@
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
</div>
|
</q-card>
|
||||||
|
</q-page>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, onBeforeMount, computed } from 'vue';
|
import { defineComponent, onBeforeMount, computed } from 'vue';
|
||||||
|
@ -39,17 +41,6 @@ import { usePricelistStore } from '../store';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Pricelist',
|
name: 'Pricelist',
|
||||||
filters: {
|
|
||||||
setVolume(volume: number) {
|
|
||||||
if (volume * 10 > 1) {
|
|
||||||
return `${volume}l`;
|
|
||||||
}
|
|
||||||
return `${volume * 100}cl`;
|
|
||||||
},
|
|
||||||
setCurrency(price: number) {
|
|
||||||
return `${price.toFixed(2)}€`;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup() {
|
setup() {
|
||||||
const store = usePricelistStore();
|
const store = usePricelistStore();
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<template>
|
|
||||||
<Pricelist />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import Pricelist from '../components/Pricelist.vue';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'PricelistPage',
|
|
||||||
components: { Pricelist },
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
|
@ -19,7 +19,7 @@ export const innerRoutes: FG_Plugin.MenuRoute[] = [
|
||||||
route: {
|
route: {
|
||||||
path: 'pricelist',
|
path: 'pricelist',
|
||||||
name: 'drinks-pricelist',
|
name: 'drinks-pricelist',
|
||||||
component: () => import('../pages/PricelistP.vue'),
|
component: () => import('../pages/Pricelist.vue'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,8 +51,8 @@ class Drink {
|
||||||
package_size,
|
package_size,
|
||||||
name,
|
name,
|
||||||
volume,
|
volume,
|
||||||
cost_price_pro_volume,
|
cost_per_volume,
|
||||||
cost_price_package_netto,
|
cost_per_package,
|
||||||
tags,
|
tags,
|
||||||
type,
|
type,
|
||||||
}: FG.Drink) {
|
}: FG.Drink) {
|
||||||
|
@ -61,15 +61,13 @@ class Drink {
|
||||||
this.package_size = package_size;
|
this.package_size = package_size;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.volume = volume;
|
this.volume = volume;
|
||||||
this.cost_price_package_netto = cost_price_package_netto;
|
this.cost_per_package = cost_per_package;
|
||||||
this._cost_price_pro_volume = cost_price_pro_volume;
|
this.cost_per_volume = cost_per_volume;
|
||||||
this.cost_price_pro_volume = computed({
|
this.cost_price_pro_volume = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
if (!!this.volume && !!this.package_size && !!this.cost_price_package_netto) {
|
if (!!this.volume && !!this.package_size && !!this.cost_per_package) {
|
||||||
const retVal =
|
const retVal =
|
||||||
((this.cost_price_package_netto || 0) /
|
((this.cost_per_package || 0) / ((this.volume || 0) * (this.package_size || 0))) * 1.19;
|
||||||
((this.volume || 0) * (this.package_size || 0))) *
|
|
||||||
1.19;
|
|
||||||
this._cost_price_pro_volume = Math.round(retVal * 1000) / 1000;
|
this._cost_price_pro_volume = Math.round(retVal * 1000) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +280,7 @@ export const usePricelistStore = defineStore({
|
||||||
volume.ingredients.forEach((ingredient) => {
|
volume.ingredients.forEach((ingredient) => {
|
||||||
if (ingredient.drink_ingredient) {
|
if (ingredient.drink_ingredient) {
|
||||||
const _drink = usePricelistStore().drinks.find(
|
const _drink = usePricelistStore().drinks.find(
|
||||||
(a) => a.id === ingredient.drink_ingredient?.drink_ingredient_id
|
(a) => a.id === ingredient.drink_ingredient?.ingredient_id
|
||||||
);
|
);
|
||||||
retVal +=
|
retVal +=
|
||||||
ingredient.drink_ingredient.volume *
|
ingredient.drink_ingredient.volume *
|
||||||
|
|
Loading…
Reference in New Issue