Added Contract to Createddocuments

This commit is contained in:
2025-10-05 16:56:41 +02:00
parent 473980d6b4
commit 008d96d0b8

View File

@@ -74,6 +74,7 @@ const servicecategories = ref([])
const selectedServicecategorie = ref(null) const selectedServicecategorie = ref(null)
const customers = ref([]) const customers = ref([])
const contacts = ref([]) const contacts = ref([])
const contracts = ref([])
const texttemplates = ref([]) const texttemplates = ref([])
const units = ref([]) const units = ref([])
const tenantUsers = ref([]) const tenantUsers = ref([])
@@ -89,6 +90,7 @@ const setupData = async () => {
productcategories.value = await useEntities("productcategories").select("*") productcategories.value = await useEntities("productcategories").select("*")
customers.value = await useEntities("customers").select("*", "customerNumber") customers.value = await useEntities("customers").select("*", "customerNumber")
contacts.value = await useEntities("contacts").select("*") contacts.value = await useEntities("contacts").select("*")
contracts.value = await useEntities("contracts").select("*")
texttemplates.value = await useEntities("texttemplates").select("*") texttemplates.value = await useEntities("texttemplates").select("*")
units.value = await useEntities("units").selectSpecial("*") units.value = await useEntities("units").selectSpecial("*")
tenantUsers.value = (await useNuxtApp().$api(`/api/tenant/users`, { tenantUsers.value = (await useNuxtApp().$api(`/api/tenant/users`, {
@@ -1158,6 +1160,10 @@ const getDocumentData = async () => {
...itemInfo.value.project ? [{ ...itemInfo.value.project ? [{
label: "Projekt", label: "Projekt",
content: projects.value.find(i => i.id === itemInfo.value.project).name content: projects.value.find(i => i.id === itemInfo.value.project).name
}] : [],
...itemInfo.value.contract ? [{
label: "Vertrag",
content: contracts.value.find(i => i.id === itemInfo.value.contract).contractNumber
}] : [] }] : []
], ],
title: itemInfo.value.title, title: itemInfo.value.title,
@@ -1259,6 +1265,7 @@ const saveSerialInvoice = async () => {
state: 'Erstellt', state: 'Erstellt',
customer: itemInfo.value.customer, customer: itemInfo.value.customer,
contact: itemInfo.value.contact, contact: itemInfo.value.contact,
contract: itemInfo.value.contract,
address: itemInfo.value.address, address: itemInfo.value.address,
project: itemInfo.value.project, project: itemInfo.value.project,
paymentDays: itemInfo.value.paymentDays, paymentDays: itemInfo.value.paymentDays,
@@ -1342,6 +1349,7 @@ const saveDocument = async (state, resetup = false) => {
state: itemInfo.value.state || "Entwurf", state: itemInfo.value.state || "Entwurf",
customer: itemInfo.value.customer, customer: itemInfo.value.customer,
contact: itemInfo.value.contact, contact: itemInfo.value.contact,
contract: itemInfo.value.contract,
address: itemInfo.value.address, address: itemInfo.value.address,
project: itemInfo.value.project, project: itemInfo.value.project,
plant: itemInfo.value.plant, plant: itemInfo.value.plant,
@@ -2097,6 +2105,45 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
</InputGroup> </InputGroup>
</UFormGroup> </UFormGroup>
<UFormGroup
label="Vertrag:"
>
<InputGroup>
<USelectMenu
:options="contracts.filter(i => i.customer === itemInfo.customer && (itemInfo.plant ? itemInfo.plant === i.plant : true))"
v-model="itemInfo.contract"
value-attribute="id"
option-attribute="name"
searchable
searchable-placeholder="Suche..."
:search-attributes="['contractNumber','name']"
class="w-full"
:disabled="!itemInfo.customer"
>
<template #label>
{{ itemInfo.contract ? contracts.find(i => i.id === itemInfo.contract).name : "Kein Vertrag ausgewählt" }}
</template>
<template #option="{option: contract}">
{{ customers.find(i => i.id === contract.customer) ? customers.find(i => i.id === contract.customer).name : "" }}
- {{ contract.contractNumber }} - {{ contract.name }}
</template>
</USelectMenu>
<UButton
variant="outline"
color="rose"
v-if="itemInfo.project"
icon="i-heroicons-x-mark"
@click="itemInfo.project = null"
/>
<EntityModalButtons
type="projects"
:id="itemInfo.project"
:create-query="{customer: itemInfo.customer, plant: itemInfo.plant}"
@return-data="(data) => itemInfo.project = data.id"
/>
</InputGroup>
</UFormGroup>
</div> </div>
</InputGroup> </InputGroup>