From 241a912f08857540fcc46fd91b1caa6a45722184 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Thu, 8 May 2025 11:08:00 +0200 Subject: [PATCH] Added Statements to OwnAccounts --- components/EntityShow.vue | 7 ++ .../EntityShowSubOwnAccountsStatements.vue | 108 ++++++++++++++++++ stores/data.js | 4 +- 3 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 components/EntityShowSubOwnAccountsStatements.vue diff --git a/components/EntityShow.vue b/components/EntityShow.vue index 29631cd..76babf2 100644 --- a/components/EntityShow.vue +++ b/components/EntityShow.vue @@ -245,6 +245,13 @@ const onTabChange = (index) => { v-else-if="tab.label === 'Auswertung Kostenstelle'" :platform="platform" /> + + +import dayjs from "dayjs"; +const supabase = useSupabaseClient() +const route = useRoute() +const router = useRouter() +const profileStore = useProfileStore() + + +const props = defineProps({ + queryStringData: { + type: String + }, + item: { + type: Object, + required: true + }, + topLevelType: { + type: String, + required: true + }, + platform: { + type: String, + required: true + } +}) + +const statementallocations = ref([]) +const incominginvoices = ref([]) + +const setup = async () => { + //statementallocations.value = (await supabase.from("statementallocations").select("*, bs_id(*)").eq("account", route.params.id).eq("tenant",profileStore.currentTenant).order("created_at",{ascending: true})).data + //incominginvoices.value = (await useSupabaseSelect("incominginvoices", "*, vendor(*)")).filter(i => i.accounts.find(x => x.account == route.params.id)) +} + +setup() + +const selectAllocation = (allocation) => { + if(allocation.type === "statementallocation") { + router.push(`/banking/statements/edit/${allocation.bs_id.id}`) + } else if(allocation.type === "incominginvoice") { + router.push(`/incominginvoices/show/${allocation.incominginvoiceid}`) + } +} + +const renderedAllocations = computed(() => { + + let tempstatementallocations = props.item.statementallocations.map(i => { + return { + ...i, + type: "statementallocation", + date: i.bs_id.date, + partner: i.bs_id ? (i.bs_id.debName ? i.bs_id.debName : (i.bs_id.credName ? i.bs_id.credName : '')) : '' + } + }) + + + /*let incominginvoicesallocations = [] + + incominginvoices.value.forEach(i => { + + incominginvoicesallocations.push(...i.accounts.filter(x => x.account == route.params.id).map(x => { + return { + ...x, + incominginvoiceid: i.id, + type: "incominginvoice", + amount: x.amountGross ? x.amountGross : x.amountNet, + date: i.date, + partner: i.vendor.name, + description: i.description, + color: i.expense ? "red" : "green" + } + })) + })*/ + + return [...tempstatementallocations/*, ... incominginvoicesallocations*/] +}) + + + + + + + \ No newline at end of file diff --git a/stores/data.js b/stores/data.js index 42a91ba..b91747c 100644 --- a/stores/data.js +++ b/stores/data.js @@ -2184,7 +2184,7 @@ export const useDataStore = defineStore('data', () => { redirect:true, historyItemHolder: "ownaccount", supabaseSortColumn: "number", - supabaseSelectWithInformation: "*", + supabaseSelectWithInformation: "*, statementallocations(*, bs_id(*))", filters: [{ name: "Archivierte ausblenden", default: true, @@ -2224,7 +2224,7 @@ export const useDataStore = defineStore('data', () => { component: profiles }, ], - showTabs: [{label: 'Informationen'}] + showTabs: [{label: 'Informationen'},{label: 'Buchungen'}] }, }