diff --git a/components/EntityEdit.vue b/components/EntityEdit.vue index 49f4342..e94fd53 100644 --- a/components/EntityEdit.vue +++ b/components/EntityEdit.vue @@ -12,6 +12,7 @@ const props = defineProps({ } }) + const {type} = props defineShortcuts({ @@ -40,9 +41,12 @@ const supabase = useSupabaseClient() const dataType = dataStore.dataTypes[type] const openTab = ref(0) +const item = ref(JSON.parse(props.item)) +console.log(item.value) + const oldItem = ref(null) const generateOldItemData = () => { - oldItem.value = JSON.parse(JSON.stringify(props.item)) + oldItem.value = JSON.parse(props.item) } generateOldItemData() @@ -50,14 +54,14 @@ generateOldItemData() const setupCreate = () => { dataType.templateColumns.forEach(datapoint => { if(datapoint.key.includes(".")){ - props.item[datapoint.key.split(".")[0]] = {} + !item.value[datapoint.key.split(".")[0]] ? item.value[datapoint.key.split(".")[0]] = {} : null } if(datapoint.inputType === "editor") { if(datapoint.key.includes(".")){ - props.item[datapoint.key.split(".")[0]][datapoint.key.split(".")[1]] = {} + item[datapoint.key.split(".")[0]][datapoint.key.split(".")[1]] = {} } else { - props.item[datapoint.key] = {} + item[datapoint.key] = {} } @@ -72,9 +76,9 @@ const setupQuery = () => { Object.keys(route.query).forEach(key => { if(["customer","contract","plant","contact"].includes(key)){ - props.item[key] = Number(route.query[key]) + item[key] = Number(route.query[key]) } else { - props.item[key] = route.query[key] + item[key] = route.query[key] } }) } @@ -99,7 +103,7 @@ const loadOptions = async () => { loadedOptions.value[option.option] = (await useSupabaseSelect(option.option)) if(dataType.templateColumns.find(x => x.key === option.key).selectDataTypeFilter){ - loadedOptions.value[option.option] = loadedOptions.value[option.option].filter(i => dataType.templateColumns.find(x => x.key === option.key).selectDataTypeFilter(i, props.item)) + loadedOptions.value[option.option] = loadedOptions.value[option.option].filter(i => dataType.templateColumns.find(x => x.key === option.key).selectDataTypeFilter(i, item)) } } } @@ -109,13 +113,13 @@ loadOptions() const contentChanged = (content, datapoint) => { if(datapoint.key.includes(".")){ - props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].html = content.html - props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].text = content.text - props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].json = content.json + item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].html = content.html + item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].text = content.text + item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].json = content.json } else { - props.item[datapoint.key].html = content.html - props.item[datapoint.key].text = content.text - props.item[datapoint.key].json = content.json + item[datapoint.key].html = content.html + item[datapoint.key].text = content.text + item[datapoint.key].json = content.json } } @@ -136,25 +140,25 @@ const contentChanged = (content, datapoint) => {
+ > + + { @@ -247,29 +255,33 @@ const contentChanged = (content, datapoint) => {
+ > + + {
{ >
@@ -346,29 +358,33 @@ const contentChanged = (content, datapoint) => {
+ > + + { @@ -408,29 +424,33 @@ const contentChanged = (content, datapoint) => {
+ > + + {
{ >
diff --git a/components/EntityShow.vue b/components/EntityShow.vue index 5d7d55c..a93ea5c 100644 --- a/components/EntityShow.vue +++ b/components/EntityShow.vue @@ -151,6 +151,9 @@ const changeActivePhase = async (key) => { + + + { v-model="openTab" > @@ -392,4 +399,10 @@ td { padding-bottom: 0.15em; padding-top: 0.15em; } + +.scroll { + height: 80vh; + overflow-y: scroll; + padding: 1em; +} \ No newline at end of file diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 1a5cd39..5795fe5 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -63,7 +63,7 @@ const itemInfo = ref({ const letterheads = ref([]) -const createdDocuments = ref([]) +const createddocuments = ref([]) const projects = ref([]) const products = ref([]) const productcategories = ref([]) @@ -79,14 +79,13 @@ 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","*")) + createddocuments.value = (await useSupabaseSelect("createddocuments","*")) projects.value = (await useSupabaseSelect("projects","*")) services.value = (await useSupabaseSelect("services","*")) servicecategories.value = (await useSupabaseSelect("servicecategories","*")) products.value = (await useSupabaseSelect("products","*")) productcategories.value = (await useSupabaseSelect("productcategories","*")) customers.value = (await useSupabaseSelect("customers","*","customerNumber")) - console.log(customers.value) contacts.value = (await useSupabaseSelect("contacts","*")) texttemplates.value = (await useSupabaseSelect("texttemplates","*")) if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id @@ -175,7 +174,6 @@ const setupPage = async () => { if(route.query.project) { itemInfo.value.project = Number(route.query.project) - checkForOpenAdvanceInvoices() } if(route.query.contact) itemInfo.value.contact = Number(route.query.contact) if(route.query.customer) { @@ -184,6 +182,8 @@ const setupPage = async () => { } } + //if(itemInfo.value.project) checkForOpenAdvanceInvoices() + loaded.value = true } @@ -238,6 +238,9 @@ const setCustomerData = () => { itemInfo.value.address.zip = customer.infoData.zip itemInfo.value.address.city = customer.infoData.city itemInfo.value.address.special = customer.infoData.special + + if(customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays + } @@ -458,7 +461,7 @@ const documentTotal = computed(() => { let totalGrossAlreadyPaid = 0 itemInfo.value.usedAdvanceInvoices.forEach(advanceInvoiceId => { - let advanceInvoice = openAdvanceInvoices.value.find(i => i.id === advanceInvoiceId) + let advanceInvoice = createddocuments.value.find(i => i.id === advanceInvoiceId) let priceNet = advanceInvoice.rows.find(i => i.advanceInvoiceData).price @@ -474,11 +477,11 @@ const documentTotal = computed(() => { return { - totalNet: renderCurrency(totalNet), - total19: renderCurrency(total19), - totalGross: renderCurrency(totalGross), - totalGrossAlreadyPaid: renderCurrency(totalGrossAlreadyPaid), - totalSumToPay: renderCurrency(sumToPay) + totalNet: totalNet, + total19: total19, + totalGross: totalGross, + totalGrossAlreadyPaid: totalGrossAlreadyPaid, + totalSumToPay: sumToPay } @@ -532,7 +535,7 @@ const processDieselPosition = () => { const getDocumentData = () => { - let customerData = customers.find(i => i.id === itemInfo.value.customer) + let customerData = customers.value.find(i => i.id === itemInfo.value.customer) let contactData = dataStore.getContactById(itemInfo.value.contact) let businessInfo = profileStore.ownTenant.businessInfo @@ -549,12 +552,14 @@ const getDocumentData = () => { let unit = dataStore.units.find(i => i.id === row.unit) if(!['pagebreak','title'].includes(row.mode)){ - if(row.agriculture?.description) { + if(row.agriculture && row.agriculture.description) { console.log("Row has Agri") row.descriptionText = row.agriculture.description } else if(row.description) { console.log("Row has no Agri") row.descriptionText = row.description + } else { + delete row.descriptionText } } @@ -591,6 +596,8 @@ const getDocumentData = () => { } } + let contactPerson = profileStore.getProfileById(itemInfo.value.contactPerson) + const returnData = { type: itemInfo.value.type, adressLine: `${businessInfo.name}, ${businessInfo.street}, ${businessInfo.zip} ${businessInfo.city}`, @@ -609,9 +616,9 @@ const getDocumentData = () => { documentDate: dayjs(itemInfo.value.documentDate).format("DD.MM.YYYY"), deliveryDate: dayjs(itemInfo.value.deliveryDate).format("DD.MM.YYYY"), deliveryDateType: itemInfo.value.deliveryDateType, - contactPerson: itemInfo.value.contactPersonName, - contactTel: itemInfo.value.contactTel, - contactEMail: itemInfo.value.contactEMail, + contactPerson: contactPerson.fullName, + contactTel: contactPerson.fixedTel || contactPerson.mobileTel, + contactEMail: contactPerson.email, project: dataStore.getProjectById(itemInfo.value.project) ? dataStore.getProjectById(itemInfo.value.project).name : null }, title: itemInfo.value.title, @@ -619,14 +626,20 @@ const getDocumentData = () => { endText: templateEndText(generateContext(itemInfo.value, contactData)), startText: templateStartText(generateContext(itemInfo.value, contactData)), rows: rows, - total: documentTotal.value, + total: { + totalNet: renderCurrency(documentTotal.value.totalNet), + total19: renderCurrency(documentTotal.value.total19), + totalGross: renderCurrency(documentTotal.value.totalGross), + totalGrossAlreadyPaid: renderCurrency(documentTotal.value.totalGrossAlreadyPaid), + totalSumToPay: renderCurrency(documentTotal.value.totalSumToPay) + }, agriculture: itemInfo.value.agriculture, usedAdvanceInvoices: itemInfo.value.usedAdvanceInvoices.map(i => { - return openAdvanceInvoices.value.find(x => x.id === i) + return createddocuments.value.find(x => x.id === i) }) } - //console.log(returnData) + console.log(returnData) return returnData } @@ -715,7 +728,7 @@ const saveSerialInvoice = async () => { await router.push(`/createDocument/edit/${data[0].id}`) } -const saveDocument = async (state) => { +const saveDocument = async (state,resetup = false) => { itemInfo.value.state = state @@ -788,21 +801,22 @@ const saveDocument = async (state) => { if(route.params.id) { await dataStore.updateItem("createddocuments", {...createData, id: itemInfo.value.id}) } else { - const {data} = await dataStore.createNewItem("createddocuments", createData) + const data = await dataStore.createNewItem("createddocuments", createData) + console.log(data) await router.push(`/createDocument/edit/${data[0].id}`) } - await setupPage() - + if(resetup) await setupPage() } const closeDocument = async () => { + loaded.value = false + await saveDocument("Gebucht") await generateDocument() - let fileData = { tags: [], project: null @@ -828,14 +842,12 @@ const closeDocument = async () => { await dataStore.uploadFiles(fileData, [file], true) - - await router.push(`/createDocument/show/${itemInfo.value.id}`) - //console.log(uri) } const setRowData = (row) => { + console.log(row) 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 @@ -859,7 +871,7 @@ const setRowData = (row) => {