diff --git a/components/PDFViewer.client.vue b/components/PDFViewer.client.vue index 2dffbf3..1ac1946 100644 --- a/components/PDFViewer.client.vue +++ b/components/PDFViewer.client.vue @@ -168,6 +168,7 @@ watch(downloadControl, (downloadCtrl) => { variant="outline" > { } + const dataURLtoFile = (dataurl:string, filename:string) => { + let arr = dataurl.split(","), + //@ts-ignore + mime = arr[0].match(/:(.*?);/)[1], + bstr = atob(arr[arr.length - 1]), + n = bstr.length, + u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + return new File([u8arr], filename, {type: mime}); + } - return {uploadFiles, selectDocuments, selectSomeDocuments, selectDocument, downloadFile} + + return {uploadFiles, selectDocuments, selectSomeDocuments, selectDocument, downloadFile, dataURLtoFile} } \ No newline at end of file diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 82c3659..047fa9c 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -661,7 +661,7 @@ const findDocumentErrors = computed(() => { if (itemInfo.value.rows.length === 0) { errors.push({message: "Es sind keine Positionen angegeben", type: "breaking"}) } else { - itemInfo.value.rows.forEach(row => { + itemInfo.value.rows.forEach((row,index) => { if (itemInfo.value.type !== "quotes" && row.optional) { errors.push({ @@ -717,6 +717,10 @@ const findDocumentErrors = computed(() => { } } + if (index === itemInfo.value.rows.length - 1 && row.mode === "pagebreak") { + errors.push({message: `Die letze Position darf kein Seitenumbruch sein`, type: "breaking"}) + } + }) } diff --git a/pages/incomingInvoices/edit/[id].vue b/pages/incomingInvoices/[mode]/[id].vue similarity index 89% rename from pages/incomingInvoices/edit/[id].vue rename to pages/incomingInvoices/[mode]/[id].vue index dc033b3..319fc26 100644 --- a/pages/incomingInvoices/edit/[id].vue +++ b/pages/incomingInvoices/[mode]/[id].vue @@ -32,6 +32,8 @@ const costcentres = ref([]) const vendors = ref([]) const accounts = ref([]) +const mode = ref(route.params.mode) + const setup = async () => { let filetype = (await useEntities("filetags").select()).find(i=> i.incomingDocumentType === "invoices").id console.log(filetype) @@ -43,6 +45,8 @@ const setup = async () => { itemInfo.value = await useEntities("incominginvoices").selectSingle(route.params.id, "*, files(*)") await loadFile(itemInfo.value.files[itemInfo.value.files.length-1].id) + if(itemInfo.value.date && !itemInfo.value.dueDate) itemInfo.value.dueDate = itemInfo.value.date + } setup() @@ -143,7 +147,7 @@ const findIncomingInvoiceErrors = computed(() => { let errors = [] if(itemInfo.value.vendor === null) errors.push({message: "Es ist kein Lieferant ausgewählt", type: "breaking"}) - if(itemInfo.value.reference === null) errors.push({message: "Es ist keine Referenz angegeben", type: "breaking"}) + if(itemInfo.value.reference === null || itemInfo.value.reference.length === 0) errors.push({message: "Es ist keine Referenz angegeben", type: "breaking"}) if(itemInfo.value.date === null) errors.push({message: "Es ist kein Datum ausgewählt", type: "breaking"}) if(itemInfo.value.dueDate === null) errors.push({message: "Es ist kein Fälligkeitsdatum ausgewählt", type: "breaking"}) if(itemInfo.value.paymentType === null) errors.push({message: "Es ist keine Zahlart ausgewählt", type: "breaking"}) @@ -168,21 +172,38 @@ const findIncomingInvoiceErrors = computed(() => {