diff --git a/pages/banking/statements/[mode]/[[id]].vue b/pages/banking/statements/[mode]/[[id]].vue index ddb9878..381120f 100644 --- a/pages/banking/statements/[mode]/[[id]].vue +++ b/pages/banking/statements/[mode]/[[id]].vue @@ -28,6 +28,9 @@ const allocatedDocuments = ref([]) const openIncomingInvoices = ref([]) const allocatedIncomingInvoices = ref([]) +const customers = ref([]) +const vendors = ref([]) + const createddocuments = ref([]) const accounts = ref([]) @@ -36,7 +39,7 @@ const ownaccounts = ref([]) const loading = ref(true) const setup = async () => { if(route.params.id) { - itemInfo.value = (await supabase.from("bankstatements").select("*, statementallocations(*, cd_id(*, customer(*)), ii_id(*))").eq("id",route.params.id).single()).data //dataStore.bankstatements.find(i => i.id === Number(route.params.id)) + itemInfo.value = (await supabase.from("bankstatements").select("*, statementallocations(*, cd_id(*), ii_id(*))").eq("id",route.params.id).single()).data //dataStore.bankstatements.find(i => i.id === Number(route.params.id)) } if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value)) @@ -48,6 +51,8 @@ const setup = async () => { accounts.value = (await supabase.from("accounts").select()).data ownaccounts.value = (await supabase.from("ownaccounts").select()).data + customers.value = (await supabase.from("customers").select()).data + vendors.value = (await supabase.from("vendors").select()).data openDocuments.value = documents.filter(i => i.statementallocations.reduce((n,{amount}) => n + amount, 0).toFixed(2) !== useSum().getCreatedDocumentSum(i,createddocuments.value).toFixed(2)) openDocuments.value = openDocuments.value.map(i => { @@ -93,17 +98,23 @@ const getInvoiceSum = (invoice) => { sum += account.amountTax sum += account.amountNet }) - return sum.toFixed(2) + console.log(sum) + + if(invoice.expense) { + return (sum * -1).toFixed(2) + } else { + return sum.toFixed(2) + } } const calculateOpenSum = computed(() => { let startingAmount = 0 itemInfo.value.statementallocations.forEach(item => { - startingAmount += Math.abs(item.amount) + startingAmount += item.amount }) - return (Math.abs(itemInfo.value.amount) - startingAmount).toFixed(2) + return (itemInfo.value.amount - startingAmount).toFixed(2) }) @@ -121,6 +132,8 @@ const saveAllocations = async () => { const showAccountSelection = ref(false) const accountToSave = ref("") const ownAccountToSave = ref("") +const customerAccountToSave = ref("") +const vendorAccountToSave = ref("") const selectAccount = (id) => { accountToSave.value = id @@ -129,6 +142,8 @@ const selectAccount = (id) => { const manualAllocationSum = ref(itemInfo.value.amount || 0) +const allocationDescription = ref("") +const showMoreWithoutRecipe = ref(false) const saveAllocation = async (allocation) => { @@ -142,6 +157,10 @@ const saveAllocation = async (allocation) => { if(data) { await setup() accountToSave.value = null + vendorAccountToSave.value = null + customerAccountToSave.value = null + ownAccountToSave.value = null + allocationDescription.value = null } @@ -172,6 +191,23 @@ const filteredIncomingInvoices = computed(() => { setup() + +const archiveStatement = async () => { + + let temp = itemInfo.value + delete temp.statementallocations + + await dataStore.updateItem("bankstatements", {...temp,archived:true}) + + + const {data,error} = await supabase.from("historyitems").insert({ + createdBy: useProfileStore().activeProfile.id, + tenant: useProfileStore().currentTenant, + text: "Bankbuchung archiviert", + bankStatement: itemInfo.value.id + }) +} + + + + @@ -343,15 +403,15 @@ setup() @@ -399,91 +459,105 @@ setup() + + + + + + + + + + + + - - - - - - - - - - -
- Buchungssumme - - Buchungsdaten + - - + + + + + + + + Ohne Beleg buchen @@ -519,7 +593,7 @@ setup() variant="outline" icon="i-heroicons-check" :disabled="!accountToSave" - @click="saveAllocation({bs_id: itemInfo.id, amount: manualAllocationSum, account: accountToSave })" + @click="saveAllocation({bs_id: itemInfo.id, amount: manualAllocationSum, account: accountToSave, description: allocationDescription })" /> + {{ showMoreWithoutRecipe ? "Weniger anzeigen" : "Mehr anzeigen" }} @@ -579,7 +659,7 @@ setup() variant="outline" icon="i-heroicons-check" :disabled="!ownAccountToSave" - @click="saveAllocation({bs_id: itemInfo.id, amount: manualAllocationSum, ownaccount: ownAccountToSave })" + @click="saveAllocation({bs_id: itemInfo.id, amount: manualAllocationSum, ownaccount: ownAccountToSave, description: allocationDescription })" /> - - + + + + + + + + + + + + + + + + + + + +
-
+
{{item.vendor ? item.vendor.name : ''}} - {{item.reference}} - -{{displayCurrency(getInvoiceSum(item))}} + {{displayCurrency(getInvoiceSum(item))}}
{ numberRangeHolder: "customerNumber", historyItemHolder: "customer", supabaseSortColumn: "customerNumber", - supabaseSelectWithInformation: "*, projects(*), plants(*), contracts(*), contacts(*), createddocuments(*), files(*)", + supabaseSelectWithInformation: "*, projects(*), plants(*), contracts(*), contacts(*), createddocuments(*), files(*), events(*)", filters: [{ name: "Archivierte ausblenden", default: true, @@ -309,7 +309,7 @@ export const useDataStore = defineStore('data', () => { component: profiles }, ], - showTabs: [{label: 'Informationen'},{label: 'Ansprechpartner'},{label: 'Dateien'},{label: 'Ausgangsbelege'},{label: 'Projekte'},{label: 'Objekte'},{label: 'Verträge'}] + showTabs: [{label: 'Informationen'},{label: 'Ansprechpartner'},{label: 'Dateien'},{label: 'Ausgangsbelege'},{label: 'Projekte'},{label: 'Objekte'},{label: 'Termine'},{label: 'Verträge'}] }, contacts: { isArchivable: true, @@ -1647,7 +1647,7 @@ export const useDataStore = defineStore('data', () => { labelSingle: "Termin", isStandardEntity: true, historyItemHolder: "event", - supabaseSelectWithInformation: "*, project(id,name)", + supabaseSelectWithInformation: "*, project(id,name), customer(*)", redirect: true, filters:[{ name: "Archivierte ausblenden", @@ -1737,6 +1737,7 @@ export const useDataStore = defineStore('data', () => { selectDataType: "customers", selectOptionAttribute: "name", selectSearchAttributes: ['name'], + component: customer, },{ key: "vendor", label: "Lieferant", @@ -2623,9 +2624,9 @@ export const useDataStore = defineStore('data', () => { await generateHistoryItems(dataType, supabaseData[0]) - if(!["statementallocations","absencerequests", "productcategories", "servicecategories", "projecttypes", "checks", "profiles","services", "inventoryitems", "inventoryitemgroups", "incominginvoices"].includes(dataType) ){ + /*if(!["statementallocations","absencerequests", "productcategories", "servicecategories", "projecttypes", "checks", "profiles","services", "inventoryitems", "inventoryitemgroups", "incominginvoices", "costcentres", "ownaccounts"].includes(dataType) ){ await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')') - } + }*/ toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`})