diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue
index f73a0a7..da6117d 100644
--- a/pages/createDocument/edit/[[id]].vue
+++ b/pages/createDocument/edit/[[id]].vue
@@ -101,7 +101,12 @@ const setupPage = async () => {
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
if(route.params) {
- if(route.params.id) itemInfo.value = await useSupabaseSelectSingle("createddocuments", route.params.id)
+ if(route.params.id) {
+ itemInfo.value = await useSupabaseSelectSingle("createddocuments", route.params.id)
+
+
+
+ }
if(!itemInfo.value.deliveryDateType) itemInfo.value.deliveryDateType = "Lieferdatum"
@@ -384,7 +389,10 @@ const setCustomerData = async (customerId, loadOnlyAdress = false) => {
if(!loadOnlyAdress && customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays
- if(!loadOnlyAdress && customer.customSurchargePercentage) itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage
+ if(!loadOnlyAdress && customer.customSurchargePercentage) {
+ itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage
+ updateCustomSurcharge()
+ }
if(!loadOnlyAdress && contacts.value.filter(i => i.customer === itemInfo.value.customer).length === 1) {
itemInfo.value.contact = contacts.value.filter(i => i.customer === itemInfo.value.customer)[0].id
@@ -467,6 +475,7 @@ const addPosition = (mode) => {
text: "",
quantity: 1,
unit: 1,
+ inputPrice: 0,
price: 0,
taxPercent: taxPercentage,
discountPercent: 0
@@ -479,6 +488,7 @@ const addPosition = (mode) => {
id: uuidv4(),
mode: "normal",
quantity: 1,
+ inputPrice: 0,
price: 0,
taxPercent: taxPercentage,
discountPercent: 0,
@@ -489,6 +499,7 @@ const addPosition = (mode) => {
id: uuidv4(),
mode: "service",
quantity: 1,
+ inputPrice: 0,
price: 0,
taxPercent: taxPercentage,
discountPercent: 0,
@@ -1178,14 +1189,18 @@ const getTextTemplateByType = (type, pos) => {
const updateCustomSurcharge = () => {
itemInfo.value.rows.forEach(row => {
- if(!["pagebreak","title","free","text"].includes(row.mode)) {
- setRowData(row)
+ if(!["pagebreak","title","text"].includes(row.mode)) {
+ //setRowData(row)
+
+ row.price = Number((row.inputPrice * (1 + itemInfo.value.customSurchargePercentage /100)).toFixed(2))
+
+
}
})
}
const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {}) => {
-
+ console.log("Set Row Data")
if(service && service.id) {
row.service = service.id
services.value = await useSupabaseSelect("services","*")
@@ -1198,7 +1213,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
if(row.service) {
row.unit = service.unit ? service.unit : services.value.find(i => i.id === row.service).unit
- 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.inputPrice = ((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))
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)) {
@@ -1209,8 +1224,10 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
}
if(row.product) {
+ console.log("Product Detected")
row.unit = product.unit ? product.unit : products.value.find(i => i.id === row.product).unit
- row.price = (product.sellingPrice ? product.sellingPrice : products.value.find(i => i.id === row.product).sellingPrice) * (1 + itemInfo.value.customSurchargePercentage /100)
+ row.inputPrice = (product.sellingPrice ? product.sellingPrice : products.value.find(i => i.id === row.product).sellingPrice)
+ //row.price = Number((row.originalPrice * (1 + itemInfo.value.customSurchargePercentage /100)).toFixed(2))
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)) {
@@ -1219,6 +1236,8 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
row.taxPercent = product.taxPercentage ? product.taxPercentage : products.value.find(i => i.id === row.product).taxPercentage
}
}
+
+ updateCustomSurcharge()
}
@@ -1997,7 +2016,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
:id="row.product"
@return-data="(data) => setRowData(row,null,data)"
/>
-