Added Create,Edit,Show to Products and Services
This commit is contained in:
@@ -3,7 +3,6 @@ import dayjs from "dayjs"
|
|||||||
import Handlebars from "handlebars"
|
import Handlebars from "handlebars"
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import {useFunctions} from "~/composables/useFunctions.js";
|
import {useFunctions} from "~/composables/useFunctions.js";
|
||||||
import StandardEntityModal from "~/components/StandardEntityModal.vue";
|
|
||||||
import EntityModalButtons from "~/components/EntityModalButtons.vue";
|
import EntityModalButtons from "~/components/EntityModalButtons.vue";
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
@@ -1144,33 +1143,41 @@ const updateCustomSurcharge = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const setRowData = (row) => {
|
const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {}) => {
|
||||||
console.log(row)
|
|
||||||
|
if(service && service.id) {
|
||||||
|
row.service = service.id
|
||||||
|
services.value = await useSupabaseSelect("services","*")
|
||||||
|
}
|
||||||
|
|
||||||
|
if(product && product.id) {
|
||||||
|
row.product = product.id
|
||||||
|
product.value = await useSupabaseSelect("products","*")
|
||||||
|
}
|
||||||
|
|
||||||
if(row.service) {
|
if(row.service) {
|
||||||
row.unit = services.value.find(i => i.id === row.service).unit
|
row.unit = service.unit ? service.unit : services.value.find(i => i.id === row.service).unit
|
||||||
row.price = (services.value.find(i => i.id === row.service).sellingPriceComposed.total || services.value.find(i => i.id === row.service).sellingPrice) * (1 + itemInfo.value.customSurchargePercentage /100)
|
row.price = ((service.sellingPriceComposed.total || service.sellingPrice) ? (service.sellingPriceComposed.total || service.sellingPrice) : (services.value.find(i => i.id === row.service).sellingPriceComposed.total || services.value.find(i => i.id === row.service).sellingPrice)) * (1 + itemInfo.value.customSurchargePercentage /100)
|
||||||
row.description = services.value.find(i => i.id === row.service).description
|
row.description = service.description ? service.description : (services.value.find(i => i.id === row.service) ? services.value.find(i => i.id === row.service).description : "")
|
||||||
|
|
||||||
if(['13b UStG','19 UStG'].includes(itemInfo.value.taxType)) {
|
if(['13b UStG','19 UStG'].includes(itemInfo.value.taxType)) {
|
||||||
row.taxPercent = 0
|
row.taxPercent = 0
|
||||||
} else {
|
} else {
|
||||||
row.taxPercent = services.value.find(i => i.id === row.service).taxPercentage
|
row.taxPercent = service.taxPercentage ? service.taxPercentage : services.value.find(i => i.id === row.service).taxPercentage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(row.product) {
|
if(row.product) {
|
||||||
row.unit = products.value.find(i => i.id === row.product).unit
|
row.unit = product.unit ? product.unit : products.value.find(i => i.id === row.product).unit
|
||||||
row.price = products.value.find(i => i.id === row.product).sellingPrice * (1 + itemInfo.value.customSurchargePercentage /100)
|
row.price = (product.sellingPrice ? product.sellingPrice : products.value.find(i => i.id === row.product).sellingPrice) * (1 + itemInfo.value.customSurchargePercentage /100)
|
||||||
row.description = products.value.find(i => i.id === row.product).description
|
row.description = product.description ? product.description : (products.value.find(i => i.id === row.product) ? products.value.find(i => i.id === row.product).description : "")
|
||||||
|
|
||||||
if(['13b UStG','19 UStG'].includes(itemInfo.value.taxType)) {
|
if(['13b UStG','19 UStG'].includes(itemInfo.value.taxType)) {
|
||||||
row.taxPercent = 0
|
row.taxPercent = 0
|
||||||
} else {
|
} else {
|
||||||
row.taxPercent = products.value.find(i => i.id === row.product).taxPercentage
|
row.taxPercent = product.taxPercentage ? product.taxPercentage : products.value.find(i => i.id === row.product).taxPercentage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1941,9 +1948,14 @@ const setRowData = (row) => {
|
|||||||
@change="setRowData(row)"
|
@change="setRowData(row)"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<span class="truncate">{{row.product ? products.find(i => i.id === row.product).name : "Kein Produkt ausgewählt" }}</span>
|
<span class="truncate">{{products.find(i => i.id === row.product) ? products.find(i => i.id === row.product).name : "Kein Produkt ausgewählt" }}</span>
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
|
<EntityModalButtons
|
||||||
|
type="products"
|
||||||
|
:id="row.product"
|
||||||
|
@return-data="(data) => setRowData(row,null,data)"
|
||||||
|
/>
|
||||||
<UButton
|
<UButton
|
||||||
icon="i-heroicons-magnifying-glass"
|
icon="i-heroicons-magnifying-glass"
|
||||||
@click="showProductSelectionModal = true"
|
@click="showProductSelectionModal = true"
|
||||||
@@ -2008,6 +2020,11 @@ const setRowData = (row) => {
|
|||||||
<span class="truncate">{{services.find(i => i.id === row.service) ? services.find(i => i.id === row.service).name : "Keine Leistung ausgewählt" }}</span>
|
<span class="truncate">{{services.find(i => i.id === row.service) ? services.find(i => i.id === row.service).name : "Keine Leistung ausgewählt" }}</span>
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
|
<EntityModalButtons
|
||||||
|
type="services"
|
||||||
|
:id="row.service"
|
||||||
|
@return-data="(data) => setRowData(row,data,null)"
|
||||||
|
/>
|
||||||
<UButton
|
<UButton
|
||||||
icon="i-heroicons-magnifying-glass"
|
icon="i-heroicons-magnifying-glass"
|
||||||
@click="showServiceSelectionModal = true"
|
@click="showServiceSelectionModal = true"
|
||||||
|
|||||||
Reference in New Issue
Block a user