diff --git a/components/DocumentUploadModal.vue b/components/DocumentUploadModal.vue index f288015..8d84458 100644 --- a/components/DocumentUploadModal.vue +++ b/components/DocumentUploadModal.vue @@ -65,7 +65,7 @@ const uploadFiles = async () => { /> { Senden @@ -208,6 +209,7 @@ const resetContactRequest = () => { type="reset" color="rose" variant="outline" + :disabled="!contactRequestData.title && !contactRequestData.message" > Zurücksetzen diff --git a/components/HistoryDisplay.vue b/components/HistoryDisplay.vue index c9aa5c9..9128288 100644 --- a/components/HistoryDisplay.vue +++ b/components/HistoryDisplay.vue @@ -2,21 +2,21 @@ import dayjs from "dayjs" const props = defineProps({ type: { - type: String + type: String, + required: true }, elementId: { - type: String + type: String, + required: true }, renderHeadline: { - type: Boolean + type: Boolean, + default: false } }) -const { metaSymbol } = useShortcuts() const profileStore = useProfileStore() -const user = useSupabaseUser() const supabase = useSupabaseClient() const toast = useToast() -const {type, elementId} = props const showAddHistoryItemModal = ref(false) const colorMode = useColorMode() @@ -24,8 +24,8 @@ const items = ref([]) const setup = async () => { - if(type && elementId){ - items.value = (await supabase.from("historyitems").select().eq(type,elementId).order("created_at",{ascending: true})).data || [] + if(props.type && props.elementId){ + items.value = (await supabase.from("historyitems").select().eq(props.type,props.elementId).order("created_at",{ascending: true})).data || [] } else { items.value = (await supabase.from("historyitems").select().order("created_at",{ascending: true})).data || [] @@ -39,8 +39,8 @@ setup() const addHistoryItemData = ref({ text: "", config: { - type: type, - id: elementId + type: props.type, + id: props.elementId } }) @@ -48,7 +48,7 @@ const addHistoryItem = async () => { console.log(addHistoryItemData.value) addHistoryItemData.value.createdBy = profileStore.activeProfile.id - addHistoryItemData.value[type] = elementId + addHistoryItemData.value[props.type] = props.elementId const {data,error} = await supabase .from("historyitems") @@ -71,7 +71,7 @@ const addHistoryItem = async () => { profile: profiles.find(x => x.username === rawUsername).id, initiatingProfile: profileStore.activeProfile.id, title: "Sie wurden im Logbuch erwähnt", - link: `/${type}s/show/${elementId}`, + link: `/${props.type}s/show/${props.elementId}`, message: addHistoryItemData.value.text } }) @@ -129,7 +129,7 @@ const renderText = (text) => { { + Eintrag -
+

Logbuch {{items.length}}

+const props = defineProps({ + row: { + type: Object, + required: true, + default: {} + } +}) + + + + diff --git a/components/displayOpenBalances.vue b/components/displayOpenBalances.vue index 0e3f3ac..0ba1943 100644 --- a/components/displayOpenBalances.vue +++ b/components/displayOpenBalances.vue @@ -6,18 +6,16 @@ let draftInvoicesSum = ref(0) let draftInvoicesCount = ref(0) let unallocatedStatements = ref(0) const setupPage = async () => { - let documents = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name)")).filter(i => i.type === "invoices" ||i.type === "advanceInvoices").filter(i => !i.archived) + let documents = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name)")).filter(i => i.type === "invoices" ||i.type === "advanceInvoices"||i.type === "cancellationInvoices").filter(i => !i.archived) let draftDocuments = documents.filter(i => i.state === "Entwurf") let finalizedDocuments = documents.filter(i => i.state === "Gebucht") - console.log(finalizedDocuments) finalizedDocuments = finalizedDocuments.filter(i => i.statementallocations.reduce((n,{amount}) => n + amount, 0).toFixed(2) !== getDocumentSum(i).toFixed(2)) finalizedDocuments.forEach(i => { - console.log(getDocumentSum(i)) unpaidInvoicesSum.value += getDocumentSum(i) - i.statementallocations.reduce((n,{amount}) => n + amount, 0) }) unpaidInvoicesCount.value = finalizedDocuments.length diff --git a/components/displayProjectsInPhases.vue b/components/displayProjectsInPhases.vue new file mode 100644 index 0000000..5b2f1ab --- /dev/null +++ b/components/displayProjectsInPhases.vue @@ -0,0 +1,43 @@ + + + + + \ No newline at end of file diff --git a/composables/useFunctions.js b/composables/useFunctions.js index 91b6dc5..6918d87 100644 --- a/composables/useFunctions.js +++ b/composables/useFunctions.js @@ -1,7 +1,7 @@ import axios from "axios"; import dayjs from "dayjs"; -const baseURL = /*"http://localhost:3333" */"https://functions.fedeo.io" +const baseURL = /*"http://localhost:3333"*/ "https://functions.fedeo.io" export const useFunctions = () => { const supabase = useSupabaseClient() @@ -79,6 +79,28 @@ export const useFunctions = () => { } + const useCreatePDF = async (invoiceData,path) => { + const {data:{session:{access_token}}} = await supabase.auth.getSession() + + const {data} = await axios({ + method: "POST", + url: `${baseURL}/functions/createpdf`, + data: { + invoiceData: invoiceData, + backgroundPath: path, + returnMode: "base64" + }, + headers: { + Authorization: `Bearer ${access_token}` + } + }) + + console.log(data) + + return `data:${data.mimeType};base64,${data.base64}` + + } + const useBankingCheckInstitutions = async (bic) => { const {data:{session:{access_token}}} = await supabase.auth.getSession() @@ -109,5 +131,5 @@ export const useFunctions = () => { } - return {getWorkingTimesEvaluationData, useNextNumber, useCreateTicket, useBankingGenerateLink, useBankingCheckInstitutions, useBankingListRequisitions} + return {getWorkingTimesEvaluationData, useNextNumber, useCreateTicket, useBankingGenerateLink, useBankingCheckInstitutions, useBankingListRequisitions, useCreatePDF} } \ No newline at end of file diff --git a/pages/banking/index.vue b/pages/banking/index.vue index 51b5f87..c419b06 100644 --- a/pages/banking/index.vue +++ b/pages/banking/index.vue @@ -11,61 +11,44 @@ defineShortcuts({ //console.log(searchinput) //searchinput.value.focus() document.getElementById("searchinput").focus() - }, - 'escape': () => { - //console.log(searchinput) - //searchinput.value.focus() - showStatementModal.value = false } }) -const dataStore = useDataStore() const profileStore = useProfileStore() const router = useRouter() const supabase = useSupabaseClient() const bankstatements = ref([]) - +const bankaccounts = ref([]) const setupPage = async () => { - bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq('tenant', profileStore.currentTenant).order("date", {ascending:false})).data - + bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").is("archived",false).eq('tenant', profileStore.currentTenant).order("date", {ascending:false})).data + bankaccounts.value = await useSupabaseSelect("bankaccounts") } - - -const selectedStatement = ref(null) -const showStatementModal = ref(false) - const templateColumns = [ { key: "account", - label: "Konto", - sortable: true + label: "Konto" },{ key: "valueDate", - label: "Valuta", - sortable: true + label: "Valuta" }, { key: "amount", - label: "Betrag", - sortable: true + label: "Betrag" }, { key: "openAmount", - label: "Offener Betrag", - sortable: true + label: "Offener Betrag" }, { key: "partner", - label: "Name", - sortable: true + label: "Name" }, { key: "text", - label: "Beschreibung", - sortable: true + label: "Beschreibung" } ] const selectedColumns = ref(templateColumns) @@ -73,35 +56,23 @@ const columns = computed(() => templateColumns.filter((column) => selectedColumn const searchString = ref('') -const filterAccount = ref(dataStore.bankAccounts || []) +const filterAccount = ref(bankaccounts || []) const showOnlyNotAssigned = ref(true) const displayCurrency = (value, currency = "€") => { return `${Number(value).toFixed(2).replace(".",",")} ${currency}` } -const getDocumentSum = (doc) => { - let sum = 0 - doc.rows.forEach(row => { - if(row.mode === "normal" || row.mode === "service" || row.mode === "free") { - sum += row.quantity * row.price * (1 - row.discountPercent / 100) * (1 + row.taxPercent / 100) - } - }) - return sum -} + const calculateOpenSum = (statement) => { - let startingAmount = statement.amount || 0 + let startingAmount = 0 statement.statementallocations.forEach(item => { - if(item.cd_id) { - startingAmount = startingAmount - item.amount - } else if(item.ii_id) { - startingAmount = Number(startingAmount) + item.amount - } + startingAmount += Math.abs(item.amount) }) - return startingAmount.toFixed(2) + return (Math.abs(statement.amount) - startingAmount).toFixed(2) } @@ -134,11 +105,12 @@ setupPage()