diff --git a/pages/banking/statements/[mode]/[[id]].vue b/pages/banking/statements/[mode]/[[id]].vue index 8677469..a92b728 100644 --- a/pages/banking/statements/[mode]/[[id]].vue +++ b/pages/banking/statements/[mode]/[[id]].vue @@ -26,6 +26,7 @@ const oldItemInfo = ref({}) const openDocuments = ref([]) const allocatedDocuments = ref([]) const openIncomingInvoices = ref([]) +const allocatedIncomingInvoices = ref([]) const accounts = ref([]) @@ -36,15 +37,16 @@ const setup = async () => { } if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value)) + manualAllocationSum.value = calculateOpenSum.value + const documents = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name)")).filter(i => i.type === "invoices" ||i.type === "advanceInvoices") + const incominginvoices = (await useSupabaseSelect("incominginvoices","*, statementallocations(*), vendor(id,name)")) 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 => { - console.log() - return { ...i, docTotal: getDocumentSum(i, i.usedAdvanceInvoices.map(i => getDocumentSum(documents.find(x => x.id === i)))), @@ -56,8 +58,10 @@ const setup = async () => { console.log(openDocuments.value) allocatedDocuments.value = documents.filter(i => i.statementallocations.find(x => x.bs_id === itemInfo.value.id)) + allocatedIncomingInvoices.value = incominginvoices.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(allocatedIncomingInvoices.value) + openIncomingInvoices.value = (await useSupabaseSelect("incominginvoices","*, statementallocations(*), vendor(*)")).filter(i => i.statementallocations.length === 0 ) //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) @@ -144,6 +148,9 @@ const selectAccount = (id) => { showAccountSelection.value = false } + +const manualAllocationSum = ref(itemInfo.value.amount || 0) + const saveAllocation = async (allocation) => { const {data,error} = await supabase.from("statementallocations").insert({ ...allocation, @@ -152,8 +159,11 @@ const saveAllocation = async (allocation) => { if(data) { await setup() + accountToSave.value = null } + + } const removeAllocation = async (allocationId) => { @@ -163,13 +173,20 @@ const removeAllocation = async (allocationId) => { } const searchString = ref("") -const filteredRows = computed(() => { +const filteredDocuments = computed(() => { return useSearch(searchString.value, openDocuments.value) }) +const filteredIncomingInvoices = computed(() => { + + + return useSearch(searchString.value, openIncomingInvoices.value) + +}) + setup() @@ -209,371 +226,411 @@ setup() - - - - - - - - - - - - - - -
- Buchungsdatum: - - {{dayjs(itemInfo.date).format("DD.MM.YYYY")}} -
- Wertstellungsdatum: - - {{dayjs(itemInfo.valueDate).format("DD.MM.YYYY")}} -
- Partner: - - {{itemInfo.debName}} - {{itemInfo.credName}} - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - + + + --> + + + + + + + -
+ Buchungsdatum: + + {{dayjs(itemInfo.date).format("DD.MM.YYYY")}} +
+ Wertstellungsdatum: + + {{dayjs(itemInfo.valueDate).format("DD.MM.YYYY")}} +
+ Partner: + + {{itemInfo.debName}} + {{itemInfo.credName}} + - -
- Partner IBAN: - - {{itemInfo.debIban}} - {{itemInfo.credIban}} - - -
- Konto: - - {{dataStore.getBankAccountById(itemInfo.account) ? dataStore.getBankAccountById(itemInfo.account).name || separateIBAN(dataStore.getBankAccountById(itemInfo.account).iban) : ""}} -
- Buchungen: -
+ Partner IBAN: + + {{separateIBAN(itemInfo.debIban)}} + {{separateIBAN(itemInfo.credIban)}} + - +
+ Konto: + + {{dataStore.getBankAccountById(itemInfo.account) ? dataStore.getBankAccountById(itemInfo.account).name || separateIBAN(dataStore.getBankAccountById(itemInfo.account).iban) : ""}} +
+ <!– {{dataStore.createddocuments.find(i => i.id === itemInfo.createdDocument).documentNumber}} + {{dataStore.getIncomingInvoiceById(itemInfo.incomingInvoice).reference}}–> + {{dataStore.getCreatedDocumentById(item.cd_id).documentNumber}} - - {{dataStore.getVendorById(dataStore.getIncomingInvoiceById(item.ii_id).vendor).name}} - {{dataStore.getIncomingInvoiceById(item.ii_id).reference}} + +<!– {{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}} - - - -
- Beschreibung: -
- {{itemInfo.text}} -
+ + +
+ Beschreibung: +
+ {{itemInfo.text}} +
+
-
+ -
- - - - - - - - - - - - - - - - - - Ohne Beleg buchen - - - -