Fixed CustomSurcharge and Introducted Input Price
This commit is contained in:
@@ -101,7 +101,12 @@ const setupPage = async () => {
|
|||||||
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
|
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
|
||||||
|
|
||||||
if(route.params) {
|
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"
|
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.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) {
|
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
|
itemInfo.value.contact = contacts.value.filter(i => i.customer === itemInfo.value.customer)[0].id
|
||||||
@@ -467,6 +475,7 @@ const addPosition = (mode) => {
|
|||||||
text: "",
|
text: "",
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
unit: 1,
|
unit: 1,
|
||||||
|
inputPrice: 0,
|
||||||
price: 0,
|
price: 0,
|
||||||
taxPercent: taxPercentage,
|
taxPercent: taxPercentage,
|
||||||
discountPercent: 0
|
discountPercent: 0
|
||||||
@@ -479,6 +488,7 @@ const addPosition = (mode) => {
|
|||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
mode: "normal",
|
mode: "normal",
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
|
inputPrice: 0,
|
||||||
price: 0,
|
price: 0,
|
||||||
taxPercent: taxPercentage,
|
taxPercent: taxPercentage,
|
||||||
discountPercent: 0,
|
discountPercent: 0,
|
||||||
@@ -489,6 +499,7 @@ const addPosition = (mode) => {
|
|||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
mode: "service",
|
mode: "service",
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
|
inputPrice: 0,
|
||||||
price: 0,
|
price: 0,
|
||||||
taxPercent: taxPercentage,
|
taxPercent: taxPercentage,
|
||||||
discountPercent: 0,
|
discountPercent: 0,
|
||||||
@@ -1178,14 +1189,18 @@ const getTextTemplateByType = (type, pos) => {
|
|||||||
|
|
||||||
const updateCustomSurcharge = () => {
|
const updateCustomSurcharge = () => {
|
||||||
itemInfo.value.rows.forEach(row => {
|
itemInfo.value.rows.forEach(row => {
|
||||||
if(!["pagebreak","title","free","text"].includes(row.mode)) {
|
if(!["pagebreak","title","text"].includes(row.mode)) {
|
||||||
setRowData(row)
|
//setRowData(row)
|
||||||
|
|
||||||
|
row.price = Number((row.inputPrice * (1 + itemInfo.value.customSurchargePercentage /100)).toFixed(2))
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {}) => {
|
const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {}) => {
|
||||||
|
console.log("Set Row Data")
|
||||||
if(service && service.id) {
|
if(service && service.id) {
|
||||||
row.service = service.id
|
row.service = service.id
|
||||||
services.value = await useSupabaseSelect("services","*")
|
services.value = await useSupabaseSelect("services","*")
|
||||||
@@ -1198,7 +1213,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
|
|
||||||
if(row.service) {
|
if(row.service) {
|
||||||
row.unit = service.unit ? service.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 = ((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 : "")
|
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)) {
|
||||||
@@ -1209,8 +1224,10 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(row.product) {
|
if(row.product) {
|
||||||
|
console.log("Product Detected")
|
||||||
row.unit = product.unit ? product.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 = (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 : "")
|
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)) {
|
||||||
@@ -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
|
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"
|
:id="row.product"
|
||||||
@return-data="(data) => setRowData(row,null,data)"
|
@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"
|
||||||
/>
|
/>
|
||||||
@@ -2036,7 +2055,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
|
|
||||||
</UTable>
|
</UTable>
|
||||||
</UCard>
|
</UCard>
|
||||||
</UModal>
|
</UModal>-->
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
@@ -2066,7 +2085,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
:id="row.service"
|
:id="row.service"
|
||||||
@return-data="(data) => setRowData(row,data,null)"
|
@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"
|
||||||
/>
|
/>
|
||||||
@@ -2103,7 +2122,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
|
|
||||||
</UTable>
|
</UTable>
|
||||||
</UCard>
|
</UCard>
|
||||||
</UModal>
|
</UModal>-->
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
@@ -2137,13 +2156,29 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
v-if="!['pagebreak','title','text'].includes(row.mode) && itemInfo.type !== 'deliveryNotes'"
|
v-if="!['pagebreak','title','text'].includes(row.mode) && itemInfo.type !== 'deliveryNotes'"
|
||||||
>
|
>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="row.price"
|
v-model="row.inputPrice"
|
||||||
type="number"
|
type="number"
|
||||||
step="0.001"
|
step="0.001"
|
||||||
|
@change="updateCustomSurcharge"
|
||||||
>
|
>
|
||||||
<template #trailing>
|
<template #leading>
|
||||||
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
||||||
</template>
|
</template>
|
||||||
|
<template #trailing>
|
||||||
|
<span
|
||||||
|
v-if="row.price > row.inputPrice"
|
||||||
|
class="text-primary text-xs">
|
||||||
|
{{useCurrency(row.price)}}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-else-if="row.price < row.inputPrice"
|
||||||
|
class="text-rose-600 text-xs">
|
||||||
|
{{useCurrency(row.price)}}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="text-gray-500 dark:text-gray-400 text-xs"> </span>
|
||||||
|
</template>
|
||||||
</UInput>
|
</UInput>
|
||||||
</td>
|
</td>
|
||||||
<!-- <td
|
<!-- <td
|
||||||
|
|||||||
Reference in New Issue
Block a user