|
|
|
|
@@ -36,7 +36,7 @@ const itemInfo = ref({
|
|
|
|
|
deliveryDate: dayjs(),
|
|
|
|
|
deliveryDateType: "Lieferdatum",
|
|
|
|
|
dateOfPerformance: null,
|
|
|
|
|
paymentDays: 7,
|
|
|
|
|
paymentDays: profileStore.ownTenant.standardPaymentDays,
|
|
|
|
|
createdBy: profileStore.activeProfile.id,
|
|
|
|
|
title: null,
|
|
|
|
|
description: null,
|
|
|
|
|
@@ -61,6 +61,7 @@ const itemInfo = ref({
|
|
|
|
|
usedAdvanceInvoices: []
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
console.log(profileStore.ownTenant)
|
|
|
|
|
|
|
|
|
|
const letterheads = ref([])
|
|
|
|
|
const createddocuments = ref([])
|
|
|
|
|
@@ -78,6 +79,7 @@ const texttemplates = ref([])
|
|
|
|
|
const loaded = ref(false)
|
|
|
|
|
const setupPage = async () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
letterheads.value = (await useSupabaseSelect("letterheads","*")).filter(i => i.documentTypes.length === 0 || i.documentTypes.includes(itemInfo.value.type))
|
|
|
|
|
createddocuments.value = (await useSupabaseSelect("createddocuments","*"))
|
|
|
|
|
projects.value = (await useSupabaseSelect("projects","*"))
|
|
|
|
|
@@ -154,7 +156,7 @@ const setupPage = async () => {
|
|
|
|
|
|
|
|
|
|
setPosNumbers()
|
|
|
|
|
|
|
|
|
|
if(linkedDocuments.find(i => i.agriculture)){
|
|
|
|
|
if(linkedDocuments.find(i => i.agriculture.dieselUsage)){
|
|
|
|
|
itemInfo.value.rows = itemInfo.value.rows.filter(i => i.key !== "dieselPos")
|
|
|
|
|
|
|
|
|
|
itemInfo.value.rows.push({
|
|
|
|
|
@@ -185,6 +187,19 @@ const setupPage = async () => {
|
|
|
|
|
|
|
|
|
|
setCustomerData()
|
|
|
|
|
|
|
|
|
|
if(route.query.loadMode === "storno") {
|
|
|
|
|
itemInfo.value.rows.forEach(row => {
|
|
|
|
|
row.price = row.price * -1
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
itemInfo.value.description = `Stornorechnung zu Rechnung ${linkedDocument.documentNumber} vom ${dayjs(linkedDocument.documentDate).format('DD.MM.YYYY')}`
|
|
|
|
|
|
|
|
|
|
itemInfo.value.type = "cancellationInvoices"
|
|
|
|
|
|
|
|
|
|
setDocumentTypeConfig(true)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -227,7 +242,7 @@ const addAdvanceInvoiceToInvoice = (advanceInvoice) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const setDocumentTypeConfig = (withTexts = false) => {
|
|
|
|
|
if(itemInfo.value.type === "invoices" ||itemInfo.value.type === "advanceInvoices" || itemInfo.value.type === "serialInvoices") {
|
|
|
|
|
if(itemInfo.value.type === "invoices" ||itemInfo.value.type === "advanceInvoices" || itemInfo.value.type === "serialInvoices"|| itemInfo.value.type === "cancellationInvoices") {
|
|
|
|
|
itemInfo.value.documentNumberTitle = "Rechnungsnummer"
|
|
|
|
|
itemInfo.value.title = `Rechnung-Nr. ${itemInfo.value.documentNumber ? itemInfo.value.documentNumber : "XXXX"}`
|
|
|
|
|
} else if(itemInfo.value.type === "quotes") {
|
|
|
|
|
@@ -433,6 +448,21 @@ const findDocumentErrors = computed(() => {
|
|
|
|
|
if(row.mode === "title" && !row.text) errors.push({message: `In Position ${row.pos} ist kein Titel hinterlegt`, type: "breaking"})
|
|
|
|
|
if(row.mode === "text" && !row.text) errors.push({message: `In einer Freitext Position ist kein Titel hinterlegt`, type: "breaking"})
|
|
|
|
|
if(row.mode === "free" && !row.text) errors.push({message: `In einer freien Position ist kein Titel hinterlegt`, type: "breaking"})
|
|
|
|
|
|
|
|
|
|
if(["normal","service","free"].includes(row.mode)){
|
|
|
|
|
|
|
|
|
|
if(!row.taxPercent) errors.push({message: `In Position ${row.pos} ist kein Steuersatz hinterlegt`, type: "breaking"})
|
|
|
|
|
if(!row.price || row.price === 0) errors.push({message: `In Position ${row.pos} ist kein Preis hinterlegt`, type: "breaking"})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(row.agriculture){
|
|
|
|
|
if(row.agriculture.dieselUsage && (!row.agriculture.dieselPrice || row.agriculture.dieselPrice === 0)) {
|
|
|
|
|
errors.push({message: `In Position ${row.pos} ist kein Dieselpreis hinterlegt`, type: "breaking"})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -760,7 +790,7 @@ const saveDocument = async (state,resetup = false) => {
|
|
|
|
|
console.log("???")
|
|
|
|
|
|
|
|
|
|
let type = ""
|
|
|
|
|
if(itemInfo.value.type === "advanceInvoices"){
|
|
|
|
|
if(itemInfo.value.type === "advanceInvoices" || itemInfo.value.type === "cancellationInvoices"){
|
|
|
|
|
type = "invoices"
|
|
|
|
|
} else {
|
|
|
|
|
type = itemInfo.value.type
|
|
|
|
|
@@ -852,9 +882,16 @@ const closeDocument = async () => {
|
|
|
|
|
|
|
|
|
|
fileData.project = itemInfo.value.project
|
|
|
|
|
fileData.createddocument = itemInfo.value.id
|
|
|
|
|
fileData.folder = (await supabase.from("folders").select("id").eq("tenant", profileStore.currentTenant).eq("function", itemInfo.value.type).eq("year",dayjs().format("YYYY")).single()).data.id
|
|
|
|
|
|
|
|
|
|
let tag = (await supabase.from("filetags").select("id").eq("tenant", profileStore.currentTenant).eq("createddocumenttype", itemInfo.value.type).single()).data
|
|
|
|
|
let mappedType = itemInfo.value.type
|
|
|
|
|
|
|
|
|
|
if(mappedType === "advanceInvoices" || mappedType === "cancellationInvoices"){
|
|
|
|
|
mappedType = "invoices"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileData.folder = (await supabase.from("folders").select("id").eq("tenant", profileStore.currentTenant).eq("function", mappedType).eq("year",dayjs().format("YYYY")).single()).data.id
|
|
|
|
|
|
|
|
|
|
let tag = (await supabase.from("filetags").select("id").eq("tenant", profileStore.currentTenant).eq("createddocumenttype", mappedType).single()).data
|
|
|
|
|
|
|
|
|
|
function dataURLtoFile(dataurl, filename) {
|
|
|
|
|
var arr = dataurl.split(","),
|
|
|
|
|
@@ -893,12 +930,14 @@ const setRowData = (row) => {
|
|
|
|
|
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
|
|
|
|
|
row.description = services.value.find(i => i.id === row.service).description
|
|
|
|
|
row.taxPercent = 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
|
|
|
|
|
row.description = products.value.find(i => i.id === row.product).description
|
|
|
|
|
row.taxPercent = products.value.find(i => i.id === row.product).taxPercentage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -956,14 +995,14 @@ const setRowData = (row) => {
|
|
|
|
|
|
|
|
|
|
<UAlert
|
|
|
|
|
class="my-5"
|
|
|
|
|
title="Vorhandene Probleme:"
|
|
|
|
|
title="Vorhandene Probleme und Informationen:"
|
|
|
|
|
:color="findDocumentErrors.filter(i => i.type === 'breaking').length > 0 ? 'rose' : 'white'"
|
|
|
|
|
variant="outline"
|
|
|
|
|
v-if="findDocumentErrors.length > 0"
|
|
|
|
|
>
|
|
|
|
|
<template #description>
|
|
|
|
|
<ul class="list-disc ml-5">
|
|
|
|
|
<li v-for="error in findDocumentErrors" :class="[...error.type === 'breaking' ? ['text-rose-600'] : ['text-gray-700']]">
|
|
|
|
|
<li v-for="error in findDocumentErrors" :class="[...error.type === 'breaking' ? ['text-rose-600'] : ['text-white']]">
|
|
|
|
|
{{error.message}}
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|