Compare commits
No commits in common. "ad7ab825c893dc384becdad12531b5dd51d350db" and "a7765797d1f52b15b5ddac6a1a39269143927ae7" have entirely different histories.
ad7ab825c8
...
a7765797d1
10
.eslintrc.js
10
.eslintrc.js
|
@ -17,11 +17,11 @@ module.exports = {
|
||||||
project: resolve(__dirname, './tsconfig.json'),
|
project: resolve(__dirname, './tsconfig.json'),
|
||||||
tsconfigRootDir: __dirname,
|
tsconfigRootDir: __dirname,
|
||||||
ecmaVersion: 2019, // Allows for the parsing of modern ECMAScript features
|
ecmaVersion: 2019, // Allows for the parsing of modern ECMAScript features
|
||||||
sourceType: 'module', // Allows for the use of imports
|
sourceType: 'module' // Allows for the use of imports
|
||||||
},
|
},
|
||||||
|
|
||||||
env: {
|
env: {
|
||||||
browser: true,
|
browser: true
|
||||||
},
|
},
|
||||||
|
|
||||||
// Rules order is important, please avoid shuffling them
|
// Rules order is important, please avoid shuffling them
|
||||||
|
@ -70,6 +70,6 @@ module.exports = {
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
|
||||||
// allow debugger during development only
|
// allow debugger during development only
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/api.d.ts",
|
"types": "src/api.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"format": "prettier --config ./package.json --write '{,!(node_modules)/**/}*.{ts,vue,js}'",
|
"format": "prettier --config ./package.json --write '{,!(node_modules)/**/}*.ts'",
|
||||||
"lint": "eslint --ext .js,.ts,.vue ./src"
|
"lint": "eslint --ext .js,.ts,.vue ./src"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"printWidth": 100,
|
"printWidth": 120,
|
||||||
"arrowParens": "always"
|
"arrowParens": "always"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@ declare namespace FG {
|
||||||
id: number;
|
id: number;
|
||||||
volume: number;
|
volume: number;
|
||||||
ingredient_id: number;
|
ingredient_id: number;
|
||||||
cost_per_volume: number;
|
|
||||||
name: string;
|
|
||||||
}
|
}
|
||||||
interface DrinkPrice {
|
interface DrinkPrice {
|
||||||
id: number;
|
id: number;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:rows="drinks"
|
:rows="drinks"
|
||||||
dense
|
dense
|
||||||
row-key="id"
|
|
||||||
:filter="search"
|
:filter="search"
|
||||||
:filter-method="filter"
|
:filter-method="filter"
|
||||||
grid
|
grid
|
||||||
|
@ -56,7 +55,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template #error>
|
<template #error>
|
||||||
<q-img class="bg-white" style="max-height: 256px" src="no-image.svg" />
|
<q-img class="bg-white" style="max-height: 256px" src='no-image.svg' />
|
||||||
<div
|
<div
|
||||||
v-if="!public && !nodetails && editable"
|
v-if="!public && !nodetails && editable"
|
||||||
class="absolute-top-right justify-end"
|
class="absolute-top-right justify-end"
|
||||||
|
@ -461,9 +460,6 @@ export default defineComponent({
|
||||||
for (const volume of toDeleteObjects.volumes) {
|
for (const volume of toDeleteObjects.volumes) {
|
||||||
await store.deleteVolume(volume, drink);
|
await store.deleteVolume(volume, drink);
|
||||||
}
|
}
|
||||||
if (deletePic) {
|
|
||||||
await deletePicture();
|
|
||||||
}
|
|
||||||
if (drink.id > 0) {
|
if (drink.id > 0) {
|
||||||
await store.updateDrink(drink);
|
await store.updateDrink(drink);
|
||||||
} else {
|
} else {
|
||||||
|
@ -472,6 +468,9 @@ export default defineComponent({
|
||||||
editDrink.value.id = _drink.id;
|
editDrink.value.id = _drink.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (deletePic) {
|
||||||
|
await deletePicture();
|
||||||
|
}
|
||||||
if (drinkPic instanceof File) {
|
if (drinkPic instanceof File) {
|
||||||
await savePicture(drinkPic);
|
await savePicture(drinkPic);
|
||||||
}
|
}
|
||||||
|
@ -496,7 +495,7 @@ export default defineComponent({
|
||||||
|
|
||||||
function image(uuid: string | undefined) {
|
function image(uuid: string | undefined) {
|
||||||
if (uuid) {
|
if (uuid) {
|
||||||
return `${api.defaults.baseURL || ''}/pricelist/picture/${uuid}?size=256`;
|
return `${api.defaults.baseURL||''}/pricelist/picture/${uuid}?size=256`;
|
||||||
}
|
}
|
||||||
return 'no-image.svg';
|
return 'no-image.svg';
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,8 +196,6 @@ export default defineComponent({
|
||||||
id: -1,
|
id: -1,
|
||||||
ingredient_id: newIngredient.value.id,
|
ingredient_id: newIngredient.value.id,
|
||||||
volume: newIngredientVolume.value,
|
volume: newIngredientVolume.value,
|
||||||
cost_per_volume: newIngredient.value.cost_per_volume,
|
|
||||||
name: newIngredient.value.name,
|
|
||||||
},
|
},
|
||||||
extra_ingredient: undefined,
|
extra_ingredient: undefined,
|
||||||
};
|
};
|
||||||
|
|
|
@ -192,8 +192,6 @@ export default defineComponent({
|
||||||
const edit_volumes = ref<Array<DrinkPriceVolume>>([]);
|
const edit_volumes = ref<Array<DrinkPriceVolume>>([]);
|
||||||
function save() {
|
function save() {
|
||||||
(<Drink>edit_drink.value).volumes = edit_volumes.value;
|
(<Drink>edit_drink.value).volumes = edit_volumes.value;
|
||||||
edit_drink.value.cost_per_volume = calc_cost_per_volume(edit_drink.value);
|
|
||||||
edit_drink.value._cost_per_volume = edit_drink.value.cost_per_volume;
|
|
||||||
emit('save', <Drink>edit_drink.value, toDeleteObjects.value, drinkPic.value, deletePic.value);
|
emit('save', <Drink>edit_drink.value, toDeleteObjects.value, drinkPic.value, deletePic.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +272,7 @@ export default defineComponent({
|
||||||
return <string>imgsrc.value;
|
return <string>imgsrc.value;
|
||||||
}
|
}
|
||||||
if (edit_drink.value?.uuid) {
|
if (edit_drink.value?.uuid) {
|
||||||
return `${api.defaults.baseURL || ''}/pricelist/picture/${edit_drink.value.uuid}?size=256`;
|
return `${api.defaults.baseURL||''}/pricelist/picture/${edit_drink.value.uuid}?size=256`;
|
||||||
}
|
}
|
||||||
return 'no-image.svg';
|
return 'no-image.svg';
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
options-cover
|
options-cover
|
||||||
/>
|
/>
|
||||||
<q-btn round icon="mdi-backburger">
|
<q-btn round icon="mdi-backburger">
|
||||||
<q-tooltip anchor="top middle" self="bottom middle"> Reihenfolge ändern </q-tooltip>
|
<q-tooltip anchor='top middle' self='bottom middle'> Reihenfolge ändern </q-tooltip>
|
||||||
<q-menu anchor="bottom middle" self="top middle">
|
<q-menu anchor="bottom middle" self="top middle">
|
||||||
<drag v-model="order" class="q-list" ghost-class="ghost" group="people" item-key="id">
|
<drag v-model="order" class="q-list" ghost-class="ghost" group="people" item-key="id">
|
||||||
<template #item="{ element }">
|
<template #item="{ element }">
|
||||||
|
|
|
@ -157,7 +157,7 @@ export default defineComponent({
|
||||||
const search_keys = computed(() => columns_drinks.filter((column) => column.filterable));
|
const search_keys = computed(() => columns_drinks.filter((column) => column.filterable));
|
||||||
function image(uuid: string | undefined) {
|
function image(uuid: string | undefined) {
|
||||||
if (uuid) {
|
if (uuid) {
|
||||||
return `${api.defaults.baseURL || ''}/pricelist/picture/${uuid}?size=256`;
|
return `${api.defaults.baseURL||''}/pricelist/picture/${uuid}?size=256`;
|
||||||
}
|
}
|
||||||
return 'no-image.svg';
|
return 'no-image.svg';
|
||||||
}
|
}
|
||||||
|
|
29
src/store.ts
29
src/store.ts
|
@ -1,7 +1,6 @@
|
||||||
import { api } from '@flaschengeist/api';
|
import { api } from '@flaschengeist/api';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { calc_volume, calc_cost_per_volume, calc_all_min_prices } from './utils/utils';
|
import { calc_volume, calc_cost_per_volume, calc_all_min_prices } from './utils/utils';
|
||||||
import Ingredient = FG.Ingredient;
|
|
||||||
|
|
||||||
interface DrinkPriceVolume extends Omit<FG.DrinkPriceVolume, 'volume'> {
|
interface DrinkPriceVolume extends Omit<FG.DrinkPriceVolume, 'volume'> {
|
||||||
_volume: number;
|
_volume: number;
|
||||||
|
@ -107,16 +106,11 @@ export const usePricelistStore = defineStore({
|
||||||
if (itm.length > 0) itm[0].name = drinkType.name;
|
if (itm.length > 0) itm[0].name = drinkType.name;
|
||||||
},
|
},
|
||||||
async getExtraIngredients() {
|
async getExtraIngredients() {
|
||||||
const { data } = await api.get<Array<FG.ExtraIngredient>>(
|
const { data } = await api.get<Array<FG.ExtraIngredient>>('pricelist/ingredients/extraIngredients');
|
||||||
'pricelist/ingredients/extraIngredients'
|
|
||||||
);
|
|
||||||
this.extraIngredients = data;
|
this.extraIngredients = data;
|
||||||
},
|
},
|
||||||
async setExtraIngredient(ingredient: FG.ExtraIngredient) {
|
async setExtraIngredient(ingredient: FG.ExtraIngredient) {
|
||||||
const { data } = await api.post<FG.ExtraIngredient>(
|
const { data } = await api.post<FG.ExtraIngredient>('pricelist/ingredients/extraIngredients', ingredient);
|
||||||
'pricelist/ingredients/extraIngredients',
|
|
||||||
ingredient
|
|
||||||
);
|
|
||||||
this.extraIngredients.push(data);
|
this.extraIngredients.push(data);
|
||||||
},
|
},
|
||||||
async updateExtraIngredient(ingredient: FG.ExtraIngredient) {
|
async updateExtraIngredient(ingredient: FG.ExtraIngredient) {
|
||||||
|
@ -197,21 +191,6 @@ export const usePricelistStore = defineStore({
|
||||||
});
|
});
|
||||||
this.drinks[index] = _drink;
|
this.drinks[index] = _drink;
|
||||||
}
|
}
|
||||||
if (!!drink.cost_per_volume) {
|
|
||||||
this.drinks.forEach((_drink: Drink) => {
|
|
||||||
_drink.volumes.forEach((_volume: DrinkPriceVolume) => {
|
|
||||||
_volume.ingredients.forEach((_ingredient: Ingredient) => {
|
|
||||||
if (
|
|
||||||
_ingredient.drink_ingredient &&
|
|
||||||
_ingredient.drink_ingredient.ingredient_id === drink.id
|
|
||||||
) {
|
|
||||||
_ingredient.drink_ingredient.cost_per_volume = drink.cost_per_volume;
|
|
||||||
_ingredient.drink_ingredient.name = drink.name;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
calc_all_min_prices(this.drinks, this.min_prices);
|
calc_all_min_prices(this.drinks, this.min_prices);
|
||||||
},
|
},
|
||||||
deleteDrink(drink: Drink) {
|
deleteDrink(drink: Drink) {
|
||||||
|
@ -289,9 +268,7 @@ export const usePricelistStore = defineStore({
|
||||||
this.pricelist_view = data;
|
this.pricelist_view = data;
|
||||||
},
|
},
|
||||||
async getPriceListColumnOrder(userid: string) {
|
async getPriceListColumnOrder(userid: string) {
|
||||||
const { data } = await api.get<Array<Order>>(
|
const { data } = await api.get<Array<Order>>(`pricelist/users/${userid}/pricecalc_columns_order`);
|
||||||
`pricelist/users/${userid}/pricecalc_columns_order`
|
|
||||||
);
|
|
||||||
this.pricelist_columns_order = data;
|
this.pricelist_columns_order = data;
|
||||||
},
|
},
|
||||||
async updatePriceListColumnOrder(userid: string, data: Array<Order>) {
|
async updatePriceListColumnOrder(userid: string, data: Array<Order>) {
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import { Drink } from '../store';
|
import { Drink } from '../store';
|
||||||
|
|
||||||
function filter(
|
function filter(rows: Array<Drink>, terms: Search, cols: Array<Col>, cellValue: { (col: Col, row: Drink): string }) {
|
||||||
rows: Array<Drink>,
|
|
||||||
terms: Search,
|
|
||||||
cols: Array<Col>,
|
|
||||||
cellValue: { (col: Col, row: Drink): string }
|
|
||||||
) {
|
|
||||||
if (terms.value) {
|
if (terms.value) {
|
||||||
return rows.filter((row) => {
|
return rows.filter((row) => {
|
||||||
if (!terms.key || terms.key === '') {
|
if (!terms.key || terms.key === '') {
|
||||||
|
|
|
@ -17,8 +17,7 @@ function calc_volume(volume: DrinkPriceVolume) {
|
||||||
function calc_cost_per_volume(drink: Drink) {
|
function calc_cost_per_volume(drink: Drink) {
|
||||||
let retVal = drink._cost_per_volume;
|
let retVal = drink._cost_per_volume;
|
||||||
if (!!drink.volume && !!drink.package_size && !!drink.cost_per_package) {
|
if (!!drink.volume && !!drink.package_size && !!drink.cost_per_package) {
|
||||||
retVal =
|
retVal = ((drink.cost_per_package || 0) / ((drink.volume || 0) * (drink.package_size || 0))) * 1.19;
|
||||||
((drink.cost_per_package || 0) / ((drink.volume || 0) * (drink.package_size || 0))) * 1.19;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal ? Math.round(retVal * 1000) / 1000 : retVal;
|
return retVal ? Math.round(retVal * 1000) / 1000 : retVal;
|
||||||
|
@ -37,9 +36,8 @@ function helper(volume: DrinkPriceVolume, min_price: number) {
|
||||||
let extraIngredientPrice = 0;
|
let extraIngredientPrice = 0;
|
||||||
volume.ingredients.forEach((ingredient) => {
|
volume.ingredients.forEach((ingredient) => {
|
||||||
if (ingredient.drink_ingredient) {
|
if (ingredient.drink_ingredient) {
|
||||||
//const _drink = usePricelistStore().drinks.find((a) => a.id === ingredient.drink_ingredient?.ingredient_id);
|
const _drink = usePricelistStore().drinks.find((a) => a.id === ingredient.drink_ingredient?.ingredient_id);
|
||||||
//retVal += ingredient.drink_ingredient.volume * <number>(<unknown>_drink?.cost_per_volume);
|
retVal += ingredient.drink_ingredient.volume * <number>(<unknown>_drink?.cost_per_volume);
|
||||||
retVal += ingredient.drink_ingredient.volume * ingredient.drink_ingredient.cost_per_volume;
|
|
||||||
}
|
}
|
||||||
if (ingredient.extra_ingredient) {
|
if (ingredient.extra_ingredient) {
|
||||||
extraIngredientPrice += ingredient.extra_ingredient.price;
|
extraIngredientPrice += ingredient.extra_ingredient.price;
|
||||||
|
@ -48,11 +46,7 @@ function helper(volume: DrinkPriceVolume, min_price: number) {
|
||||||
return (retVal * min_price) / 100 + extraIngredientPrice;
|
return (retVal * min_price) / 100 + extraIngredientPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calc_min_prices(
|
function calc_min_prices(volume: DrinkPriceVolume, cost_per_volume: number | undefined, min_prices: Array<number>) {
|
||||||
volume: DrinkPriceVolume,
|
|
||||||
cost_per_volume: number | undefined,
|
|
||||||
min_prices: Array<number>
|
|
||||||
) {
|
|
||||||
const retVal: Array<FG.MinPrices> = [];
|
const retVal: Array<FG.MinPrices> = [];
|
||||||
volume.min_prices = [];
|
volume.min_prices = [];
|
||||||
if (min_prices) {
|
if (min_prices) {
|
||||||
|
|
Loading…
Reference in New Issue