diff --git a/components/HelpSlideover.vue b/components/HelpSlideover.vue index 2c273b6..63a2f38 100644 --- a/components/HelpSlideover.vue +++ b/components/HelpSlideover.vue @@ -1,4 +1,4 @@ - \ No newline at end of file diff --git a/composables/useFunctions.js b/composables/useFunctions.js index 0f4890e..07f956b 100644 --- a/composables/useFunctions.js +++ b/composables/useFunctions.js @@ -1,7 +1,7 @@ import axios from "axios"; import dayjs from "dayjs"; -const baseURL = "https://functions.fedeo.io" +const baseURL = "http://localhost:3333" /*"https://functions.fedeo.io"*/ export const useFunctions = () => { const supabase = useSupabaseClient() @@ -38,5 +38,76 @@ export const useFunctions = () => { })).data.usedNumber } - return {getWorkingTimesEvaluationData, useNextNumber} + const useCreateTicket = async (subject,message,url,source) => { + const {data:{session:{access_token}}} = await supabase.auth.getSession() + + const {data} = await axios({ + method: "POST", + url: `${baseURL}/functions/createticket`, + data: { + subject, + message, + source, + url + }, + headers: { + Authorization: `Bearer ${access_token}` + } + }) + + return !!data.ticket_created; + + } + + const useBankingGenerateLink = async (institutionId) => { + const {data:{session:{access_token}}} = await supabase.auth.getSession() + + const {data} = await axios({ + method: "POST", + url: `${baseURL}/functions/bankstatements/generatelink`, + data: { + institutionId + }, + headers: { + Authorization: `Bearer ${access_token}` + } + }) + + console.log(data) + + return data.link + + } + + const useBankingCheckInstitutions = async (bic) => { + const {data:{session:{access_token}}} = await supabase.auth.getSession() + + const {data} = await axios({ + method: "GET", + url: `${baseURL}/functions/bankstatements/checkinstitutions/${bic}`, + headers: { + Authorization: `Bearer ${access_token}` + } + }) + + return data + + } + + const useBankingListRequisitions = async (reqId) => { + const {data:{session:{access_token}}} = await supabase.auth.getSession() + + const {data} = await axios({ + method: "GET", + url: `${baseURL}/functions/bankstatements/listrequisitions/${reqId}`, + headers: { + Authorization: `Bearer ${access_token}` + } + }) + + return data + + } + + return {getWorkingTimesEvaluationData, useNextNumber, useCreateTicket, useBankingGenerateLink, useBankingCheckInstitutions, useBankingListRequisitions} } \ No newline at end of file diff --git a/pages/banking/statements/[mode]/[[id]].vue b/pages/banking/statements/[mode]/[[id]].vue index cea4294..378abf9 100644 --- a/pages/banking/statements/[mode]/[[id]].vue +++ b/pages/banking/statements/[mode]/[[id]].vue @@ -27,6 +27,8 @@ const openDocuments = ref([]) const allocatedDocuments = ref([]) const openIncomingInvoices = ref([]) +const accounts = ref([]) + const setup = async () => { if(route.params.id) { itemInfo.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq("id",route.params.id).single()).data //dataStore.bankstatements.find(i => i.id === Number(route.params.id)) @@ -35,6 +37,8 @@ const setup = async () => { const documents = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name)")).filter(i => i.type === "invoices" ||i.type === "advanceInvoices") + accounts.value = (await supabase.from("accounts").select()).data + openDocuments.value = documents.filter(i => i.statementallocations.reduce((n,{amount}) => n + amount, 0).toFixed(2) !== getDocumentSum(i).toFixed(2)) openDocuments.value = openDocuments.value.map(i => { @@ -99,6 +103,8 @@ const calculateOpenSum = computed(() => { startingAmount = startingAmount - item.amount } else if(item.ii_id) { startingAmount = Number(startingAmount) + item.amount + }else if(item.account) { + startingAmount = Number(startingAmount) - item.amount } }) @@ -298,7 +304,7 @@ setup() - Verknüpfte Dokumente: + Buchungen: {{dataStore.getVendorById(dataStore.getIncomingInvoiceById(item.ii_id).vendor).name}} - {{dataStore.getIncomingInvoiceById(item.ii_id).reference}} + + Buchungskonto: {{accounts.find(i => i.id === item.account).number}} {{accounts.find(i => i.id === item.account).label}} + + + + Als DP markieren + + { if(route.query.ref) { - const {data,error} = await supabase.functions.invoke(`bankstatement_gateway`,{ - body: { - reqId: route.query.ref, - method: "listRequisitions" - } - }) - - if(data) { - reqData.value = data - } + reqData.value = await useFunctions().useBankingListRequisitions(route.query.ref) } + + bankaccounts.value = await useSupabaseSelect("bankaccounts") } const checkBIC = async () => { - const {data,error} = await supabase.functions.invoke(`bankstatement_gateway`,{ - body: { - bic: bicBankToAdd.value, - method: "checkInstitutions" - } - }) - - bankData.value = data + bankData.value = await useFunctions().useBankingCheckInstitutions(bicBankToAdd.value) showAlert.value = true } -const generateLink = async () => { +const generateLink = async (bankId) => { try { - const {data,error} = await supabase.functions.invoke(`bankstatement_gateway`,{ + /*const {data,error} = await supabase.functions.invoke(`bankstatement_gateway`,{ body: { method: "generateLink", institutionId: bankData.value.id, tenant: profileStore.currentTenant } - }) + })*/ + const link = await useFunctions().useBankingGenerateLink(bankId || bankData.value.id) - await navigateTo(data.link, { + await navigateTo(link, { open: { target: "_blank" } @@ -76,12 +67,13 @@ const addAccount = async (account) => { } const updateAccount = async (account) => { - const {data,error} = await supabase.from("bankaccounts").update({accountId: account.id}).eq("iban",account.iban).select() + const {data,error} = await supabase.from("bankaccounts").update({accountId: account.id, expired: false}).eq("iban",account.iban).select() if(error) { console.log(error) toast.add({title: "Es gab einen Fehler bei aktualisieren des Accounts", color:"rose"}) } else if(data) { toast.add({title: "Account erfolgreich aktualisiert"}) + setupPage() } } @@ -173,11 +165,11 @@ setupPage() --> + + diff --git a/pages/standardEntity/[type]/[[mode]]/[[id]].vue b/pages/standardEntity/[type]/[[mode]]/[[id]].vue index 2f3a565..64b74bf 100644 --- a/pages/standardEntity/[type]/[[mode]]/[[id]].vue +++ b/pages/standardEntity/[type]/[[mode]]/[[id]].vue @@ -31,7 +31,7 @@ const setupPage = async () => { console.log(item.value) } else if(mode.value === "list") { //Load Data for List - items.value = await useSupabaseSelect(type, dataType.supabaseSelectWithInformation || "*", dataType.supabaseSortColumn) + items.value = await useSupabaseSelect(type, dataType.supabaseSelectWithInformation || "*", dataType.supabaseSortColumn,dataType.supabaseSortAscending || false) } loaded.value = true diff --git a/pages/workingtimes/[mode]/[[id]].vue b/pages/workingtimes/[mode]/[[id]].vue index 4cde3f6..6e4946e 100644 --- a/pages/workingtimes/[mode]/[[id]].vue +++ b/pages/workingtimes/[mode]/[[id]].vue @@ -23,6 +23,11 @@ const setupPage = () => { //setStartEnd() } oldItemInfo.value = itemInfo.value + + if(route.query) { + if(route.query.profile) itemInfo.value.profile = route.query.profile + } + } /*const setStartEnd = () => { diff --git a/pages/workingtimes/index.vue b/pages/workingtimes/index.vue index ff0870e..e716dc1 100644 --- a/pages/workingtimes/index.vue +++ b/pages/workingtimes/index.vue @@ -12,16 +12,27 @@ const dataStore = useDataStore() const profileStore = useProfileStore() const supabase = useSupabaseClient() const router = useRouter() - - - +const route = useRoute() const filterUser = ref(profileStore.activeProfile.id || "") const workingtimes = ref([]) const setupPage = async () => { + if(route.query) { + if(route.query.profile) filterUser.value = route.query.profile + } + workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",filterUser.value).order("startDate",{ascending: false})).data + + + + +} + +const changeFilterUser = async () => { + await router.push(`/workingtimes/?profile=${filterUser.value}`) + await setupPage() } setupPage() @@ -147,9 +158,9 @@ const setEndDate = (row) => { @@ -161,7 +172,7 @@ const setEndDate = (row) => { option-attribute="fullName" value-attribute="id" v-model="filterUser" - @change="setupPage" + @change="changeFilterUser" >