Added select-special

Fixed Banking Page
This commit is contained in:
2025-09-07 19:20:50 +02:00
parent 9f59b94336
commit 34c5764472
2 changed files with 33 additions and 10 deletions

View File

@@ -36,6 +36,7 @@ const ownaccounts = ref([])
const loading = ref(true)
const setup = async () => {
loading.value = true
if(route.params.id) {
itemInfo.value = await useEntities("bankstatements").selectSingle(route.params.id,"*, statementallocations(*, cd_id(*), ii_id(*))", undefined, undefined, true)
}
@@ -48,9 +49,9 @@ const setup = async () => {
const incominginvoices = (await useEntities("incominginvoices").select("*, statementallocations(*), vendor(id,name)")).filter(i => i.state === "Gebucht")
accounts.value = (await useEntities("accounts").selectSpecial("*","number",true))
ownaccounts.value = (await useEntities("ownaccounts").select()).data
customers.value = (await useEntities("customers").select()).data
vendors.value = (await useEntities("vendors").select()).data
ownaccounts.value = (await useEntities("ownaccounts").select())
customers.value = (await useEntities("customers").select())
vendors.value = (await useEntities("vendors").select())
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 => {
@@ -149,12 +150,14 @@ const saveAllocation = async (allocation) => {
//TODO: BACKEND CHANGE SAVE/REMOVE
console.log(allocation)
const {data,error} = await supabase.from("statementallocations").insert({
...allocation,
tenant: profileStore.currentTenant
}).select()
const res = await useNuxtApp().$api("/api/banking/statements",{
method: "POST",
body: {
data: allocation
}
})
if(data) {
if(res) {
await setup()
accountToSave.value = null
vendorAccountToSave.value = null
@@ -168,7 +171,9 @@ const saveAllocation = async (allocation) => {
}
const removeAllocation = async (allocationId) => {
const {data,error} = await supabase.from("statementallocations").delete().eq("id",allocationId)
const res = await useNuxtApp().$api(`/api/banking/statements/${allocationId}`,{
method: "DELETE"
})
await setup()
}