Merge branch 'refs/heads/dev' into beta
This commit is contained in:
@@ -3,7 +3,6 @@ import dayjs from "dayjs"
|
||||
import Handlebars from "handlebars"
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import {useFunctions} from "~/composables/useFunctions.js";
|
||||
import StandardEntityModal from "~/components/StandardEntityModal.vue";
|
||||
import EntityModalButtons from "~/components/EntityModalButtons.vue";
|
||||
|
||||
const dataStore = useDataStore()
|
||||
@@ -102,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.project) checkForOpenAdvanceInvoices()
|
||||
|
||||
@@ -201,19 +205,60 @@ const setupPage = async () => {
|
||||
|
||||
if(route.query.linkedDocument) {
|
||||
itemInfo.value.linkedDocument = route.query.linkedDocument
|
||||
|
||||
let linkedDocument = await useSupabaseSelectSingle("createddocuments",itemInfo.value.linkedDocument)
|
||||
|
||||
itemInfo.value.rows = linkedDocument.rows
|
||||
itemInfo.value.customer = linkedDocument.customer
|
||||
itemInfo.value.project = linkedDocument.project
|
||||
itemInfo.value.contact = linkedDocument.contact
|
||||
itemInfo.value.description = linkedDocument.description
|
||||
itemInfo.value.deliveryDate = linkedDocument.deliveryDate
|
||||
itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType
|
||||
|
||||
if(route.query.optionsToImport) {
|
||||
//Import only true
|
||||
let optionsToImport = JSON.parse(route.query.optionsToImport)
|
||||
|
||||
console.log(optionsToImport)
|
||||
console.log(linkedDocument)
|
||||
|
||||
if(optionsToImport.taxType) itemInfo.value.taxType = linkedDocument.taxType
|
||||
if(optionsToImport.customer) itemInfo.value.customer = linkedDocument.customer
|
||||
if(optionsToImport.letterhead) itemInfo.value.letterhead = linkedDocument.letterhead
|
||||
if(optionsToImport.contact) itemInfo.value.contact = linkedDocument.contact
|
||||
if(optionsToImport.deliveryDateType) itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType
|
||||
if(optionsToImport.deliveryDate) itemInfo.value.deliveryDate = linkedDocument.deliveryDate
|
||||
if(optionsToImport.deliveryDateEnd) itemInfo.value.deliveryDateEnd = linkedDocument.deliveryDateEnd
|
||||
if(optionsToImport.documentDate) itemInfo.value.documentDate = linkedDocument.documentDate
|
||||
if(optionsToImport.paymentDays) itemInfo.value.paymentDays = linkedDocument.paymentDays
|
||||
if(optionsToImport.customSurchargePercentage) itemInfo.value.customSurchargePercentage = linkedDocument.customSurchargePercentage
|
||||
if(optionsToImport.contactPerson) itemInfo.value.contactPerson = linkedDocument.contactPerson
|
||||
if(optionsToImport.plant) itemInfo.value.plant = linkedDocument.plant
|
||||
if(optionsToImport.project) itemInfo.value.project = linkedDocument.project
|
||||
if(optionsToImport.title) itemInfo.value.title = linkedDocument.title
|
||||
if(optionsToImport.description) itemInfo.value.description = linkedDocument.description
|
||||
if(optionsToImport.startText) itemInfo.value.startText = linkedDocument.startText
|
||||
if(optionsToImport.rows) itemInfo.value.rows = linkedDocument.rows
|
||||
if(optionsToImport.endText) itemInfo.value.endText = linkedDocument.endText
|
||||
|
||||
} else {
|
||||
// Import all
|
||||
|
||||
itemInfo.value.taxType = linkedDocument.taxType
|
||||
itemInfo.value.customer = linkedDocument.customer
|
||||
itemInfo.value.letterhead = linkedDocument.letterhead
|
||||
itemInfo.value.contact = linkedDocument.contact
|
||||
itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType
|
||||
itemInfo.value.deliveryDate = linkedDocument.deliveryDate
|
||||
itemInfo.value.deliveryDateEnd = linkedDocument.deliveryDateEnd
|
||||
itemInfo.value.documentDate = linkedDocument.documentDate
|
||||
itemInfo.value.paymentDays = linkedDocument.paymentDays
|
||||
itemInfo.value.customSurchargePercentage = linkedDocument.customSurchargePercentage
|
||||
itemInfo.value.contactPerson = linkedDocument.contactPerson
|
||||
itemInfo.value.plant = linkedDocument.plant
|
||||
itemInfo.value.project = linkedDocument.project
|
||||
itemInfo.value.title = linkedDocument.title
|
||||
itemInfo.value.description = linkedDocument.description
|
||||
itemInfo.value.startText = linkedDocument.startText
|
||||
itemInfo.value.rows = linkedDocument.rows
|
||||
itemInfo.value.endText = linkedDocument.endText
|
||||
}
|
||||
|
||||
|
||||
setCustomerData()
|
||||
setCustomerData(null,true)
|
||||
|
||||
if(route.query.loadMode === "storno") {
|
||||
itemInfo.value.rows.forEach(row => {
|
||||
@@ -329,7 +374,7 @@ const setTaxType = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const setCustomerData = async (customerId) => {
|
||||
const setCustomerData = async (customerId, loadOnlyAdress = false) => {
|
||||
|
||||
if(customerId){
|
||||
itemInfo.value.customer = customerId
|
||||
@@ -347,11 +392,14 @@ const setCustomerData = async (customerId) => {
|
||||
itemInfo.value.address.city = customer.infoData.city
|
||||
itemInfo.value.address.special = customer.infoData.special
|
||||
|
||||
if(customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays
|
||||
if(!loadOnlyAdress && customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays
|
||||
|
||||
if(customer.customSurchargePercentage) itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage
|
||||
if(!loadOnlyAdress && customer.customSurchargePercentage) {
|
||||
itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage
|
||||
updateCustomSurcharge()
|
||||
}
|
||||
|
||||
if(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
|
||||
}
|
||||
|
||||
@@ -432,6 +480,7 @@ const addPosition = (mode) => {
|
||||
text: "",
|
||||
quantity: 1,
|
||||
unit: 1,
|
||||
inputPrice: 0,
|
||||
price: 0,
|
||||
taxPercent: taxPercentage,
|
||||
discountPercent: 0
|
||||
@@ -444,6 +493,7 @@ const addPosition = (mode) => {
|
||||
id: uuidv4(),
|
||||
mode: "normal",
|
||||
quantity: 1,
|
||||
inputPrice: 0,
|
||||
price: 0,
|
||||
taxPercent: taxPercentage,
|
||||
discountPercent: 0,
|
||||
@@ -454,6 +504,7 @@ const addPosition = (mode) => {
|
||||
id: uuidv4(),
|
||||
mode: "service",
|
||||
quantity: 1,
|
||||
inputPrice: 0,
|
||||
price: 0,
|
||||
taxPercent: taxPercentage,
|
||||
discountPercent: 0,
|
||||
@@ -1075,7 +1126,7 @@ const saveDocument = async (state,resetup = false) => {
|
||||
} else {
|
||||
const data = await dataStore.createNewItem("createddocuments", createData)
|
||||
console.log(data)
|
||||
await router.push(`/createDocument/edit/${data[0].id}`)
|
||||
await router.push(`/createDocument/edit/${data.id}`)
|
||||
}
|
||||
|
||||
if(resetup) await setupPage()
|
||||
@@ -1143,39 +1194,55 @@ 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 = (row) => {
|
||||
console.log(row)
|
||||
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","*")
|
||||
}
|
||||
|
||||
if(product && product.id) {
|
||||
row.product = product.id
|
||||
product.value = await useSupabaseSelect("products","*")
|
||||
}
|
||||
|
||||
if(row.service) {
|
||||
row.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.description = services.value.find(i => i.id === row.service).description
|
||||
row.unit = service.unit ? service.unit : services.value.find(i => i.id === row.service).unit
|
||||
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)) {
|
||||
row.taxPercent = 0
|
||||
} 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) {
|
||||
row.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.description = products.value.find(i => i.id === row.product).description
|
||||
console.log("Product Detected")
|
||||
row.unit = product.unit ? product.unit : products.value.find(i => i.id === row.product).unit
|
||||
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)) {
|
||||
row.taxPercent = 0
|
||||
} 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateCustomSurcharge()
|
||||
}
|
||||
|
||||
|
||||
@@ -1873,8 +1940,8 @@ const setRowData = (row) => {
|
||||
<th class="pl-2">Menge</th>
|
||||
<th class="pl-2">Einheit</th>
|
||||
<th class="pl-2" v-if="itemInfo.type !== 'deliveryNotes'">Preis</th>
|
||||
<th class="pl-2" v-if="itemInfo.type !== 'deliveryNotes'">Steuer</th>
|
||||
<th class="pl-2" v-if="itemInfo.type !== 'deliveryNotes'">Rabatt</th>
|
||||
<!-- <th class="pl-2" v-if="itemInfo.type !== 'deliveryNotes'">Steuer</th>
|
||||
<th class="pl-2" v-if="itemInfo.type !== 'deliveryNotes'">Rabatt</th>-->
|
||||
<th class="pl-2"> </th>
|
||||
<th class="pl-2" v-if="itemInfo.type !== 'deliveryNotes'">Gesamt</th>
|
||||
</tr>
|
||||
@@ -1945,10 +2012,15 @@ const setRowData = (row) => {
|
||||
@change="setRowData(row)"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
<UButton
|
||||
<EntityModalButtons
|
||||
type="products"
|
||||
:id="row.product"
|
||||
@return-data="(data) => setRowData(row,null,data)"
|
||||
/>
|
||||
<!-- <UButton
|
||||
icon="i-heroicons-magnifying-glass"
|
||||
@click="showProductSelectionModal = true"
|
||||
/>
|
||||
@@ -1987,7 +2059,7 @@ const setRowData = (row) => {
|
||||
|
||||
</UTable>
|
||||
</UCard>
|
||||
</UModal>
|
||||
</UModal>-->
|
||||
</InputGroup>
|
||||
|
||||
</td>
|
||||
@@ -2012,7 +2084,12 @@ 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>
|
||||
</template>
|
||||
</USelectMenu>
|
||||
<UButton
|
||||
<EntityModalButtons
|
||||
type="services"
|
||||
:id="row.service"
|
||||
@return-data="(data) => setRowData(row,data,null)"
|
||||
/>
|
||||
<!-- <UButton
|
||||
icon="i-heroicons-magnifying-glass"
|
||||
@click="showServiceSelectionModal = true"
|
||||
/>
|
||||
@@ -2049,7 +2126,7 @@ const setRowData = (row) => {
|
||||
|
||||
</UTable>
|
||||
</UCard>
|
||||
</UModal>
|
||||
</UModal>-->
|
||||
</InputGroup>
|
||||
</td>
|
||||
<td
|
||||
@@ -2083,16 +2160,32 @@ const setRowData = (row) => {
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode) && itemInfo.type !== 'deliveryNotes'"
|
||||
>
|
||||
<UInput
|
||||
v-model="row.price"
|
||||
v-model="row.inputPrice"
|
||||
type="number"
|
||||
step="0.001"
|
||||
@change="updateCustomSurcharge"
|
||||
>
|
||||
<template #trailing>
|
||||
<template #leading>
|
||||
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
||||
</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>
|
||||
</td>
|
||||
<td
|
||||
<!-- <td
|
||||
class="w-40"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)&& itemInfo.type !== 'deliveryNotes'"
|
||||
|
||||
@@ -2110,8 +2203,8 @@ const setRowData = (row) => {
|
||||
</template>
|
||||
</USelectMenu>
|
||||
|
||||
</td>
|
||||
<td
|
||||
</td>-->
|
||||
<!-- <td
|
||||
class="w-40"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)&& itemInfo.type !== 'deliveryNotes'"
|
||||
>
|
||||
@@ -2125,7 +2218,7 @@ const setRowData = (row) => {
|
||||
<span class="text-gray-500 dark:text-gray-400 text-xs">%</span>
|
||||
</template>
|
||||
</UInput>
|
||||
</td>
|
||||
</td>-->
|
||||
<td
|
||||
class="w-40"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
||||
|
||||
Reference in New Issue
Block a user