Tidying and Datatype Changes

This commit is contained in:
2024-12-28 14:34:07 +01:00
parent 8cfa5eaa43
commit 156ca348aa

View File

@@ -1134,6 +1134,38 @@ export const useDataStore = defineStore('data', () => {
selectSearchAttributes: ['name'], selectSearchAttributes: ['name'],
selectMultiple: true selectMultiple: true
}, },
{
key: "sellingPriceComposed.worker",
label: "Verkaufspreis Personal pro Einheit",
inputType: "number",
inputChangeFunction: function (row) {
if(row.sellingPriceComposed.worker) {
row.sellingPriceComposed.total = row.sellingPriceComposed.worker + (row.sellingPriceComposed.material || 0)
row.sellingPrice = row.sellingPriceComposed.total
}
},
},
{
key: "sellingPriceComposed.material",
label: "Verkaufspreis Material pro Einheit",
inputType: "number",
inputChangeFunction: function (row) {
if(row.sellingPriceComposed.material) {
row.sellingPriceComposed.total = (row.sellingPriceComposed.worker || 0) + row.sellingPriceComposed.material
row.sellingPrice = row.sellingPriceComposed.total
}
},
},
{
key: "sellingPriceComposed.total",
label: "Verkaufspreis Gesamt",
inputType: "number",
disabledFunction: function (item) {
return item.sellingPriceComposed.worker || item.sellingPriceComposed.material
},
},
{ {
key: "description", key: "description",
label: "Beschreibung", label: "Beschreibung",
@@ -1417,11 +1449,9 @@ export const useDataStore = defineStore('data', () => {
const bankrequisitions = ref([]) const bankrequisitions = ref([])
const historyItems = ref([]) const historyItems = ref([])
const notifications = ref([]) const notifications = ref([])
const absencerequests = ref([])
const accounts = ref([]) const accounts = ref([])
const taxTypes = ref([]) const taxTypes = ref([])
const plants = ref([]) const plants = ref([])
const inventoryitems = ref([])
const chats = ref([]) const chats = ref([])
const messages = ref([]) const messages = ref([])
const createddocuments = ref([]) const createddocuments = ref([])
@@ -1429,8 +1459,6 @@ export const useDataStore = defineStore('data', () => {
const phasesTemplates = ref([]) const phasesTemplates = ref([])
const emailAccounts = ref([]) const emailAccounts = ref([])
const texttemplates =ref([]) const texttemplates =ref([])
const services =ref([])
const servicecategories =ref([])
const resources =ref([]) const resources =ref([])
async function fetchData () { async function fetchData () {
@@ -1456,11 +1484,9 @@ export const useDataStore = defineStore('data', () => {
await fetchBankRequisitions() await fetchBankRequisitions()
await fetchHistoryItems() await fetchHistoryItems()
await fetchNotifications() await fetchNotifications()
await fetchAbsenceRequests()
await fetchAccounts() await fetchAccounts()
await fetchTaxTypes() await fetchTaxTypes()
await fetchPlants() await fetchPlants()
await fetchInventoryItems()
await fetchChats() await fetchChats()
await fetchMessages() await fetchMessages()
await fetchCreatedDocuments() await fetchCreatedDocuments()
@@ -1468,8 +1494,6 @@ export const useDataStore = defineStore('data', () => {
await fetchPhasesTemplates() await fetchPhasesTemplates()
await fetchEmailAccounts() await fetchEmailAccounts()
await fetchTextTemplates() await fetchTextTemplates()
await fetchServices()
await fetchServiceCategories()
await fetchResources() await fetchResources()
} }
@@ -1496,11 +1520,9 @@ export const useDataStore = defineStore('data', () => {
bankrequisitions.value= [] bankrequisitions.value= []
historyItems.value = [] historyItems.value = []
notifications.value = [] notifications.value = []
absencerequests.value = []
accounts.value = [] accounts.value = []
taxTypes.value = [] taxTypes.value = []
plants.value = [] plants.value = []
inventoryitems.value = []
chats.value = [] chats.value = []
messages.value = [] messages.value = []
createddocuments.value = [] createddocuments.value = []
@@ -1508,8 +1530,6 @@ export const useDataStore = defineStore('data', () => {
phasesTemplates.value = [] phasesTemplates.value = []
emailAccounts.value = [] emailAccounts.value = []
texttemplates.value = [] texttemplates.value = []
services.value = []
servicecategories.value = []
resources.value = [] resources.value = []
} }
@@ -1885,7 +1905,7 @@ export const useDataStore = defineStore('data', () => {
await generateHistoryItems(dataType, supabaseData[0]) await generateHistoryItems(dataType, supabaseData[0])
if(!["statementallocations", "productcategories", "projecttypes", "checks"].includes(dataType) ){ if(!["statementallocations", "productcategories", "projecttypes", "checks", "profiles"].includes(dataType) ){
await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')') await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')')
} }
@@ -2094,9 +2114,6 @@ export const useDataStore = defineStore('data', () => {
async function fetchNotifications () { async function fetchNotifications () {
notifications.value = (await supabase.from("notifications").select().eq('tenant', profileStore.currentTenant).order("created_at", {ascending: false})).data notifications.value = (await supabase.from("notifications").select().eq('tenant', profileStore.currentTenant).order("created_at", {ascending: false})).data
} }
async function fetchAbsenceRequests () {
absencerequests.value = (await supabase.from("absencerequests").select().eq('tenant', profileStore.currentTenant)).data
}
async function fetchAccounts () { async function fetchAccounts () {
accounts.value = (await supabase.from("accounts").select()).data accounts.value = (await supabase.from("accounts").select()).data
} }
@@ -2106,9 +2123,6 @@ export const useDataStore = defineStore('data', () => {
async function fetchPlants () { async function fetchPlants () {
plants.value = (await supabase.from("plants").select().eq('tenant', profileStore.currentTenant)).data plants.value = (await supabase.from("plants").select().eq('tenant', profileStore.currentTenant)).data
} }
async function fetchInventoryItems () {
inventoryitems.value = (await supabase.from("inventoryitems").select().eq('tenant', profileStore.currentTenant)).data
}
async function fetchChats() { async function fetchChats() {
chats.value = (await supabase.from("chats").select()).data chats.value = (await supabase.from("chats").select()).data
} }
@@ -2135,14 +2149,6 @@ export const useDataStore = defineStore('data', () => {
texttemplates.value = (await supabase.from("texttemplates").select().eq('tenant', profileStore.currentTenant)).data texttemplates.value = (await supabase.from("texttemplates").select().eq('tenant', profileStore.currentTenant)).data
} }
async function fetchServices() {
services.value = (await supabase.from("services").select().eq('tenant', profileStore.currentTenant)).data
}
async function fetchServiceCategories() {
servicecategories.value = (await supabase.from("servicecategories").select().eq('tenant', profileStore.currentTenant)).data
}
async function fetchResources() { async function fetchResources() {
resources.value = (await supabase.from("resources").select().eq('tenant', profileStore.currentTenant)).data resources.value = (await supabase.from("resources").select().eq('tenant', profileStore.currentTenant)).data
} }
@@ -2200,94 +2206,10 @@ export const useDataStore = defineStore('data', () => {
//Getters //Getters
const getOpenTasksCount = computed(() => {
return tasks.value.filter(task => task.categorie != "Erledigt").length
})
const getMovementsBySpace = computed(() => (spaceId) => {
return movements.value.filter(movement => movement.spaceId === spaceId)
})
async function getContactsByCustomerId (itemId) {
return (await supabase.from("contacts").select().eq("customer", itemId)).data
}
const getPlantsByCustomerId = computed(() => (customerId) => {
return plants.value.filter(item => item.customer === customerId)
})
const getContractsByCustomerId = computed(() => (customerId) => {
return contracts.value.filter(item => item.customer === customerId)
})
const getContactsByVendorId = computed(() => (vendorId) => {
return contacts.value.filter(item => item.vendor === vendorId)
})
const getDocumentsByProjectId = computed(() => (projectId) => {
return documents.value.filter(item => item.project === projectId && !item.tags.includes("Archiviert"))
})
const getDocumentsByProfileId = computed(() => (profileId) => { const getDocumentsByProfileId = computed(() => (profileId) => {
return documents.value.filter(item => item.profile === profileId && !item.tags.includes("Archiviert")) return documents.value.filter(item => item.profile === profileId && !item.tags.includes("Archiviert"))
}) })
const getDocumentsByInventoryItemId = computed(() => (itemId) => {
return documents.value.filter(item => item.inventoryitem === itemId && !item.tags.includes("Archiviert"))
})
const getDocumentsByPlantId = computed(() => (itemId) => {
return documents.value.filter(item => item.plant === itemId && !item.tags.includes("Archiviert"))
})
const getDocumentsByContractId = computed(() => (itemId) => {
return documents.value.filter(item => item.contract === itemId && !item.tags.includes("Archiviert"))
})
const getDocumentsByCheckId = computed(() => (itemId) => {
return documents.value.filter(item => item.check === itemId && !item.tags.includes("Archiviert"))
})
const getDocumentsByVehicleId = computed(() => (itemId) => {
return documents.value.filter(item => item.vehicle === itemId && !item.tags.includes("Archiviert"))
})
const getDocumentsByProductId = computed(() => (itemId) => {
return documents.value.filter(item => item.product === itemId && !item.tags.includes("Archiviert"))
})
const getDocumentsByVendorId = computed(() => (itemId) => {
return documents.value.filter(item => item.vendor === itemId && !item.tags.includes("Archiviert"))
})
const getEventsByProjectId = computed(() => (projectId) => {
return events.value.filter(item => item.project === projectId)
})
const getTimesByProjectId = computed(() => (projectId) => {
return times.value.filter(time => time.projectId === projectId)
})
const getTasksByProjectId = computed(() => (projectId) => {
return tasks.value.filter(item => item.project === projectId)
})
const getTasksByPlantId = computed(() => (plantId) => {
return tasks.value.filter(item => item.plant === plantId)
})
const getProjectsByPlantId = computed(() => (plantId) => {
return projects.value.filter(item => item.plant === plantId)
})
const getIncomingInvoicesByVehicleId = computed(() => (vehicleId) => {
return incominginvoices.value.filter(i => i.accounts.find(a => a.costCentre === vehicleId))
})
const getMovementsBySpaceId = computed(() => (spaceId) => {
return movements.value.filter(movement => movement.spaceId === spaceId)
})
const getMessagesByChatId = computed(() => (chatId) => { const getMessagesByChatId = computed(() => (chatId) => {
return messages.value.filter(i => i.destination === chatId) return messages.value.filter(i => i.destination === chatId)
}) })
@@ -2307,18 +2229,6 @@ export const useDataStore = defineStore('data', () => {
return texttemplates.value.filter(i => i.documentType === type) return texttemplates.value.filter(i => i.documentType === type)
}) })
const getCreatedDocumentsByProject = computed(() => (project) => {
return createddocuments.value.filter(i => i.project === project)
})
const getCreatedDocumentsByType = computed(() => (type) => {
return createddocuments.value.filter(i => i.type === type)
})
const getWorkingTimesByProfileId = computed(() => (profileId) => {
return workingtimes.value.filter(i => i.profile === profileId)
})
const getStartedWorkingTimes = computed(() => () => { const getStartedWorkingTimes = computed(() => () => {
return workingtimes.value.filter(i => !i.endDate) return workingtimes.value.filter(i => !i.endDate)
}) })
@@ -2335,39 +2245,6 @@ export const useDataStore = defineStore('data', () => {
return count return count
}) })
const getStocksByProjectId = computed(() => (projectId) => {
let projectMovements = movements.value.filter(movement => movement.projectId === projectId)
let projectProducts = [... new Set(projectMovements.map(i => i.productId))]
console.log(projectProducts)
let productStocks = []
projectProducts.forEach(product => {
let count = 0
let productMovements = movements.value.filter(i => i.productId === product && i.projectId && projectId)
productMovements.forEach(movement => {
count += movement.quantity
})
productStocks.push({
productId: product,
stock: count
})
})
/*let count = 0
projectMovements.forEach(movement => {
count += movement.quantity
})*/
return productStocks
})
const getEventTypes = computed(() => { const getEventTypes = computed(() => {
return profileStore.ownTenant.calendarConfig.eventTypes return profileStore.ownTenant.calendarConfig.eventTypes
}) })
@@ -2380,10 +2257,6 @@ export const useDataStore = defineStore('data', () => {
return profileStore.ownTenant.tags.documents return profileStore.ownTenant.tags.documents
}) })
const getMeasures = computed(() => {
return profileStore.ownTenant.measures
})
const getResources = computed(() => { const getResources = computed(() => {
return [ return [
...profiles.value.filter(i => i.tenant === profileStore.currentTenant).map(profile => { ...profiles.value.filter(i => i.tenant === profileStore.currentTenant).map(profile => {
@@ -2410,32 +2283,6 @@ export const useDataStore = defineStore('data', () => {
] ]
}) })
const getResourcesList = computed(() => {
return [
...profiles.value.filter(i => i.tenant === profileStore.currentTenant).map(profile => {
return {
type: 'Mitarbeiter',
title: profile.fullName,
id: profile.id
}
}),
...vehicles.value.map(vehicle => {
return {
type: 'Fahrzeug',
title: vehicle.licensePlate,
id: vehicle.id
}
}),
...inventoryitems.value.filter(i=> i.usePlanning).map(item => {
return {
type: 'Inventar',
title: item.name,
id: item.id
}
})
]
})
const getEvents = computed(() => { const getEvents = computed(() => {
return [ return [
...events.value.map(event => { ...events.value.map(event => {
@@ -2549,12 +2396,6 @@ export const useDataStore = defineStore('data', () => {
] ]
}) })
//Get Item By Id
const getProductById = computed(() => (itemId) => {
return products.value.find(item => item.id === itemId)
})
const getServiceById = computed(() => (itemId) => { const getServiceById = computed(() => (itemId) => {
return services.value.find(item => item.id === itemId) return services.value.find(item => item.id === itemId)
}) })
@@ -2567,54 +2408,26 @@ export const useDataStore = defineStore('data', () => {
return incominginvoices.value.find(item => item.id === itemId) return incominginvoices.value.find(item => item.id === itemId)
}) })
const getContractById = computed(() => (itemId) => {
return contracts.value.find(item => item.id === itemId)
})
const getContactById = computed(() => (itemId) => { const getContactById = computed(() => (itemId) => {
return contacts.value.find(item => item.id === itemId) return contacts.value.find(item => item.id === itemId)
}) })
const getVehicleById = computed(() => (itemId) => {
return vehicles.value.find(item => item.id === itemId)
})
const getDocumentById = computed(() => (itemId) => { const getDocumentById = computed(() => (itemId) => {
return documents.value.find(item => item.id === itemId) return documents.value.find(item => item.id === itemId)
}) })
const getSpaceById = computed(() => (itemId) => {
return spaces.value.find(item => item.id === itemId)
})
const getCustomerById = computed(() => (itemId) => { const getCustomerById = computed(() => (itemId) => {
return customers.value.find(item => item.id === itemId) return customers.value.find(item => item.id === itemId)
}) })
const getTaskById = computed(() => (itemId) => {
return tasks.value.find(item => item.id === itemId)
})
const getAbsenceRequestById = computed(() => (itemId) => {
return absencerequests.value.find(item => item.id === itemId)
})
const getAccountById = computed(() => (accountId) => { const getAccountById = computed(() => (accountId) => {
return accounts.value.find(item => item.id === accountId) return accounts.value.find(item => item.id === accountId)
}) })
const getPlantById = computed(() => (plantId) => {
return plants.value.find(item => item.id === plantId)
})
const getCreatedDocumentById = computed(() => (documentId) => { const getCreatedDocumentById = computed(() => (documentId) => {
return createddocuments.value.find(item => item.id === documentId) return createddocuments.value.find(item => item.id === documentId)
}) })
const getInventoryItemById = computed(() => (itemId) => {
return inventoryitems.value.find(item => item.id === itemId)
})
const getBankAccountById = computed(() => (itemId) => { const getBankAccountById = computed(() => (itemId) => {
return bankAccounts.value.find(item => item.id === itemId) return bankAccounts.value.find(item => item.id === itemId)
}) })
@@ -2622,13 +2435,6 @@ export const useDataStore = defineStore('data', () => {
const getWorkingTimeById = computed(() => (itemId) => { const getWorkingTimeById = computed(() => (itemId) => {
return workingtimes.value.find(item => item.id === itemId) return workingtimes.value.find(item => item.id === itemId)
}) })
const getOpenIncomingInvoices = computed(() => (itemId) => {
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 => !i.paid)
})
const getProjectById = computed(() => (itemId) => { const getProjectById = computed(() => (itemId) => {
if(projects.value.find(i => i.id === itemId)) { if(projects.value.find(i => i.id === itemId)) {
@@ -2656,7 +2462,6 @@ export const useDataStore = defineStore('data', () => {
dataTypes, dataTypes,
//Data //Data
events,
customers, customers,
tasks, tasks,
projects, projects,
@@ -2678,11 +2483,9 @@ export const useDataStore = defineStore('data', () => {
bankrequisitions, bankrequisitions,
historyItems, historyItems,
notifications, notifications,
absencerequests,
accounts, accounts,
taxTypes, taxTypes,
plants, plants,
inventoryitems,
chats, chats,
messages, messages,
createddocuments, createddocuments,
@@ -2690,8 +2493,6 @@ export const useDataStore = defineStore('data', () => {
phasesTemplates, phasesTemplates,
emailAccounts, emailAccounts,
texttemplates, texttemplates,
services,
servicecategories,
documentTypesForCreation, documentTypesForCreation,
//Functions //Functions
@@ -2704,64 +2505,28 @@ export const useDataStore = defineStore('data', () => {
fetchDocuments, fetchDocuments,
fetchWorkingTimes, fetchWorkingTimes,
//Getters //Getters
getOpenTasksCount,
getMovementsBySpace,
getContactsByCustomerId,
getPlantsByCustomerId,
getContractsByCustomerId,
getContactsByVendorId,
getDocumentsByProjectId,
getDocumentsByProfileId, getDocumentsByProfileId,
getDocumentsByInventoryItemId,
getDocumentsByPlantId,
getDocumentsByContractId,
getDocumentsByCheckId,
getDocumentsByVehicleId,
getDocumentsByProductId,
getDocumentsByVendorId,
getEventsByProjectId,
getTimesByProjectId,
getTasksByProjectId,
getTasksByPlantId,
getProjectsByPlantId,
getMovementsBySpaceId,
getMessagesByChatId, getMessagesByChatId,
getTextTemplatesByDocumentType, getTextTemplatesByDocumentType,
getCreatedDocumentsByProject,
getCreatedDocumentsByType,
getWorkingTimesByProfileId,
getStartedWorkingTimes, getStartedWorkingTimes,
getStockByProductId, getStockByProductId,
getStocksByProjectId,
getIncomingInvoicesByVehicleId,
getEventTypes, getEventTypes,
getTimeTypes, getTimeTypes,
getDocumentTags, getDocumentTags,
getMeasures,
getResources, getResources,
getResourcesList,
getEvents, getEvents,
getEventsByResource, getEventsByResource,
getCostCentresComposed, getCostCentresComposed,
getProductById,
getServiceById, getServiceById,
getVendorById, getVendorById,
getIncomingInvoiceById, getIncomingInvoiceById,
getContractById,
getContactById, getContactById,
getVehicleById,
getDocumentById, getDocumentById,
getSpaceById,
getCustomerById, getCustomerById,
getTaskById,
getAbsenceRequestById,
getProjectById, getProjectById,
getAccountById, getAccountById,
getPlantById,
getCreatedDocumentById, getCreatedDocumentById,
getInventoryItemById,
getBankAccountById, getBankAccountById,
getWorkingTimeById, getWorkingTimeById,
getOpenIncomingInvoices
} }
}) })