New Backend changes
This commit is contained in:
@@ -36,6 +36,24 @@ export const useEntities = (
|
|||||||
return data
|
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 (
|
const selectSingle = async (
|
||||||
idToEq: string | number,
|
idToEq: string | number,
|
||||||
select: string = "*",
|
select: string = "*",
|
||||||
@@ -113,7 +131,7 @@ export const useEntities = (
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
return {select, create, update, archive, selectSingle}
|
return {select, create, update, archive, selectSingle, selectSpecial}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,15 @@ defineShortcuts({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const profileStore = useProfileStore()
|
|
||||||
const tempStore = useTempStore()
|
const tempStore = useTempStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const supabase = useSupabaseClient()
|
|
||||||
|
|
||||||
const bankstatements = ref([])
|
const bankstatements = ref([])
|
||||||
const bankaccounts = ref([])
|
const bankaccounts = ref([])
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").is("archived",false).eq('tenant', profileStore.currentTenant).order("date", {ascending:false})).data
|
bankstatements.value = (await useEntities("bankstatements").select("*, statementallocations(*)", "date", false))
|
||||||
bankaccounts.value = await useSupabaseSelect("bankaccounts")
|
bankaccounts.value = await useEntities("bankaccounts").select()
|
||||||
}
|
}
|
||||||
|
|
||||||
const templateColumns = [
|
const templateColumns = [
|
||||||
|
|||||||
@@ -37,20 +37,20 @@ const ownaccounts = ref([])
|
|||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
if(route.params.id) {
|
if(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))
|
itemInfo.value = await useEntities("bankstatements").selectSingle(route.params.id,"*, statementallocations(*, cd_id(*), ii_id(*))", undefined, undefined, true)
|
||||||
}
|
}
|
||||||
if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
|
if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
|
||||||
|
|
||||||
manualAllocationSum.value = calculateOpenSum.value
|
manualAllocationSum.value = calculateOpenSum.value
|
||||||
|
|
||||||
createddocuments.value = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name)"))
|
createddocuments.value = (await useEntities("createddocuments").select("*, statementallocations(*), customer(id,name)"))
|
||||||
const documents = createddocuments.value.filter(i => i.type === "invoices" ||i.type === "advanceInvoices")
|
const documents = createddocuments.value.filter(i => i.type === "invoices" ||i.type === "advanceInvoices")
|
||||||
const incominginvoices = (await useSupabaseSelect("incominginvoices","*, statementallocations(*), vendor(id,name)")).filter(i => i.state === "Gebucht")
|
const incominginvoices = (await useEntities("incominginvoices").select("*, statementallocations(*), vendor(id,name)")).filter(i => i.state === "Gebucht")
|
||||||
|
|
||||||
accounts.value = (await supabase.from("accounts").select().order("number",{ascending: true})).data
|
accounts.value = (await useEntities("accounts").selectSpecial("*","number",true))
|
||||||
ownaccounts.value = (await supabase.from("ownaccounts").select()).data
|
ownaccounts.value = (await useEntities("ownaccounts").select()).data
|
||||||
customers.value = (await supabase.from("customers").select()).data
|
customers.value = (await useEntities("customers").select()).data
|
||||||
vendors.value = (await supabase.from("vendors").select()).data
|
vendors.value = (await useEntities("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 = 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 => {
|
openDocuments.value = openDocuments.value.map(i => {
|
||||||
@@ -69,15 +69,12 @@ const setup = async () => {
|
|||||||
allocatedIncomingInvoices.value = incominginvoices.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)
|
console.log(allocatedDocuments.value)
|
||||||
console.log(allocatedIncomingInvoices.value)
|
console.log(allocatedIncomingInvoices.value)
|
||||||
//openIncomingInvoices.value = (await useSupabaseSelect("incominginvoices","*, statementallocations(*), vendor(*)")).filter(i => i.statementallocations.length === 0 )
|
openIncomingInvoices.value = (await useEntities("incominginvoices").select("*, statementallocations(*), vendor(*)")).filter(i => i.statementallocations.reduce((n,{amount}) => n + amount, 0).toFixed(2) !== getInvoiceSum(i,false))
|
||||||
openIncomingInvoices.value = (await useSupabaseSelect("incominginvoices","*, statementallocations(*), vendor(*)")).filter(i => i.statementallocations.reduce((n,{amount}) => n + amount, 0).toFixed(2) !== getInvoiceSum(i,false))
|
|
||||||
//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)
|
// return incominginvoices.value.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.type === 'incomingInvoice' && y.id === i.id)).length === 0)
|
||||||
|
|
||||||
|
|
||||||
let allocations = (await supabase.from("createddocuments").select(`*, statementallocations(*)`).eq("id",50)).data
|
|
||||||
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -149,7 +146,7 @@ const showMoreWithoutRecipe = ref(false)
|
|||||||
const showMoreText = ref(false)
|
const showMoreText = ref(false)
|
||||||
|
|
||||||
const saveAllocation = async (allocation) => {
|
const saveAllocation = async (allocation) => {
|
||||||
|
//TODO: BACKEND CHANGE SAVE/REMOVE
|
||||||
console.log(allocation)
|
console.log(allocation)
|
||||||
|
|
||||||
const {data,error} = await supabase.from("statementallocations").insert({
|
const {data,error} = await supabase.from("statementallocations").insert({
|
||||||
@@ -354,7 +351,9 @@ const archiveStatement = async () => {
|
|||||||
<span class="font-semibold">Konto:</span>
|
<span class="font-semibold">Konto:</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<!--
|
||||||
{{dataStore.getBankAccountById(itemInfo.account) ? dataStore.getBankAccountById(itemInfo.account).name || separateIBAN(dataStore.getBankAccountById(itemInfo.account).iban) : ""}}
|
{{dataStore.getBankAccountById(itemInfo.account) ? dataStore.getBankAccountById(itemInfo.account).name || separateIBAN(dataStore.getBankAccountById(itemInfo.account).iban) : ""}}
|
||||||
|
-->
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- <tr class="flex-row flex justify-between">
|
<!-- <tr class="flex-row flex justify-between">
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ const setCustomerData = async (customerId, loadOnlyAdress = false) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const setContactPersonData = async () => {
|
const setContactPersonData = async () => {
|
||||||
//console.log(itemInfo.value.contactPerson) //TODO Set Profile
|
//console.log(itemInfo.value.contactPerson) //TODO: BACKEND CHANGE Set Profile
|
||||||
let profile = await useSupabaseSelectSingle("profiles",itemInfo.value.contactPerson, '*')
|
let profile = await useSupabaseSelectSingle("profiles",itemInfo.value.contactPerson, '*')
|
||||||
|
|
||||||
itemInfo.value.contactPersonName = profile.fullName
|
itemInfo.value.contactPersonName = profile.fullName
|
||||||
|
|||||||
Reference in New Issue
Block a user