This commit is contained in:
2024-02-21 16:38:48 +01:00
parent 6e2e419a1c
commit ddb3b90788
13 changed files with 409 additions and 34 deletions

View File

@@ -155,7 +155,7 @@ const updateDocumentAssignment = async () => {
<br>
<UBadge
v-if="documentData.vendorInvoice"
>{{dataStore.incomingInvoices.find(item => item.id === documentData.vendorInvoice) ? dataStore.incomingInvoices.find(item => item.id === documentData.vendorInvoice).reference : ''}}</UBadge>
>{{dataStore.incominginvoices.find(item => item.id === documentData.vendorInvoice) ? dataStore.incominginvoices.find(item => item.id === documentData.vendorInvoice).reference : ''}}</UBadge>
<UBadge
v-if="documentData.inDatev"
>DATEV</UBadge>

View File

@@ -95,7 +95,7 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
opacity: 1
})*/
pages[pageCounter - 1].drawText("Federspiel Technology UG haftungsbeschränkt, Am Schwarzen Brack 14 26452 Sande", {
pages[pageCounter - 1].drawText(invoiceData.adressLine, {
...getCoordinatesForPDFLib(21,48, page1),
size:6,
color:rgb(0,0,0),

View File

@@ -289,6 +289,10 @@ const links = [[{
label: "Artikelstamm",
to: "/products",
icon: "i-heroicons-puzzle-piece"
},{
label: "Leistungsstamm",
to: "/services",
icon: "i-heroicons-puzzle-piece"
},
{
label: "Lagerplätze",
@@ -445,13 +449,6 @@ const links = [[{
/>
</template>
</UVerticalNavigation>
<UButton
:icon="!isLight ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
color="white"
variant="outline"
aria-label="Theme"
@click="isLight = !isLight"
/>
</div>
<div class="pl-3 pr-3 mt-3" id="contentContainer">

View File

@@ -7,6 +7,10 @@ import resourceTimelinePlugin from "@fullcalendar/resource-timeline";
import interactionPlugin from "@fullcalendar/interaction";
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
//Config
const route = useRoute()
const mode = ref(route.params.mode || "grid")

View File

@@ -9,7 +9,9 @@ const router = useRouter()
const supabase = useSupabaseClient()
definePageMeta({
middleware: "auth"
})
@@ -142,6 +144,15 @@ const addPosition = (mode) => {
taxPercent: 19,
discountPercent: 0
})
} else if(mode === 'service'){
itemInfo.value.rows.push({
id: lastId +1,
mode: "service",
quantity: 1,
price: 0,
taxPercent: 19,
discountPercent: 0
})
} else if(mode === "pagebreak") {
itemInfo.value.rows.push({
id: lastId +1,
@@ -202,6 +213,7 @@ const getDocumentData = () => {
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
let contactData = dataStore.getContactById(itemInfo.value.contact)
let userData = dataStore.getProfileById(user.value.id)
let businessInfo = dataStore.ownTenant.businessInfo
@@ -236,14 +248,14 @@ const getDocumentData = () => {
const returnData = {
adressLine: `${businessInfo.name}, ${businessInfo.street}, ${businessInfo.zip} ${businessInfo.city}`,
recipient: {
name: customerData.name,
contact: contactData ? `${contactData.firstName} ${contactData.lastName}` : "",
street: customerData.infoData.street,
special: "",
city: customerData.infoData.city,
zip: customerData.infoData.zip
street: itemInfo.value.address.street || customerData.infoData.street,
special: itemInfo.value.address.special || customerData.infoData.special,
city: itemInfo.value.address.city || customerData.infoData.city,
zip: itemInfo.value.address.zip || customerData.infoData.zip
},
info: {
customerNumber: customerData.customerNumber,
@@ -276,12 +288,8 @@ const uri = ref("")
const generateDocument = async () => {
const ownTenant = dataStore.ownTenant
const path = ownTenant.letterheadConfig[itemInfo.value.type]
console.log(path)
console.log(ownTenant)
const {data,error} = await supabase.storage.from("files").download(path)
console.log(data)
console.log(error)
uri.value = await useCreatePdf(getDocumentData(), await data.arrayBuffer())
//alert(uri.value)
@@ -297,7 +305,7 @@ const onChangeTab = (index) => {
const setPosNumbers = () => {
let index = 1
let rows = itemInfo.value.rows.map(row => {
if(row.mode === 'free' ||row.mode === 'normal') {
if(row.mode !== 'pagebreak') {
row.pos = index
index += 1
}
@@ -480,29 +488,28 @@ setupPage()
<UInput
v-model="itemInfo.address.street"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.street : 'Straße + Hausnummer'"
:color="itemInfo.address.street ? 'primary' : 'rose'"
/>
<UInput
v-model="itemInfo.address.special"
class="mt-3"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.special : 'Adresszusatz'"
/>
<InputGroup class="mt-3">
<UInput
class="flex-auto"
v-model="itemInfo.address.zip"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.zip : 'PLZ'"
:color="itemInfo.address.zip ? 'primary' : 'rose'"
/>
<UInput
class="flex-auto"
v-model="itemInfo.address.city"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.city : 'Ort'"
:color="itemInfo.address.city ? 'primary' : 'rose'"
/>
</InputGroup>
</UFormGroup>
</div>
<div class="flex-auto">
<UFormGroup
@@ -697,7 +704,7 @@ setupPage()
<UDivider/>
</td>
<td
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>{{row.pos}}</td>
<td
class="w-120"
@@ -729,9 +736,29 @@ setupPage()
</template>
</USelectMenu>
</td>
<td
class="w-120"
v-else-if="row.mode === 'service'"
>
<USelectMenu
:options="dataStore.services"
option-attribute="name"
value-attribute="id"
searchable
searchable-placeholder="Suche ..."
:search-attributes="['name']"
v-model="row.service"
@change="row.unit = dataStore.getServiceById(row.service).unit,
row.price = dataStore.getServiceById(row.service).sellingPrice || 0"
>
<template #label>
{{dataStore.getServiceById(row.service) ? dataStore.getServiceById(row.service).name : "Keine Leistung ausgewählt" }}
</template>
</USelectMenu>
</td>
<td
class="w-20"
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<UInput
v-model="row.quantity"
@@ -742,7 +769,7 @@ setupPage()
</td>
<td
class="w-40"
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<USelectMenu
v-model="row.unit"
@@ -756,7 +783,7 @@ setupPage()
</USelectMenu>
</td>
<td
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<UInput
v-model="row.price"
@@ -770,7 +797,7 @@ setupPage()
</td>
<td
class="w-40"
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<USelectMenu
@@ -788,7 +815,7 @@ setupPage()
</td>
<td
class="w-40"
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<UInput
v-model="row.discountPercent"
@@ -802,7 +829,7 @@ setupPage()
</UInput>
</td>
<td
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<p class="text-right font-bold whitespace-nowrap">{{getRowAmount(row)}} </p>
</td>
@@ -970,6 +997,12 @@ setupPage()
</table>
<InputGroup>
<UButton
@click="addPosition('service')"
class="mt-3"
>
+ Leistungsposition
</UButton>
<UButton
@click="addPosition('normal')"
class="mt-3"

View File

@@ -1,5 +1,7 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const route = useRoute()
const router = useRouter()

View File

@@ -6,6 +6,9 @@ import interactionPlugin from '@fullcalendar/interaction'
import listPlugin from '@fullcalendar/list';
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
const viewport = useViewport()

View File

@@ -3,6 +3,10 @@ import InputGroup from "~/components/InputGroup.vue";
import dayjs from "dayjs";
import HistoryDisplay from "~/components/HistoryDisplay.vue";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()

View File

@@ -184,7 +184,7 @@ const searchString = ref('')
const showDrafts = ref(false)
const filteredRows = computed(() => {
let items = [...dataStore.incomingInvoices.map(i => {return {...i, type: "incomingInvoice"}}),...dataStore.createddocuments]
let items = [...dataStore.incominginvoices.map(i => {return {...i, type: "incomingInvoice"}}),...dataStore.createddocuments]
console.log(dataStore.createddocuments)

View File

@@ -0,0 +1,221 @@
<script setup>
import HistoryDisplay from "~/components/HistoryDisplay.vue";
import DocumentList from "~/components/DocumentList.vue";
import DocumentUpload from "~/components/DocumentUpload.vue";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
let currentItem = ref(null)
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
unit: 1,
tags: []
})
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentItem.value = dataStore.getServiceById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentItem.value
}
const editItem = async () => {
router.push(`/services/edit/${currentItem.value.id}`)
setupPage()
}
const cancelEditorCreate = () => {
mode.value = "show"
itemInfo.value = {
id: 0,
}
}
setupPage()
</script>
<template>
<h1
class="mb-3 truncate font-bold text-2xl"
v-if="currentItem "
>Leistung: {{currentItem.name}}</h1>
<UTabs
:items="[{label: 'Informationen'},{label: 'Logbuch'},{label: 'Dokumente'}]"
v-if="mode === 'show'"
>
<template #item="{item}">
<UCard class="mt-5">
<div
v-if="item.label === 'Informationen'"
>
<Toolbar>
<UButton
v-if="mode === 'show' && currentItem.id"
@click="editItem"
>
Bearbeiten
</UButton>
</Toolbar><!--
<UBadge
v-for="tag in currentItem.tags"
class="mr-2"
>
{{tag}}
</UBadge>
<UDivider
class="my-2"
/>-->
<span v-if="currentItem.sellingPrice">Verkaufspreis: {{Number(currentItem.sellingPrice).toFixed(2)}} <br></span>
</div>
<div
v-if="item.label === 'Logbuch'"
>
<HistoryDisplay
type="product"
v-if="currentItem"
:element-id="currentItem.id"
/>
</div>
<div
v-if="item.label === 'Bestand'"
>
Bestand: {{dataStore.getStockByProductId(currentItem.id)}} {{dataStore.units.find(unit => unit.id === currentItem.unit) ? dataStore.units.find(unit => unit.id === currentItem.unit).name : ""}}
</div>
<div
v-if="item.label === 'Dokumente'"
>
<Toolbar>
<DocumentUpload
type="product"
:element-id="currentItem.id"
/>
</Toolbar>
<DocumentList :documents="dataStore.getDocumentsByProductId(currentItem.id)"/>
</div>
</UCard>
</template>
</UTabs>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header v-if="mode === 'edit'">
{{itemInfo.name}}
</template>
<UFormGroup
label="Name:"
>
<UInput
v-model="itemInfo.name"
/>
</UFormGroup>
<UFormGroup
label="Hersteller:"
>
<UInput
v-model="itemInfo.manufacturer"
/>
</UFormGroup>
<UFormGroup
label="Einheit:"
>
<USelectMenu
v-model="itemInfo.unit"
:options="dataStore.units"
option-attribute="name"
value-attribute="id"
>
<template #label>
{{dataStore.units.find(unit => unit.id === itemInfo.unit) ? dataStore.units.find(unit => unit.id === itemInfo.unit).name : itemInfo.unit }}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Tags:"
>
<USelectMenu
v-model="itemInfo.tags"
:options="dataStore.ownTenant.tags.products"
multiple
/>
</UFormGroup>
<UFormGroup
label="EAN:"
>
<UInput
v-model="itemInfo.ean"
/>
</UFormGroup>
<UFormGroup
label="Barcode:"
>
<UInput
v-model="itemInfo.barcode"
/>
</UFormGroup>
<UFormGroup
label="Einkaufspreis:"
>
<UInput
v-model="itemInfo.purchasePrice"
type="number"
steps="0.01"
>
<template #trailing>
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
</template>
</UInput>
</UFormGroup>
<template #footer>
<UButton
v-if="mode == 'edit'"
@click="dataStore.updateItem('products',itemInfo)"
>
Speichern
</UButton>
<UButton
v-else-if="mode == 'create'"
@click="dataStore.createNewItem('products',itemInfo)"
>
Erstellen
</UButton>
<UButton
@click="cancelEditorCreate"
color="red"
class="ml-2"
>
Abbrechen
</UButton>
</template>
</UCard>
</template>
<style scoped>
</style>

View File

@@ -0,0 +1,96 @@
<template>
<Toolbar>
<UButton @click="router.push(`/services/create/`)">+ Leistung</UButton>
<UInput
v-model="searchString"
placeholder="Suche..."
/>
</Toolbar>
<div class="table">
<UTable
:rows="filteredRows"
:columns="itemColumns"
@select="selectItem"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
>
<template #sellingPrice-data="{row}">
{{row.sellingPrice ? Number(row.sellingPrice).toFixed(2) + " €" : ""}}
</template>
<!-- <template #tags-data="{row}">
<UBadge
v-if="row.tags.length > 0"
v-for="tag in row.tags"
class="mr-2"
>
{{tag}}
</UBadge>
<span v-else>-</span>
</template>-->
<template #unit-data="{row}">
{{dataStore.units.find(unit => unit.id === row.unit) ? dataStore.units.find(unit => unit.id === row.unit).name : row.unit}}
</template>
</UTable>
</div>
</template>
<script setup>
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const router = useRouter()
const itemColumns = [
{
key: "name",
label: "Name",
sortable: true
},
{
key: "unit",
label: "Einheit",
sortable: true
},
{
key: "sellingPrice",
label: "Verkaufspreis",
sortable: true
}/*,
{
key: "tags",
label: "Tags",
sortable: true
}*/
]
const selectItem = (item) => {
console.log(item)
router.push(`/services/show/${item.id} `)
}
const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return dataStore.services
}
return dataStore.services.filter(product => {
return Object.values(product).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})
})
})
</script>
<style scoped>
</style>

View File

@@ -1,5 +1,7 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const router = useRouter()

View File

@@ -164,6 +164,7 @@ export const useDataStore = defineStore('data', () => {
const phasesTemplates = ref([])
const emailAccounts = ref([])
const texttemplates =ref([])
const services =ref([])
const rights = ref({
@@ -279,6 +280,7 @@ export const useDataStore = defineStore('data', () => {
await fetchPhasesTemplates()
await fetchEmailAccounts()
await fetchTextTemplates()
await fetchServices()
loaded.value = true
}
@@ -321,6 +323,7 @@ export const useDataStore = defineStore('data', () => {
phasesTemplates.value = []
emailAccounts.value = []
texttemplates.value = []
services.value = []
}
function hasRight (right) {
@@ -600,6 +603,10 @@ export const useDataStore = defineStore('data', () => {
texttemplates.value = (await supabase.from("textTemplates").select().eq('tenant', currentTenant.value)).data
}
async function fetchServices() {
services.value = (await supabase.from("services").select().eq('tenant', currentTenant.value)).data
}
async function fetchDocuments () {
let tempDocuments = (await supabase.from("documents").select().eq('tenant', currentTenant.value)).data
@@ -915,6 +922,10 @@ export const useDataStore = defineStore('data', () => {
return products.value.find(item => item.id === itemId)
})
const getServiceById = computed(() => (itemId) => {
return services.value.find(item => item.id === itemId)
})
const getVendorById = computed(() => (itemId) => {
return vendors.value.find(item => item.id === itemId)
})
@@ -1041,6 +1052,7 @@ export const useDataStore = defineStore('data', () => {
phasesTemplates,
emailAccounts,
texttemplates,
services,
documentTypesForCreation,
//Functions
@@ -1112,6 +1124,7 @@ export const useDataStore = defineStore('data', () => {
getEventsByResource,
getCostCentresComposed,
getProductById,
getServiceById,
getVendorById,
getIncomingInvoiceById,
getContractById,