diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 8e64697..34ae996 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -6,7 +6,6 @@ import { v4 as uuidv4 } from 'uuid'; const dataStore = useDataStore() const profileStore = useProfileStore() -const user = useSupabaseUser() const route = useRoute() const router = useRouter() const supabase = useSupabaseClient() @@ -63,7 +62,6 @@ const itemInfo = ref({ }) - const letterheads = ref([]) const createdDocuments = ref([]) const projects = ref([]) @@ -189,6 +187,7 @@ const setupPage = async () => { } +setupPage() const openAdvanceInvoices = ref([]) const checkForOpenAdvanceInvoices = async () => { const {data,error} = await supabase.from("createddocuments").select().eq("project", itemInfo.value.project).eq("advanceInvoiceResolved", false).eq("type","advanceInvoices") @@ -473,8 +472,8 @@ const documentTotal = computed(() => { return { - totalNet: `${String(totalNet.toFixed(2)).replace(".",",")} €`, - total19: `${String(total19.toFixed(2)).replace(".",",")} €`, + totalNet: renderCurrency(totalNet), + total19: renderCurrency(total19), totalGross: renderCurrency(totalGross), totalGrossAlreadyPaid: renderCurrency(totalGrossAlreadyPaid), totalSumToPay: renderCurrency(sumToPay) @@ -559,7 +558,7 @@ const getDocumentData = () => { if(!['pagebreak','title','text'].includes(row.mode)) { if(row.mode === 'normal') row.text = products.value.find(i => i.id === row.product).name - if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name + if(row.mode === 'service') row.text = services.value.find(i => i.id === row.service).name return { @@ -636,13 +635,26 @@ const generateDocument = async () => { const ownTenant = profileStore.ownTenant const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path + const {data,error} = await supabase.functions.invoke('create_pdf',{ + body: { + invoiceData: getDocumentData(), + backgroundPath: path, + returnMode: "base64" + } + }) - const {data,error} = await supabase.storage.from("files").download(path) + + + //const {data,error} = await supabase.storage.from("files").download(path) //console.log(data) //console.log(error) - uri.value = await useCreatePdf(getDocumentData(), await data.arrayBuffer()) + //console.log(JSON.stringify(getDocumentData())) + + uri.value = `data:${data.mimeType};base64,${data.base64}` + + //uri.value = await useCreatePdf(getDocumentData(), await data.arrayBuffer()) //alert(uri.value) showDocument.value = true //console.log(uri.value) @@ -821,7 +833,23 @@ const closeDocument = async () => { //console.log(uri) } -setupPage() +const setRowData = (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 + row.description = services.value.find(i => i.id === row.service).description + } + + if(row.product) { + 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 + row.description = services.value.find(i => i.id === row.service).description + } + + +} + +