From 6f965b1704403db6f6750919b477d794f277d833 Mon Sep 17 00:00:00 2001 From: flfeders Date: Fri, 6 Sep 2024 21:15:26 +0200 Subject: [PATCH] added allocating for more than one bankstatement --- pages/banking/statements/[mode]/[[id]].vue | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/pages/banking/statements/[mode]/[[id]].vue b/pages/banking/statements/[mode]/[[id]].vue index af6f604..6acb7b1 100644 --- a/pages/banking/statements/[mode]/[[id]].vue +++ b/pages/banking/statements/[mode]/[[id]].vue @@ -34,10 +34,24 @@ const setup = async () => { const documents = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name)")).filter(i => i.type === "invoices" ||i.type === "advanceInvoices") - openDocuments.value = documents.filter(i => i.statementallocations.length === 0 ) + 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 => { + + + return { + ...i, + docTotal: getDocumentSum(i), + statementTotal: Number(i.statementallocations.reduce((n,{amount}) => n + amount, 0)), + openSum: (Number(getDocumentSum(i)) - Number(i.statementallocations.reduce((n,{amount}) => n + amount, 0))).toFixed(2) + } + }) + + console.log(openDocuments.value) + allocatedDocuments.value = documents.filter(i => i.statementallocations.find(x => x.bs_id === itemInfo.value.id)) + console.log(allocatedDocuments.value) openIncomingInvoices.value = (await useSupabaseSelect("incominginvoices","*, statementallocations(*)")).filter(i => i.statementallocations.length === 0 || i.statementallocations.find(x => x.bs_id === itemInfo.value.id)) - console.log(openIncomingInvoices.value) + //console.log(openIncomingInvoices.value) // return incominginvoices.value.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.type === 'incomingInvoice' && y.id === i.id)).length === 0) @@ -397,7 +411,7 @@ setup()