many changes

This commit is contained in:
2024-01-11 18:33:56 +01:00
parent d62fc5d668
commit 12323382a5
17 changed files with 941 additions and 537 deletions

View File

@@ -21,7 +21,8 @@ export const useDataStore = defineStore('data', () => {
tags: {
documents: [] as any[],
products: [] as any[]
}
},
measures: [] as {name:String, short:String}[]
})
const profiles = ref([])
const events = ref([])
@@ -40,7 +41,7 @@ export const useDataStore = defineStore('data', () => {
const contacts = ref([])
const vehicles = ref([])
const vendors = ref([])
const vendorInvoices = ref([])
const incomingInvoices = ref([])
const bankAccounts = ref([])
const bankStatements = ref([])
const historyItems = ref([])
@@ -71,7 +72,7 @@ export const useDataStore = defineStore('data', () => {
await fetchSpaces()
await fetchVehicles()
await fetchVendors()
await fetchVendorInvoices()
await fetchIncomingInvoices()
await fetchBankAccounts()
await fetchBankStatements()
await fetchHistoryItems()
@@ -105,7 +106,7 @@ export const useDataStore = defineStore('data', () => {
contacts.value= []
vehicles.value= []
vendors.value= []
vendorInvoices.value= []
incomingInvoices.value= []
bankAccounts.value= []
bankStatements.value= []
historyItems.value = []
@@ -170,16 +171,17 @@ export const useDataStore = defineStore('data', () => {
vehicles.value = (await supabase.from("vehicles").select()).data
}
async function fetchTimes () {
times.value = (await supabase.from("times").select()).data
times.value = (await supabase.from("times").select().order("start", {ascending:false})).data
}
async function fetchHistoryItems () {
historyItems.value = (await supabase.from("historyItems").select()).data
}
async function fetchVendors () {
vendors.value = (await supabase.from("vendors").select().order("vendorNumber", {ascending:true})).data
}
async function fetchVendorInvoices () {
vendorInvoices.value = (await supabase.from("vendorInvoices").select()).data
async function fetchIncomingInvoices () {
incomingInvoices.value = (await supabase.from("incomingInvoices").select()).data
}
async function fetchNumberRanges () {
numberRanges.value = (await supabase.from("numberRanges").select()).data
@@ -273,6 +275,10 @@ export const useDataStore = defineStore('data', () => {
return historyItems.value.filter(item => item.vendor === vendorId)
})
const getIncomingInvoicesByVehicleId = computed(() => (vehicleId:string) => {
return incomingInvoices.value.filter(i => i.accounts.find(a => a.costCentre === vehicleId))
})
const getMovementsBySpaceId = computed(() => (spaceId:string) => {
return movements.value.filter(movement => movement.spaceId === spaceId)
})
@@ -301,18 +307,22 @@ export const useDataStore = defineStore('data', () => {
return ownTenant.value.tags.documents
})
const getMeasures = computed(() => {
return ownTenant.value.measures
})
const getResources = computed(() => {
return [
...profiles.value.map(profile => {
return {
type: 'person',
type: 'Mitarbeiter',
title: profile.fullName,
id: profile.id
}
}),
...vehicles.value.map(vehicle => {
return {
type: 'vehicle',
type: 'Fahrzeug',
title: vehicle.licensePlate,
id: vehicle.licensePlate
}
@@ -327,6 +337,7 @@ export const useDataStore = defineStore('data', () => {
return {
...event,
title: !event.title ? projects.value.find(i => i.id === event.project).name : event.title,
borderColor: eventColor,
textColor: eventColor,
backgroundColor: "black"
@@ -345,6 +356,23 @@ export const useDataStore = defineStore('data', () => {
]
})
const getCostCentresComposed = computed(() => {
return [
...vehicles.value.map(vehicle => {
return {
label: "Fahrzeug - " + vehicle.licensePlate,
id: vehicle.id
}
}),
...projects.value.map(project => {
return {
label: "Projekt - " + project.name,
id: project.id
}
})
]
})
//Get Item By Id
const getProductById = computed(() => (itemId:string) => {
@@ -355,8 +383,8 @@ export const useDataStore = defineStore('data', () => {
return vendors.value.find(item => item.id === itemId)
})
const getVendorInvoiceById = computed(() => (itemId:string) => {
return vendorInvoices.value.find(item => item.id === itemId)
const getIncomingInvoiceById = computed(() => (itemId:string) => {
return incomingInvoices.value.find(item => item.id === itemId)
})
const getContractById = computed(() => (itemId:string) => {
@@ -443,7 +471,7 @@ export const useDataStore = defineStore('data', () => {
contacts,
vehicles,
vendors,
vendorInvoices,
incomingInvoices,
bankAccounts,
bankStatements,
historyItems,
@@ -476,7 +504,7 @@ export const useDataStore = defineStore('data', () => {
fetchTimes,
fetchHistoryItems,
fetchVendors,
fetchVendorInvoices,
fetchIncomingInvoices,
fetchNumberRanges,
fetchNotifications,
fetchDocuments,
@@ -495,14 +523,17 @@ export const useDataStore = defineStore('data', () => {
getStockByProductId,
getHistoryItemsByCustomer,
getHistoryItemsByVendor,
getIncomingInvoicesByVehicleId,
getEventTypes,
getTimeTypes,
getDocumentTags,
getMeasures,
getResources,
getEvents,
getCostCentresComposed,
getProductById,
getVendorById,
getVendorInvoiceById,
getIncomingInvoiceById,
getContractById,
getContactById,
getVehicleById,