Added select-special
Fixed Banking Page
This commit is contained in:
@@ -36,6 +36,24 @@ export const useEntities = (
|
||||
return data
|
||||
}
|
||||
|
||||
const selectSpecial = async (
|
||||
select: string = "*",
|
||||
sortColumn: string | null = null,
|
||||
ascending: boolean = false,
|
||||
) => {
|
||||
|
||||
const res = await useNuxtApp().$api(`/api/resource-special/${relation}`, {
|
||||
method: "GET",
|
||||
params: {
|
||||
select,
|
||||
sort: sortColumn || undefined,
|
||||
asc: ascending
|
||||
}
|
||||
})
|
||||
|
||||
return res || []
|
||||
}
|
||||
|
||||
const selectSingle = async (
|
||||
idToEq: string | number,
|
||||
select: string = "*",
|
||||
@@ -113,7 +131,7 @@ export const useEntities = (
|
||||
return res
|
||||
}
|
||||
|
||||
return {select, create, update, archive, selectSingle}
|
||||
return {select, create, update, archive, selectSingle, selectSpecial}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user