Added AI Suggestion to IncomingInvoice Create
This commit is contained in:
@@ -101,6 +101,26 @@ export const useFunctions = () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const useGetInvoiceData = async (file) => {
|
||||||
|
const {data:{session:{access_token}}} = await supabase.auth.getSession()
|
||||||
|
|
||||||
|
const {data} = await axios({
|
||||||
|
method: "POST",
|
||||||
|
url: `${baseURL}/functions/getinvoicedatafromgpt`,
|
||||||
|
data: {
|
||||||
|
file
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${access_token}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const useSendTelegramNotification = async (message) => {
|
const useSendTelegramNotification = async (message) => {
|
||||||
const {data:{session:{access_token}}} = await supabase.auth.getSession()
|
const {data:{session:{access_token}}} = await supabase.auth.getSession()
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,127 @@ const setCostCentre = async (item,data) => {
|
|||||||
item.costCentre = data.id
|
item.costCentre = data.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gptLoading = ref(false)
|
||||||
|
|
||||||
|
const getInvoiceData = async () => {
|
||||||
|
gptLoading.value = true
|
||||||
|
console.log(loadedFile.value)
|
||||||
|
|
||||||
|
|
||||||
|
//loadedFile.value.url
|
||||||
|
|
||||||
|
|
||||||
|
/*let data = {
|
||||||
|
"invoice_number": "3423478673",
|
||||||
|
"invoice_date": "2025-05-30",
|
||||||
|
"invoice_type": "incoming",
|
||||||
|
"delivery_type": "null",
|
||||||
|
"delivery_note_number": "null",
|
||||||
|
"reference": "null",
|
||||||
|
"issuer": {
|
||||||
|
"name": "Boels Rental Germany GmbH",
|
||||||
|
"address": "Emeranstraße 49-51, 85622 Feldkirchen, Deutschland",
|
||||||
|
"phone": "+49-(0)1801663225",
|
||||||
|
"email": "fakturierung@boels.de",
|
||||||
|
"bank": "ABN AMRO Bank N.V.",
|
||||||
|
"bic": "ABNANL2A",
|
||||||
|
"iban": "NL09 ABNA 0520 5585 61"
|
||||||
|
},
|
||||||
|
"recipient": {
|
||||||
|
"name": "Federspiel Technology UG",
|
||||||
|
"address": "Am Schwarzen Brack 14, 26452 Sande, Deutschland",
|
||||||
|
"phone": "null",
|
||||||
|
"email": "null"
|
||||||
|
},
|
||||||
|
"invoice_items": [
|
||||||
|
{
|
||||||
|
"description": "Bautrockner 50 ltr.",
|
||||||
|
"unit": "piece",
|
||||||
|
"quantity": 1,
|
||||||
|
"total": 395.22
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Servicepauschale Kat. A",
|
||||||
|
"unit": "piece",
|
||||||
|
"quantity": 1,
|
||||||
|
"total": 32.1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Haftungsbegrenzung A: (Schäden, exkl. Feuer/Diebstahl/Einbruch)",
|
||||||
|
"unit": "piece",
|
||||||
|
"quantity": 1,
|
||||||
|
"total": 3.2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Haftungsbegrenzung B: (Feuer/Diebstahl/Einbruch)",
|
||||||
|
"unit": "piece",
|
||||||
|
"quantity": 1,
|
||||||
|
"total": 16.93
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"subtotal": 89.1,
|
||||||
|
"tax_rate": 19,
|
||||||
|
"tax": 16.93,
|
||||||
|
"total": 106.03,
|
||||||
|
"terms": "Dieser Betrag wird automatisch mittels Lastschrift von ihrem Konto eingezogen"
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(data)
|
||||||
|
console.log(data.subtotal)*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let data = await useFunctions().useGetInvoiceData(loadedFile.value)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(data.invoice_number) itemInfo.value.reference = data.invoice_number
|
||||||
|
if(data.invoice_date) itemInfo.value.date = dayjs(data.invoice_date)
|
||||||
|
if(data.issuer.id) itemInfo.value.vendor = data.issuer.id
|
||||||
|
if(data.invoice_duedate) itemInfo.value.dueDate = dayjs(data.invoice_duedate)
|
||||||
|
if(data.terms) itemInfo.value.paymentType = data.terms
|
||||||
|
if(data.subtotal) {
|
||||||
|
itemInfo.value.accounts = [
|
||||||
|
{
|
||||||
|
account: null,
|
||||||
|
amountNet: data.subtotal,
|
||||||
|
amountTax: data.tax,
|
||||||
|
taxType: String(data.tax_rate),
|
||||||
|
costCentre: null,
|
||||||
|
amountGross: Number(data.subtotal) + Number(data.tax)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.terms === "Direct Debit") {
|
||||||
|
itemInfo.value.paymentType = "Einzug"
|
||||||
|
} else if(data.terms === "Transfer") {
|
||||||
|
itemInfo.value.paymentType = "Überweisung"
|
||||||
|
} else if(data.terms === "Credit Card") {
|
||||||
|
itemInfo.value.paymentType = "Kreditkarte"
|
||||||
|
} else if(data.terms === "Other") {
|
||||||
|
itemInfo.value.paymentType = "Sonstiges"
|
||||||
|
}
|
||||||
|
|
||||||
|
let description = ""
|
||||||
|
|
||||||
|
if(data.delivery_note_number) description += `Lieferschein: ${data.delivery_note_number} \n`
|
||||||
|
if(data.reference) description += `Referenz: ${data.reference} \n`
|
||||||
|
if(data.invoice_items) {
|
||||||
|
data.invoice_items.forEach(item => {
|
||||||
|
description += `${item.description} - ${item.quantity} ${item.unit} - ${item.total}\n`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
itemInfo.value.description = description
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gptLoading.value = false
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -204,6 +325,17 @@ const setCostCentre = async (item,data) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else class=" scrollContainer">
|
<div v-else class=" scrollContainer">
|
||||||
|
<UButton
|
||||||
|
icon="i-heroicons-sparkles"
|
||||||
|
class="my-3"
|
||||||
|
variant="outline"
|
||||||
|
@click="getInvoiceData"
|
||||||
|
:disabled="gptLoading"
|
||||||
|
>
|
||||||
|
KI - Vorschlag
|
||||||
|
<UProgress v-if="gptLoading" animation="carousel"/>
|
||||||
|
</UButton>
|
||||||
|
|
||||||
<InputGroup class="mb-3">
|
<InputGroup class="mb-3">
|
||||||
<UButton
|
<UButton
|
||||||
:variant="itemInfo.expense ? 'solid' : 'outline'"
|
:variant="itemInfo.expense ? 'solid' : 'outline'"
|
||||||
@@ -431,7 +563,7 @@ const setCostCentre = async (item,data) => {
|
|||||||
:color="!item.amountNet ? 'rose' : 'primary'"
|
:color="!item.amountNet ? 'rose' : 'primary'"
|
||||||
:disabled="item.taxType === null"
|
:disabled="item.taxType === null"
|
||||||
@keyup="item.amountTax = Number((item.amountNet * (Number(taxOptions.find(i => i.key === item.taxType).percentage)/100)).toFixed(2)),
|
@keyup="item.amountTax = Number((item.amountNet * (Number(taxOptions.find(i => i.key === item.taxType).percentage)/100)).toFixed(2)),
|
||||||
item.amountGross = Number(item.amountNet) + NUmber(item.amountTax)"
|
item.amountGross = Number(item.amountNet) + Number(item.amountTax)"
|
||||||
>
|
>
|
||||||
<template #trailing>
|
<template #trailing>
|
||||||
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user