New Backend changes
This commit is contained in:
@@ -13,9 +13,7 @@ const supabase = useSupabaseClient()
|
||||
const modal = useModal()
|
||||
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
|
||||
|
||||
const itemInfo = ref({
|
||||
@@ -84,23 +82,23 @@ 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","*"))
|
||||
projects.value = (await useSupabaseSelect("projects","*"))
|
||||
plants.value = (await useSupabaseSelect("plants","*"))
|
||||
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"))
|
||||
contacts.value = (await useSupabaseSelect("contacts","*"))
|
||||
texttemplates.value = (await useSupabaseSelect("texttemplates","*"))
|
||||
letterheads.value = (await useEntities("letterheads").select("*")).filter(i => i.documentTypes.length === 0 || i.documentTypes.includes(itemInfo.value.type))
|
||||
createddocuments.value = await useEntities("createddocuments").select("*")
|
||||
projects.value = await useEntities("projects").select("*")
|
||||
plants.value = await useEntities("plants").select("*")
|
||||
services.value = await useEntities("services").select("*")
|
||||
servicecategories.value = await useEntities("servicecategories").select("*")
|
||||
products.value = await useEntities("products").select("*")
|
||||
productcategories.value = await useEntities("productcategories").select("*")
|
||||
customers.value = await useEntities("customers").select("*","customerNumber")
|
||||
contacts.value = await useEntities("contacts").select("*")
|
||||
texttemplates.value = await useEntities("texttemplactes").select("*")
|
||||
if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id
|
||||
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
|
||||
|
||||
if(route.params) {
|
||||
if(route.params.id) {
|
||||
itemInfo.value = await useSupabaseSelectSingle("createddocuments", route.params.id)
|
||||
itemInfo.value = await useEntities("createddocuments").selectSingle(route.params.id)
|
||||
checkCompatibilityWithInputPrice()
|
||||
}
|
||||
|
||||
@@ -213,7 +211,7 @@ const setupPage = async () => {
|
||||
setCustomerData()
|
||||
|
||||
for await (const doc of linkedDocuments.filter(i => i.type === "confirmationOrders")) {
|
||||
let linkedDocument = await useSupabaseSelectSingle("createddocuments",doc.id)
|
||||
let linkedDocument = await useEntities("createddocuments").selectSingle(doc.id)
|
||||
|
||||
itemInfo.value.rows.push({
|
||||
mode: "title",
|
||||
@@ -224,7 +222,7 @@ const setupPage = async () => {
|
||||
}
|
||||
|
||||
for await (const doc of linkedDocuments.filter(i => i.type === "quotes")) {
|
||||
let linkedDocument = await useSupabaseSelectSingle("createddocuments",doc.id)
|
||||
let linkedDocument = await useEntities("createddocuments").selectSingle(doc.id)
|
||||
|
||||
itemInfo.value.rows.push({
|
||||
mode: "title",
|
||||
@@ -277,8 +275,7 @@ const setupPage = async () => {
|
||||
|
||||
if(route.query.linkedDocument) {
|
||||
itemInfo.value.linkedDocument = route.query.linkedDocument
|
||||
let linkedDocument = await useSupabaseSelectSingle("createddocuments",itemInfo.value.linkedDocument)
|
||||
|
||||
let linkedDocument = await useEntities("createddocuments").selectSingle(itemInfo.value.linkedDocument)
|
||||
|
||||
if(route.query.optionsToImport) {
|
||||
//Import only true
|
||||
@@ -361,7 +358,7 @@ const setupPage = async () => {
|
||||
if(route.query.project) {
|
||||
itemInfo.value.project = Number(route.query.project)
|
||||
|
||||
let project = await useSupabaseSelectSingle("projects",itemInfo.value.project)
|
||||
let project = await useEntities("projects").selectSingle(itemInfo.value.project)
|
||||
|
||||
if(!itemInfo.value.description){
|
||||
itemInfo.value.description = project.customerRef
|
||||
@@ -389,21 +386,6 @@ const setupPage = async () => {
|
||||
}
|
||||
|
||||
setupPage()
|
||||
const openAdvanceInvoices = ref([])
|
||||
const checkForOpenAdvanceInvoices = async () => {
|
||||
console.log("Check for Open Advance Invoices")
|
||||
const {data} = await supabase.from("createddocuments").select().eq("project", itemInfo.value.project).eq("advanceInvoiceResolved", false).eq("type","advanceInvoices")
|
||||
const {data: usedAdvanceInvoices} = await supabase.from("createddocuments").select().in("id", itemInfo.value.usedAdvanceInvoices)
|
||||
|
||||
console.log(data)
|
||||
|
||||
openAdvanceInvoices.value = [...data, ...usedAdvanceInvoices.filter(i => !data.find(x => x.id === i.id))]
|
||||
|
||||
}
|
||||
|
||||
const addAdvanceInvoiceToInvoice = (advanceInvoice) => {
|
||||
itemInfo.value.usedAdvanceInvoices.push(advanceInvoice)
|
||||
}
|
||||
|
||||
const setDocumentTypeConfig = (withTexts = false) => {
|
||||
if(itemInfo.value.type === "invoices" ||itemInfo.value.type === "advanceInvoices" || itemInfo.value.type === "serialInvoices"|| itemInfo.value.type === "cancellationInvoices") {
|
||||
@@ -467,7 +449,7 @@ const setCustomerData = async (customerId, loadOnlyAdress = false) => {
|
||||
itemInfo.value.customer = customerId
|
||||
}
|
||||
|
||||
customers.value = await useSupabaseSelect("customers")
|
||||
customers.value = await useEntities("customers").select()
|
||||
|
||||
|
||||
let customer = customers.value.find(i => i.id === itemInfo.value.customer)
|
||||
@@ -496,7 +478,7 @@ const setCustomerData = async (customerId, loadOnlyAdress = false) => {
|
||||
}
|
||||
|
||||
const setContactPersonData = async () => {
|
||||
//console.log(itemInfo.value.contactPerson)
|
||||
//console.log(itemInfo.value.contactPerson) //TODO Set Profile
|
||||
let profile = await useSupabaseSelectSingle("profiles",itemInfo.value.contactPerson, '*')
|
||||
|
||||
itemInfo.value.contactPersonName = profile.fullName
|
||||
@@ -1187,32 +1169,9 @@ const uri = ref("")
|
||||
const generateDocument = async () => {
|
||||
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"
|
||||
}
|
||||
})*/
|
||||
|
||||
uri.value = await useFunctions().useCreatePDF(getDocumentData(), path)
|
||||
|
||||
|
||||
|
||||
|
||||
//const {data,error} = await supabase.storage.from("files").download(path)
|
||||
|
||||
//console.log(data)
|
||||
//console.log(error)
|
||||
|
||||
//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)
|
||||
}
|
||||
|
||||
const onChangeTab = (index) => {
|
||||
@@ -1454,12 +1413,12 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
||||
console.log("Set Row Data")
|
||||
if(service && service.id) {
|
||||
row.service = service.id
|
||||
services.value = await useSupabaseSelect("services","*")
|
||||
services.value = await useEntities("services").select("*")
|
||||
}
|
||||
|
||||
if(product && product.id) {
|
||||
row.product = product.id
|
||||
product.value = await useSupabaseSelect("products","*")
|
||||
product.value = await useEntities("products").select("*")
|
||||
}
|
||||
|
||||
if(row.service) {
|
||||
|
||||
Reference in New Issue
Block a user