diff --git a/stores/data.js b/stores/data.js index 27c2e7d..222ab71 100644 --- a/stores/data.js +++ b/stores/data.js @@ -1134,6 +1134,38 @@ export const useDataStore = defineStore('data', () => { selectSearchAttributes: ['name'], 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", label: "Beschreibung", @@ -1417,11 +1449,9 @@ export const useDataStore = defineStore('data', () => { const bankrequisitions = ref([]) const historyItems = ref([]) const notifications = ref([]) - const absencerequests = ref([]) const accounts = ref([]) const taxTypes = ref([]) const plants = ref([]) - const inventoryitems = ref([]) const chats = ref([]) const messages = ref([]) const createddocuments = ref([]) @@ -1429,8 +1459,6 @@ export const useDataStore = defineStore('data', () => { const phasesTemplates = ref([]) const emailAccounts = ref([]) const texttemplates =ref([]) - const services =ref([]) - const servicecategories =ref([]) const resources =ref([]) async function fetchData () { @@ -1456,11 +1484,9 @@ export const useDataStore = defineStore('data', () => { await fetchBankRequisitions() await fetchHistoryItems() await fetchNotifications() - await fetchAbsenceRequests() await fetchAccounts() await fetchTaxTypes() await fetchPlants() - await fetchInventoryItems() await fetchChats() await fetchMessages() await fetchCreatedDocuments() @@ -1468,8 +1494,6 @@ export const useDataStore = defineStore('data', () => { await fetchPhasesTemplates() await fetchEmailAccounts() await fetchTextTemplates() - await fetchServices() - await fetchServiceCategories() await fetchResources() } @@ -1496,11 +1520,9 @@ export const useDataStore = defineStore('data', () => { bankrequisitions.value= [] historyItems.value = [] notifications.value = [] - absencerequests.value = [] accounts.value = [] taxTypes.value = [] plants.value = [] - inventoryitems.value = [] chats.value = [] messages.value = [] createddocuments.value = [] @@ -1508,8 +1530,6 @@ export const useDataStore = defineStore('data', () => { phasesTemplates.value = [] emailAccounts.value = [] texttemplates.value = [] - services.value = [] - servicecategories.value = [] resources.value = [] } @@ -1885,7 +1905,7 @@ export const useDataStore = defineStore('data', () => { 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) + ')') } @@ -2094,9 +2114,6 @@ export const useDataStore = defineStore('data', () => { async function fetchNotifications () { 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 () { accounts.value = (await supabase.from("accounts").select()).data } @@ -2106,9 +2123,6 @@ export const useDataStore = defineStore('data', () => { async function fetchPlants () { 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() { 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 } - 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() { resources.value = (await supabase.from("resources").select().eq('tenant', profileStore.currentTenant)).data } @@ -2200,94 +2206,10 @@ export const useDataStore = defineStore('data', () => { //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) => { 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) => { 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) }) - 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(() => () => { return workingtimes.value.filter(i => !i.endDate) }) @@ -2335,39 +2245,6 @@ export const useDataStore = defineStore('data', () => { 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(() => { return profileStore.ownTenant.calendarConfig.eventTypes }) @@ -2380,10 +2257,6 @@ export const useDataStore = defineStore('data', () => { return profileStore.ownTenant.tags.documents }) - const getMeasures = computed(() => { - return profileStore.ownTenant.measures - }) - const getResources = computed(() => { return [ ...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(() => { return [ ...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) => { 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) }) - const getContractById = computed(() => (itemId) => { - return contracts.value.find(item => item.id === itemId) - }) - const getContactById = computed(() => (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) => { return documents.value.find(item => item.id === itemId) }) - const getSpaceById = computed(() => (itemId) => { - return spaces.value.find(item => item.id === itemId) - }) - const getCustomerById = computed(() => (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) => { return accounts.value.find(item => item.id === accountId) }) - const getPlantById = computed(() => (plantId) => { - return plants.value.find(item => item.id === plantId) - }) - const getCreatedDocumentById = computed(() => (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) => { return bankAccounts.value.find(item => item.id === itemId) }) @@ -2622,13 +2435,6 @@ export const useDataStore = defineStore('data', () => { const getWorkingTimeById = computed(() => (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) => { if(projects.value.find(i => i.id === itemId)) { @@ -2656,7 +2462,6 @@ export const useDataStore = defineStore('data', () => { dataTypes, //Data - events, customers, tasks, projects, @@ -2678,11 +2483,9 @@ export const useDataStore = defineStore('data', () => { bankrequisitions, historyItems, notifications, - absencerequests, accounts, taxTypes, plants, - inventoryitems, chats, messages, createddocuments, @@ -2690,8 +2493,6 @@ export const useDataStore = defineStore('data', () => { phasesTemplates, emailAccounts, texttemplates, - services, - servicecategories, documentTypesForCreation, //Functions @@ -2704,64 +2505,28 @@ export const useDataStore = defineStore('data', () => { fetchDocuments, fetchWorkingTimes, //Getters - getOpenTasksCount, - getMovementsBySpace, - getContactsByCustomerId, - getPlantsByCustomerId, - getContractsByCustomerId, - getContactsByVendorId, - getDocumentsByProjectId, getDocumentsByProfileId, - getDocumentsByInventoryItemId, - getDocumentsByPlantId, - getDocumentsByContractId, - getDocumentsByCheckId, - getDocumentsByVehicleId, - getDocumentsByProductId, - getDocumentsByVendorId, - getEventsByProjectId, - getTimesByProjectId, - getTasksByProjectId, - getTasksByPlantId, - getProjectsByPlantId, - getMovementsBySpaceId, getMessagesByChatId, getTextTemplatesByDocumentType, - getCreatedDocumentsByProject, - getCreatedDocumentsByType, - getWorkingTimesByProfileId, getStartedWorkingTimes, getStockByProductId, - getStocksByProjectId, - getIncomingInvoicesByVehicleId, getEventTypes, getTimeTypes, getDocumentTags, - getMeasures, getResources, - getResourcesList, getEvents, getEventsByResource, getCostCentresComposed, - getProductById, getServiceById, getVendorById, getIncomingInvoiceById, - getContractById, getContactById, - getVehicleById, getDocumentById, - getSpaceById, getCustomerById, - getTaskById, - getAbsenceRequestById, getProjectById, getAccountById, - getPlantById, getCreatedDocumentById, - getInventoryItemById, getBankAccountById, getWorkingTimeById, - getOpenIncomingInvoices } }) \ No newline at end of file