Rebuild Inovice LoadModes
This commit is contained in:
@@ -129,6 +129,9 @@ const setupPage = async () => {
|
|||||||
|
|
||||||
if(route.query.linkedDocuments) {
|
if(route.query.linkedDocuments) {
|
||||||
|
|
||||||
|
console.log(route.query.loadMode)
|
||||||
|
|
||||||
|
if(route.query.loadMode === "deliveryNotes") {
|
||||||
let linkedDocuments = (await supabase.from("createddocuments").select().in("id",JSON.parse(route.query.linkedDocuments))).data
|
let linkedDocuments = (await supabase.from("createddocuments").select().in("id",JSON.parse(route.query.linkedDocuments))).data
|
||||||
|
|
||||||
//TODO: Implement Checking for Same Customer, Contact and Project
|
//TODO: Implement Checking for Same Customer, Contact and Project
|
||||||
@@ -196,6 +199,62 @@ const setupPage = async () => {
|
|||||||
processDieselPosition()
|
processDieselPosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if(route.query.loadMode === "finalInvoice") {
|
||||||
|
let linkedDocuments = (await supabase.from("createddocuments").select().in("id",JSON.parse(route.query.linkedDocuments))).data
|
||||||
|
|
||||||
|
//TODO: Implement Checking for Same Customer, Contact and Project
|
||||||
|
|
||||||
|
console.log(linkedDocuments)
|
||||||
|
|
||||||
|
itemInfo.value.customer = linkedDocuments[0].customer
|
||||||
|
itemInfo.value.project = linkedDocuments[0].project
|
||||||
|
itemInfo.value.contact = linkedDocuments[0].contact
|
||||||
|
|
||||||
|
setCustomerData()
|
||||||
|
|
||||||
|
for await (const doc of linkedDocuments.filter(i => i.type === "confirmationOrders")) {
|
||||||
|
let linkedDocument = await useSupabaseSelectSingle("createddocuments",doc.id)
|
||||||
|
itemInfo.value.rows.push(...linkedDocument.rows)
|
||||||
|
}
|
||||||
|
|
||||||
|
for await (const doc of linkedDocuments.filter(i => i.type === "quotes")) {
|
||||||
|
let linkedDocument = await useSupabaseSelectSingle("createddocuments",doc.id)
|
||||||
|
itemInfo.value.rows.push(...linkedDocument.rows)
|
||||||
|
}
|
||||||
|
|
||||||
|
for await (const doc of linkedDocuments.filter(i => i.type === "advanceInvoices")) {
|
||||||
|
itemInfo.value.rows.push({
|
||||||
|
mode: "free",
|
||||||
|
text: `Abschlagsrechnung ${doc.documentNumber}`,
|
||||||
|
quantity: 1,
|
||||||
|
taxPercent: 19, // TODO TAX PERCENTAGE
|
||||||
|
discountPercent: 0,
|
||||||
|
unit: 10,
|
||||||
|
inputPrice: useSum().getCreatedDocumentSumDetailed(doc).totalNet *-1,
|
||||||
|
linkedEntitys: [
|
||||||
|
{
|
||||||
|
type: "createddocuments",
|
||||||
|
subtype: "advanceInvoices",
|
||||||
|
id: doc.id
|
||||||
|
}
|
||||||
|
],
|
||||||
|
editDisabled: true
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
updateCustomSurcharge()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setPosNumbers()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,6 +324,12 @@ const setupPage = async () => {
|
|||||||
row.price = row.price * -1
|
row.price = row.price * -1
|
||||||
})
|
})
|
||||||
|
|
||||||
|
itemInfo.value.documentDate = dayjs()
|
||||||
|
|
||||||
|
itemInfo.value.usedAdvanceInvoices = linkedDocument.usedAdvanceInvoices
|
||||||
|
|
||||||
|
checkForOpenAdvanceInvoices()
|
||||||
|
|
||||||
itemInfo.value.description = `Stornorechnung zu Rechnung ${linkedDocument.documentNumber} vom ${dayjs(linkedDocument.documentDate).format('DD.MM.YYYY')}`
|
itemInfo.value.description = `Stornorechnung zu Rechnung ${linkedDocument.documentNumber} vom ${dayjs(linkedDocument.documentDate).format('DD.MM.YYYY')}`
|
||||||
|
|
||||||
itemInfo.value.type = "cancellationInvoices"
|
itemInfo.value.type = "cancellationInvoices"
|
||||||
@@ -310,11 +375,12 @@ setupPage()
|
|||||||
const openAdvanceInvoices = ref([])
|
const openAdvanceInvoices = ref([])
|
||||||
const checkForOpenAdvanceInvoices = async () => {
|
const checkForOpenAdvanceInvoices = async () => {
|
||||||
console.log("Check for Open Advance Invoices")
|
console.log("Check for Open Advance Invoices")
|
||||||
const {data,error} = await supabase.from("createddocuments").select().eq("project", itemInfo.value.project).eq("advanceInvoiceResolved", false).eq("type","advanceInvoices")
|
const {data} = await supabase.from("createddocuments").select().eq("project", itemInfo.value.project).eq("advanceInvoiceResolved", false).eq("type","advanceInvoices")
|
||||||
|
const {data: usedAdvanceInvoices} = await supabase.from("createddocuments").select().in("id", itemInfo.value.usedAdvanceInvoices)
|
||||||
|
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
|
||||||
openAdvanceInvoices.value = data
|
openAdvanceInvoices.value = [...data, ...usedAdvanceInvoices.filter(i => !data.find(x => x.id === i.id))]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +553,8 @@ const addPosition = (mode) => {
|
|||||||
inputPrice: 0,
|
inputPrice: 0,
|
||||||
price: 0,
|
price: 0,
|
||||||
taxPercent: taxPercentage,
|
taxPercent: taxPercentage,
|
||||||
discountPercent: 0
|
discountPercent: 0,
|
||||||
|
linkedEntitys: []
|
||||||
}
|
}
|
||||||
|
|
||||||
itemInfo.value.rows.push({...rowData, ...profileStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
itemInfo.value.rows.push({...rowData, ...profileStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
||||||
@@ -501,7 +568,8 @@ const addPosition = (mode) => {
|
|||||||
price: 0,
|
price: 0,
|
||||||
taxPercent: taxPercentage,
|
taxPercent: taxPercentage,
|
||||||
discountPercent: 0,
|
discountPercent: 0,
|
||||||
unit: 1
|
unit: 1,
|
||||||
|
linkedEntitys: []
|
||||||
})
|
})
|
||||||
} else if(mode === 'service'){
|
} else if(mode === 'service'){
|
||||||
let rowData = {
|
let rowData = {
|
||||||
@@ -512,7 +580,8 @@ const addPosition = (mode) => {
|
|||||||
price: 0,
|
price: 0,
|
||||||
taxPercent: taxPercentage,
|
taxPercent: taxPercentage,
|
||||||
discountPercent: 0,
|
discountPercent: 0,
|
||||||
unit: 1
|
unit: 1,
|
||||||
|
linkedEntitys: []
|
||||||
}
|
}
|
||||||
|
|
||||||
//Push Agriculture Holder only if Module is activated
|
//Push Agriculture Holder only if Module is activated
|
||||||
@@ -521,16 +590,19 @@ const addPosition = (mode) => {
|
|||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
mode: "pagebreak",
|
mode: "pagebreak",
|
||||||
|
linkedEntitys: []
|
||||||
})
|
})
|
||||||
} else if(mode === "title") {
|
} else if(mode === "title") {
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
mode: "title",
|
mode: "title",
|
||||||
|
linkedEntitys: []
|
||||||
})
|
})
|
||||||
} else if(mode === "text") {
|
} else if(mode === "text") {
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
mode: "text",
|
mode: "text",
|
||||||
|
linkedEntitys: []
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -692,7 +764,22 @@ const documentTotal = computed(() => {
|
|||||||
|
|
||||||
console.log(totalGrossAlreadyPaid)
|
console.log(totalGrossAlreadyPaid)
|
||||||
|
|
||||||
let sumToPay = totalGross - totalGrossAlreadyPaid
|
let sumToPay = 0
|
||||||
|
|
||||||
|
if(itemInfo.value.type === "invoices") {
|
||||||
|
sumToPay = totalGross - totalGrossAlreadyPaid
|
||||||
|
} else if(itemInfo.value.type === "cancellationInvoices") {
|
||||||
|
sumToPay = totalGross + totalGrossAlreadyPaid
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
titleSums: titleSums,
|
titleSums: titleSums,
|
||||||
@@ -2083,6 +2170,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
<UIcon
|
<UIcon
|
||||||
class="handle"
|
class="handle"
|
||||||
name="i-mdi-menu"
|
name="i-mdi-menu"
|
||||||
|
v-if="itemInfo.type !== 'cancellationInvoices'"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
@@ -2113,6 +2201,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
v-if="row.mode === 'free'"
|
v-if="row.mode === 'free'"
|
||||||
>
|
>
|
||||||
<UInput
|
<UInput
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices' || row.editDisabled"
|
||||||
v-model="row.text"
|
v-model="row.text"
|
||||||
placeholder="Name"
|
placeholder="Name"
|
||||||
class="min-w-40"
|
class="min-w-40"
|
||||||
@@ -2124,6 +2213,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
>
|
>
|
||||||
<InputGroup class="w-full">
|
<InputGroup class="w-full">
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
class="w-60"
|
class="w-60"
|
||||||
:options="products"
|
:options="products"
|
||||||
:color="row.product ? 'primary' : 'rose'"
|
:color="row.product ? 'primary' : 'rose'"
|
||||||
@@ -2193,6 +2283,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
>
|
>
|
||||||
<InputGroup class="w-full">
|
<InputGroup class="w-full">
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
class="w-60"
|
class="w-60"
|
||||||
:options="services"
|
:options="services"
|
||||||
:color="row.service ? 'primary' : 'rose'"
|
:color="row.service ? 'primary' : 'rose'"
|
||||||
@@ -2259,6 +2350,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
>
|
>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="row.quantity"
|
v-model="row.quantity"
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
type="number"
|
type="number"
|
||||||
:step="dataStore.units.find(i => i.id === row.unit) ? dataStore.units.find(i => i.id === row.unit).step : '1' "
|
:step="dataStore.units.find(i => i.id === row.unit) ? dataStore.units.find(i => i.id === row.unit).step : '1' "
|
||||||
|
|
||||||
@@ -2270,6 +2362,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="row.unit"
|
v-model="row.unit"
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
:options="dataStore.units"
|
:options="dataStore.units"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
@@ -2285,6 +2378,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
>
|
>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="row.inputPrice"
|
v-model="row.inputPrice"
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
type="number"
|
type="number"
|
||||||
step="0.001"
|
step="0.001"
|
||||||
@change="updateCustomSurcharge"
|
@change="updateCustomSurcharge"
|
||||||
@@ -2348,10 +2442,12 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
||||||
>
|
>
|
||||||
<UButton
|
<UButton
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
icon="i-heroicons-pencil-square-16-solid"
|
icon="i-heroicons-pencil-square-16-solid"
|
||||||
@click="row.showEdit = true"
|
@click="row.showEdit = true"
|
||||||
/>
|
/>
|
||||||
<UButton
|
<UButton
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
icon="i-mdi-water-drop-outline"
|
icon="i-mdi-water-drop-outline"
|
||||||
class="ml-3"
|
class="ml-3"
|
||||||
v-if="row.agriculture"
|
v-if="row.agriculture"
|
||||||
@@ -2370,6 +2466,36 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
<UButton color="gray" variant="ghost" icon="i-heroicons-x-mark-20-solid" class="-my-1" @click="row.showEdit = false" />
|
<UButton color="gray" variant="ghost" icon="i-heroicons-x-mark-20-solid" class="-my-1" @click="row.showEdit = false" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<InputGroup>
|
||||||
|
<UFormGroup
|
||||||
|
label="Anzahl:"
|
||||||
|
class="flex-auto"
|
||||||
|
>
|
||||||
|
<UInput
|
||||||
|
v-model="row.quantity"
|
||||||
|
type="number"
|
||||||
|
:step="dataStore.units.find(i => i.id === row.unit) ? dataStore.units.find(i => i.id === row.unit).step : '1' "
|
||||||
|
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
|
<UFormGroup
|
||||||
|
label="Einheit:"
|
||||||
|
class="flex-auto"
|
||||||
|
>
|
||||||
|
<USelectMenu
|
||||||
|
v-model="row.unit"
|
||||||
|
:options="dataStore.units"
|
||||||
|
option-attribute="name"
|
||||||
|
|
||||||
|
value-attribute="id"
|
||||||
|
>
|
||||||
|
<template #label>
|
||||||
|
{{dataStore.units.find(i => i.id === row.unit) ? dataStore.units.find(i => i.id === row.unit).name : "Keine Einheit gewählt"}}
|
||||||
|
</template>
|
||||||
|
</USelectMenu>
|
||||||
|
</UFormGroup>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Einzelpreis:"
|
label="Einzelpreis:"
|
||||||
v-if="itemInfo.type !== 'deliveryNotes'"
|
v-if="itemInfo.type !== 'deliveryNotes'"
|
||||||
@@ -2455,6 +2581,26 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
<UAlert
|
||||||
|
v-if="row.linkedEntitys && row.linkedEntitys.find(i => i.type === 'createddocuments' && i.subtype === 'advanceInvoices')"
|
||||||
|
title="Berechnung des Individuellen Aufschlags für die Zeile gesperrt"
|
||||||
|
color="orange"
|
||||||
|
variant="subtle"
|
||||||
|
class="my-3"
|
||||||
|
/>
|
||||||
|
|
||||||
|
Verknüpfungen:
|
||||||
|
<ul>
|
||||||
|
<li
|
||||||
|
v-for="linkedEntity in row.linkedEntitys"
|
||||||
|
>
|
||||||
|
- <a
|
||||||
|
v-if="linkedEntity.subtype === 'advanceInvoices'"
|
||||||
|
:to="`/createddocuments/show/${linkedEntity.id}`"
|
||||||
|
>Abschlagsrechnung</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Beschreibung:"
|
label="Beschreibung:"
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
@@ -2569,12 +2715,14 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
colspan="6"
|
colspan="6"
|
||||||
>
|
>
|
||||||
<UInput
|
<UInput
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
v-model="row.text"
|
v-model="row.text"
|
||||||
placeholder="Titel"
|
placeholder="Titel"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<UButton
|
<UButton
|
||||||
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
color="rose"
|
color="rose"
|
||||||
icon="i-heroicons-x-mark-16-solid"
|
icon="i-heroicons-x-mark-16-solid"
|
||||||
@@ -2597,39 +2745,42 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
<UButton
|
<UButton
|
||||||
@click="addPosition('service')"
|
@click="addPosition('service')"
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
:disabled="itemInfo.type === 'advanceInvoices'"
|
:disabled="['advanceInvoices','cancellationInvoices'].includes(itemInfo.type)"
|
||||||
>
|
>
|
||||||
+ Leistung
|
+ Leistung
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="addPosition('normal')"
|
@click="addPosition('normal')"
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
:disabled="itemInfo.type === 'advanceInvoices'"
|
:disabled="['advanceInvoices','cancellationInvoices'].includes(itemInfo.type)"
|
||||||
>
|
>
|
||||||
+ Artikel
|
+ Artikel
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="addPosition('free')"
|
@click="addPosition('free')"
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
:disabled="itemInfo.type === 'advanceInvoices'"
|
:disabled="['advanceInvoices','cancellationInvoices'].includes(itemInfo.type)"
|
||||||
>
|
>
|
||||||
+ Freie Position
|
+ Freie Position
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="addPosition('pagebreak')"
|
@click="addPosition('pagebreak')"
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
|
:disabled="['advanceInvoices','cancellationInvoices'].includes(itemInfo.type)"
|
||||||
>
|
>
|
||||||
+ Seitenumbruch
|
+ Seitenumbruch
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="addPosition('title')"
|
@click="addPosition('title')"
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
|
:disabled="['advanceInvoices','cancellationInvoices'].includes(itemInfo.type)"
|
||||||
>
|
>
|
||||||
+ Titel
|
+ Titel
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="addPosition('text')"
|
@click="addPosition('text')"
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
|
:disabled="['advanceInvoices','cancellationInvoices'].includes(itemInfo.type)"
|
||||||
>
|
>
|
||||||
+ Text
|
+ Text
|
||||||
</UButton>
|
</UButton>
|
||||||
@@ -2637,7 +2788,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
|
|
||||||
<UDivider
|
<UDivider
|
||||||
class="mt-5 mb-3"
|
class="mt-5 mb-3"
|
||||||
v-if="openAdvanceInvoices.length > 0"
|
v-if="openAdvanceInvoices.length > 0 || itemInfo.usedAdvanceInvoices.length > 0"
|
||||||
>
|
>
|
||||||
Noch nicht abgerechnete Abschlagsrechnungen
|
Noch nicht abgerechnete Abschlagsrechnungen
|
||||||
</UDivider>
|
</UDivider>
|
||||||
|
|||||||
Reference in New Issue
Block a user