From a742fc8c54bcf868d780ac397f53514ca55282b2 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Thu, 26 Jun 2025 11:31:52 +0200 Subject: [PATCH] EDIT Graph --- components/displayIncomeAndExpenditure.vue | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/components/displayIncomeAndExpenditure.vue b/components/displayIncomeAndExpenditure.vue index 4d2e837..ac30d7f 100644 --- a/components/displayIncomeAndExpenditure.vue +++ b/components/displayIncomeAndExpenditure.vue @@ -14,8 +14,36 @@ let expenseData = ref({}) const setup = async () => { let incomeRawData = (await supabase.from("createddocuments").select().eq("tenant",profileStore.currentTenant).in('type',['invoices','cancellationInvoices'])).data let expenseRawData =(await supabase.from("incominginvoices").select().eq("tenant",profileStore.currentTenant)).data + let withoutInvoiceRawData = (await supabase.from("statementallocations").select().eq("tenant",profileStore.currentTenant).not("account","is",null)).data + let withoutInvoiceRawDataExpenses = [] + let withoutInvoiceRawDataIncomes = [] + withoutInvoiceRawData.forEach(i => { + if(i.amount > 0) { + withoutInvoiceRawDataIncomes.push({ + id: i.id, + date: dayjs(i.created_at).format("DD-MM-YY"), + amount: Math.abs(i.amount), + bs_id: i.bs_id + }) + } else if(i.amount < 0) { + withoutInvoiceRawDataExpenses.push({ + id: i.id, + date: dayjs(i.created_at).format("DD-MM-YY"), + amount: Math.abs(i.amount), + bs_id: i.bs_id + }) + } + }) + + /*withoutInvoiceRawDataExpenses.forEach(i => { + expenseData.value[i.date] ? expenseData.value[i.date] = Number((expenseData.value[i.date] + i.amount).toFixed(2)) : expenseData.value[i.date] = i.amount + }) + + withoutInvoiceRawDataIncomes.forEach(i => { + incomeData.value[i.date] ? incomeData.value[i.date] = Number((incomeData.value[i.date] + i.amount).toFixed(2)) : incomeData.value[i.date] = i.amount + })*/ expenseRawData = expenseRawData.filter(i => i.date).map(i => { let amount = 0 @@ -55,6 +83,8 @@ const setup = async () => { } Object.keys(expenseMonths).forEach(month => { let dates = Object.keys(expenseData.value).filter(i => i.split("-")[1] === month && i.split("-")[2] === dayjs().format("YY")) + console.log(dates) + dates.forEach(date => { if(expenseMonths[month]){