Introduced ProfileStore
Corrected All Links to DataStore
This commit is contained in:
@@ -5,6 +5,7 @@ import {useNumberRange} from "~/composables/useNumberRange.js";
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const user = useSupabaseUser()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -37,7 +38,7 @@ const itemInfo = ref({
|
||||
deliveryDateType: "Lieferdatum",
|
||||
dateOfPerformance: null,
|
||||
paymentDays: 7,
|
||||
createdBy: dataStore.activeProfile.id,
|
||||
createdBy: profileStore.activeProfile.id,
|
||||
title: null,
|
||||
description: null,
|
||||
startText: null,
|
||||
@@ -45,7 +46,7 @@ const itemInfo = ref({
|
||||
rows: [
|
||||
|
||||
],
|
||||
contactPerson: dataStore.activeProfile.id,
|
||||
contactPerson: profileStore.activeProfile.id,
|
||||
contactPersonName: null,
|
||||
contactTel: null,
|
||||
contactEMail: null,
|
||||
@@ -74,6 +75,7 @@ const servicecategories = ref([])
|
||||
const selectedServicecategorie = ref(null)
|
||||
const customers = ref([])
|
||||
const contacts = ref([])
|
||||
const texttemplates = ref([])
|
||||
|
||||
const loaded = ref(false)
|
||||
const setupPage = async () => {
|
||||
@@ -87,6 +89,7 @@ const setupPage = async () => {
|
||||
productcategories.value = (await useSupabaseSelect("productcategories","*"))
|
||||
customers.value = (await useSupabaseSelect("customers","*","customerNumber"))
|
||||
contacts.value = (await useSupabaseSelect("contacts","*"))
|
||||
texttemplates.value = (await useSupabaseSelect("texttemplates","*"))
|
||||
if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id
|
||||
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
|
||||
|
||||
@@ -216,8 +219,8 @@ const setDocumentTypeConfig = (withTexts = false) => {
|
||||
}
|
||||
|
||||
if(withTexts) {
|
||||
itemInfo.value.startText = dataStore.getTextTemplatesByDocumentType(itemInfo.value.type).find(i => i.default && i.pos === "startText").text
|
||||
itemInfo.value.endText = dataStore.getTextTemplatesByDocumentType(itemInfo.value.type).find(i => i.default && i.pos === "endText").text
|
||||
itemInfo.value.startText = texttemplates.value.find(i => i.documentType === itemInfo.value.type && i.default && i.pos === "startText").text
|
||||
itemInfo.value.endText = texttemplates.value.find(i => i.documentType === itemInfo.value.type && i.default && i.pos === "endText").text
|
||||
}
|
||||
|
||||
itemInfo.value.letterhead = letterheads.value[0].id
|
||||
@@ -310,7 +313,7 @@ const addPosition = (mode) => {
|
||||
discountPercent: 0
|
||||
}
|
||||
|
||||
itemInfo.value.rows.push({...rowData, ...dataStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
||||
itemInfo.value.rows.push({...rowData, ...profileStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
||||
|
||||
} else if(mode === 'normal'){
|
||||
itemInfo.value.rows.push({
|
||||
@@ -334,7 +337,7 @@ const addPosition = (mode) => {
|
||||
}
|
||||
|
||||
//Push Agriculture Holder only if Module is activated
|
||||
itemInfo.value.rows.push({...rowData, ...dataStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
||||
itemInfo.value.rows.push({...rowData, ...profileStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
||||
} else if(mode === "pagebreak") {
|
||||
itemInfo.value.rows.push({
|
||||
id: uuidv4(),
|
||||
@@ -373,7 +376,7 @@ const removePosition = (id) => {
|
||||
|
||||
const getRowMargin = (row) => {
|
||||
if(row.mode === "normal" && row.product) {
|
||||
let purchasePrice = dataStore.getProductById(row.product).purchasePrice || 0
|
||||
let purchasePrice = products.value.find(i => i.id === row.product).purchasePrice || 0
|
||||
return row.price - purchasePrice
|
||||
} else {
|
||||
return 0
|
||||
@@ -530,9 +533,9 @@ const getDocumentData = () => {
|
||||
|
||||
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
|
||||
let contactData = dataStore.getContactById(itemInfo.value.contact)
|
||||
let businessInfo = dataStore.ownTenant.businessInfo
|
||||
let businessInfo = profileStore.ownTenant.businessInfo
|
||||
|
||||
if(dataStore.ownTenant.extraModules.includes("agriculture")) {
|
||||
if(profileStore.ownTenant.extraModules.includes("agriculture")) {
|
||||
itemInfo.value.rows.forEach(row => {
|
||||
if(row.agriculture && row.agriculture.dieselUsage) {
|
||||
row.agriculture.description = `${row.agriculture.dieselUsage} L Diesel zu ${renderCurrency(row.agriculture.dieselPrice)}/L verbraucht ${row.description ? "\n" + row.description : ""}`
|
||||
@@ -555,7 +558,7 @@ const getDocumentData = () => {
|
||||
}
|
||||
|
||||
if(!['pagebreak','title','text'].includes(row.mode)) {
|
||||
if(row.mode === 'normal') row.text = dataStore.getProductById(row.product).name
|
||||
if(row.mode === 'normal') row.text = products.value.find(i => i.id === row.product).name
|
||||
if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name
|
||||
|
||||
|
||||
@@ -630,7 +633,7 @@ const getDocumentData = () => {
|
||||
const showDocument = ref(false)
|
||||
const uri = ref("")
|
||||
const generateDocument = async () => {
|
||||
const ownTenant = dataStore.ownTenant
|
||||
const ownTenant = profileStore.ownTenant
|
||||
const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path
|
||||
|
||||
|
||||
@@ -717,7 +720,7 @@ const saveDocument = async (state) => {
|
||||
setDocumentTypeConfig(false)
|
||||
}
|
||||
|
||||
if(dataStore.ownTenant.extraModules.includes("agriculture")) {
|
||||
if(profileStore.ownTenant.extraModules.includes("agriculture")) {
|
||||
itemInfo.value.rows.forEach(row => {
|
||||
if(row.agriculture && row.agriculture.dieselUsage) {
|
||||
row.agriculture.description = `${row.agriculture.dieselUsage} L Diesel zu ${renderCurrency(row.agriculture.dieselPrice)}/L verbraucht ${row.description ? "\n" + row.description : ""}`
|
||||
@@ -1193,7 +1196,7 @@ setupPage()
|
||||
label="Ansprechpartner:"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
v-model="itemInfo.contactPerson"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
@@ -1464,12 +1467,12 @@ setupPage()
|
||||
searchable-placeholder="Suche ..."
|
||||
:search-attributes="['name']"
|
||||
v-model="row.product"
|
||||
@change="row.unit = dataStore.getProductById(row.product).unit,
|
||||
row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
|
||||
row.description = dataStore.getProductById(row.product).description"
|
||||
@change="row.unit = products.find(i => i.id === row.product).unit,
|
||||
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
|
||||
row.description = products.find(i => i.id === row.product).description"
|
||||
>
|
||||
<template #label>
|
||||
<span class="truncate">{{row.product ? dataStore.getProductById(row.product).name : "Kein Produkt ausgewählt" }}</span>
|
||||
<span class="truncate">{{row.product ? products.find(i => i.id === row.product).name : "Kein Produkt ausgewählt" }}</span>
|
||||
</template>
|
||||
</USelectMenu>
|
||||
<UButton
|
||||
@@ -1503,9 +1506,9 @@ setupPage()
|
||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Artikel anzuzeigen' }"
|
||||
@select=" (i) => {
|
||||
row.product = i.id
|
||||
row.unit = dataStore.getProductById(row.product).unit,
|
||||
row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
|
||||
row.description = dataStore.getProductById(row.product).description
|
||||
row.unit = products.find(i => i.id === row.product).unit,
|
||||
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
|
||||
row.description = products.find(i => i.id === row.product).description
|
||||
showProductSelectionModal = false}"
|
||||
>
|
||||
|
||||
@@ -1514,9 +1517,6 @@ setupPage()
|
||||
</UModal>
|
||||
</InputGroup>
|
||||
|
||||
<!--
|
||||
{{dataStore.getProductById(66)}}
|
||||
-->
|
||||
</td>
|
||||
<td
|
||||
class="w-120"
|
||||
|
||||
@@ -280,10 +280,6 @@ const isPaid = (item) => {
|
||||
let amountPaid = 0
|
||||
item.statementallocations.forEach(allocation => amountPaid += allocation.amount)
|
||||
|
||||
console.log(item.documentNumber)
|
||||
console.log(amountPaid)
|
||||
console.log(calculateDocSum(item))
|
||||
|
||||
return Number(amountPaid.toFixed(2)) === Number(calculateDocSum(item))
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -12,6 +12,7 @@ defineShortcuts({
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
@@ -26,7 +27,7 @@ const setupPage = async () => {
|
||||
|
||||
}
|
||||
|
||||
currentTenant.value = (await supabase.from("tenants").select().eq("id",dataStore.currentTenant).single()).data
|
||||
currentTenant.value = (await supabase.from("tenants").select().eq("id",profileStore.currentTenant).single()).data
|
||||
console.log(currentTenant.value)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user