Restructured Project Rep

This commit is contained in:
2024-04-07 22:25:16 +02:00
parent 895f508c29
commit d51ad2c4eb
150 changed files with 19358 additions and 7318 deletions

View File

@@ -0,0 +1,28 @@
import { createSharedComposable } from '@vueuse/core'
const _useDashboard = () => {
const route = useRoute()
const router = useRouter()
const isHelpSlideoverOpen = ref(false)
const isNotificationsSlideoverOpen = ref(false)
defineShortcuts({
'g-h': () => router.push('/'),
'g-a': () => router.push('/tasks'),
'g-s': () => router.push('/settings'),
'?': () => isHelpSlideoverOpen.value = !isHelpSlideoverOpen.value,
n: () => isNotificationsSlideoverOpen.value = !isNotificationsSlideoverOpen.value
})
watch(() => route.fullPath, () => {
isHelpSlideoverOpen.value = false
isNotificationsSlideoverOpen.value = false
})
return {
isHelpSlideoverOpen,
isNotificationsSlideoverOpen
}
}
export const useDashboard = createSharedComposable(_useDashboard)

View File

@@ -0,0 +1,29 @@
export const useNumberRange = (resourceType) => {
const supabase = useSupabaseClient()
const {numberRanges} = storeToRefs(useDataStore())
const {fetchNumberRanges} = useDataStore()
const numberRange = numberRanges.value.find(range => range.resourceType === resourceType)
const useNextNumber = async () => {
let nextNumber = numberRange.nextNumber
const {data,error} = await supabase
.from("numberranges")
.update({nextNumber: nextNumber + 1})
.eq('id',numberRange.id)
fetchNumberRanges()
return (numberRange.prefix ? numberRange.prefix : "") + nextNumber + (numberRange.suffix ? numberRange.suffix : "")
}
return { useNextNumber}
}

View File

@@ -0,0 +1,909 @@
import {PDFDocument, StandardFonts, rgb} from "pdf-lib"
const getCoordinatesForPDFLib = (x ,y, page) => {
/*
* @param x the wanted X Parameter in Millimeters from Top Left
* @param y the wanted Y Parameter in Millimeters from Top Left
* @param page the page Object
*
* @returns x,y object
* */
let retX = x * 2.83
let retY = page.getHeight()-(y*2.83)
return {
x: retX,
y: retY
}
}
export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
const uri = ref("test")
const genPDF = async () => {
const pdfDoc = await PDFDocument.create()
const font = await pdfDoc.embedFont(StandardFonts.Helvetica)
const fontBold = await pdfDoc.embedFont(StandardFonts.HelveticaBold)
let pages = []
let pageCounter = 1
//const backgroundPdfSourceBuffer = await fetch("/Briefpapier.pdf").then((res) => res.arrayBuffer())
const backgroudPdf = await PDFDocument.load(backgroundSourceBuffer)
const firstPageBackground = await pdfDoc.embedPage(backgroudPdf.getPages()[0])
const secondPageBackground = await pdfDoc.embedPage(backgroudPdf.getPages()[backgroudPdf.getPages().length > 1 ? 1 : 0])
//console.log("TEST")
const page1 = pdfDoc.addPage()
//console.log(page1.getSize().width/2.83)
page1.drawPage(firstPageBackground, {
x: 0,
y: 0,
})
//console.log(page1.getSize())
pages.push(page1)
//console.log(pages)
//Falzmarke 1
pages[pageCounter - 1].drawLine({
start: getCoordinatesForPDFLib(0,105,page1),
end: getCoordinatesForPDFLib(7,105,page1),
thickness: 0.25,
color: rgb(0,0,0),
opacity: 1
})
//Lochmarke
pages[pageCounter - 1].drawLine({
start: getCoordinatesForPDFLib(0,148.5,page1),
end: getCoordinatesForPDFLib(7,148.5,page1),
thickness: 0.25,
color: rgb(0,0,0),
opacity: 1
})
//Falzmarke 2
pages[pageCounter - 1].drawLine({
start: getCoordinatesForPDFLib(0,210,page1),
end: getCoordinatesForPDFLib(7,210,page1),
thickness: 0.25,
color: rgb(0,0,0),
opacity: 1
})
/*page1.drawLine({
start: getCoordinatesForPDFLib(20,45,page1),
end: getCoordinatesForPDFLib(105,45,page1),
thickness: 0.5,
color: rgb(0,0,0),
opacity: 1
})*/
pages[pageCounter - 1].drawText(invoiceData.adressLine, {
...getCoordinatesForPDFLib(21,48, page1),
size:6,
color:rgb(0,0,0),
lineHeight:6,
opacity: 1,
maxWidth: 240
})
/*page1.drawLine({
start: getCoordinatesForPDFLib(20,50,page1),
end: getCoordinatesForPDFLib(105,50,page1),
thickness: 0.5,
color: rgb(0,0,0),
opacity: 1
})*/
pages[pageCounter - 1].drawText(invoiceData.recipient.name, {
...getCoordinatesForPDFLib(21,55, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
if(invoiceData.recipient.contact && !invoiceData.recipient.special) {
pages[pageCounter - 1].drawText(invoiceData.recipient.contact, {
...getCoordinatesForPDFLib(21,60, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.recipient.street, {
...getCoordinatesForPDFLib(21,65, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(`${invoiceData.recipient.zip} ${invoiceData.recipient.city}`, {
...getCoordinatesForPDFLib(21,70, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
} else if(invoiceData.recipient.contact && invoiceData.recipient.special) {
pages[pageCounter - 1].drawText(invoiceData.recipient.contact, {
...getCoordinatesForPDFLib(21,60, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.recipient.special, {
...getCoordinatesForPDFLib(21,65, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.recipient.street, {
...getCoordinatesForPDFLib(21,70, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(`${invoiceData.recipient.zip} ${invoiceData.recipient.city}`, {
...getCoordinatesForPDFLib(21,75, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
} else if(!invoiceData.recipient.contact && !invoiceData.recipient.special) {
pages[pageCounter - 1].drawText(invoiceData.recipient.street, {
...getCoordinatesForPDFLib(21,60, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(`${invoiceData.recipient.zip} ${invoiceData.recipient.city}`, {
...getCoordinatesForPDFLib(21,65, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
} else {
pages[pageCounter - 1].drawText(invoiceData.recipient.contact, {
...getCoordinatesForPDFLib(21,60, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.recipient.special, {
...getCoordinatesForPDFLib(21,65, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.recipient.street, {
...getCoordinatesForPDFLib(21,70, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(`${invoiceData.recipient.zip} ${invoiceData.recipient.city}`, {
...getCoordinatesForPDFLib(21,75, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
}
/*page1.drawLine({
start: getCoordinatesForPDFLib(20,90,page1),
end: getCoordinatesForPDFLib(105,90,page1),
thickness: 0.5,
color: rgb(0,0,0),
opacity: 1
})*/
//Rechts
/*page1.drawLine({
start: getCoordinatesForPDFLib(125,50,page1),
end: getCoordinatesForPDFLib(200,50,page1),
thickness: 0.5,
color: rgb(0,0,0),
opacity: 1
})*/
pages[pageCounter - 1].drawText(invoiceData.info.documentNumberTitle, {
...getCoordinatesForPDFLib(126,55, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.documentNumber ? invoiceData.info.documentNumber : "XXXX", {
y: getCoordinatesForPDFLib(126,55, page1).y,
x: getCoordinatesForPDFLib(126,55,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.documentNumber ? invoiceData.info.documentNumber : "XXXX",10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText("Kundennummer", {
...getCoordinatesForPDFLib(126,60, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.customerNumber, {
y: getCoordinatesForPDFLib(126,60, page1).y,
x: getCoordinatesForPDFLib(126,60,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.customerNumber,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText("Belegdatum", {
...getCoordinatesForPDFLib(126,65, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.documentDate, {
y: getCoordinatesForPDFLib(126,65, page1).y,
x: getCoordinatesForPDFLib(126,65,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.documentDate,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
if(invoiceData.info.deliveryDateType !== "Kein Lieferdatum anzeigen") {
pages[pageCounter - 1].drawText(invoiceData.info.deliveryDateType, {
...getCoordinatesForPDFLib(126,70, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.deliveryDate, {
y: getCoordinatesForPDFLib(126,70, page1).y,
x: getCoordinatesForPDFLib(126,70,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.deliveryDate,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
}
pages[pageCounter - 1].drawText("Ansprechpartner", {
...getCoordinatesForPDFLib(126,75, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.contactPerson, {
y: getCoordinatesForPDFLib(126,75, page1).y,
x: getCoordinatesForPDFLib(126,75,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.contactPerson,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
if(invoiceData.info.contactTel && invoiceData.info.contactEMail) {
pages[pageCounter - 1].drawText("Telefon", {
...getCoordinatesForPDFLib(126,80, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.contactTel, {
y: getCoordinatesForPDFLib(126,80, page1).y,
x: getCoordinatesForPDFLib(126,80,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.contactTel,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText("E-Mail", {
...getCoordinatesForPDFLib(126,85, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.contactEMail, {
y: getCoordinatesForPDFLib(126,85, page1).y,
x: getCoordinatesForPDFLib(126,85,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.contactEMail,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
} else if(invoiceData.info.contactTel && !invoiceData.info.contactEMail) {
pages[pageCounter - 1].drawText("Telefon", {
...getCoordinatesForPDFLib(126,80, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.contactTel, {
y: getCoordinatesForPDFLib(126,80, page1).y,
x: getCoordinatesForPDFLib(126,80,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.contactTel,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
} else if(!invoiceData.info.contactTel && invoiceData.info.contactEMail) {
pages[pageCounter - 1].drawText("E-Mail", {
...getCoordinatesForPDFLib(126,80, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.contactEMail, {
y: getCoordinatesForPDFLib(126,80, page1).y,
x: getCoordinatesForPDFLib(126,80,page1).x + 210 - font.widthOfTextAtSize(invoiceData.info.contactEMail,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
}
/*pages[pageCounter - 1].drawText("Projekt:", {
...getCoordinatesForPDFLib(126,90, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(invoiceData.info.project, {
y: getCoordinatesForPDFLib(126,90, page1).y,
x: getCoordinatesForPDFLib(126,90,page1).x + 50 /!*+ 210 - font.widthOfTextAtSize(invoiceData.info.project,10)*!/,
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 150
})*/
/*page1.drawLine({
start: getCoordinatesForPDFLib(125,90,page1),
end: getCoordinatesForPDFLib(200,90,page1),
thickness: 0.5,
color: rgb(0,0,0),
opacity: 1
})*/
//Title
/*page1.drawLine({
start: getCoordinatesForPDFLib(20,95,page1),
end: getCoordinatesForPDFLib(200,95,page1),
thickness: 0.5,
color: rgb(0,0,0),
opacity: 1
})*/
pages[pageCounter - 1].drawText(invoiceData.title, {
...getCoordinatesForPDFLib(20,100, page1),
size:13,
color:rgb(0,0,0),
lineHeight:15,
opacity: 1,
maxWidth: 500
})
/*page1.drawLine({
start: getCoordinatesForPDFLib(20,105,page1),
end: getCoordinatesForPDFLib(200,105,page1),
thickness: 0.5,
color: rgb(0,0,0),
opacity: 1
})*/
if(invoiceData.description) {
pages[pageCounter - 1].drawText(invoiceData.description, {
...getCoordinatesForPDFLib(20,112, page1),
size:13,
color:rgb(0,0,0),
lineHeight:15,
opacity: 1,
maxWidth: 500
})
}
pages[pageCounter - 1].drawText(invoiceData.startText,{
...getCoordinatesForPDFLib(20,119, page1),
size: 10,
color: rgb(0,0,0),
lineHeight: 10,
opacity: 1,
maxWidth: 500
})
/*page1.drawLine({
start: getCoordinatesForPDFLib(20,115,page1),
end: getCoordinatesForPDFLib(200,115,page1),
thickness: 0.5,
color: rgb(0,0,0),
opacity: 1
})*/
pages[pageCounter - 1].drawRectangle({
...getCoordinatesForPDFLib(20,140, page1),
width: 180 * 2.83,
height: 8 * 2.83,
color: rgb(0,0,0),
opacity: 0.25
})
//Header
pages[pageCounter - 1].drawText("Pos", {
...getCoordinatesForPDFLib(21,137, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pages[pageCounter - 1].drawText("Menge", {
...getCoordinatesForPDFLib(35,137, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pages[pageCounter - 1].drawText("Bezeichnung", {
...getCoordinatesForPDFLib(52,137, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pages[pageCounter - 1].drawText("Einheitspreis", {
...getCoordinatesForPDFLib(135,137, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pages[pageCounter - 1].drawText("Gesamt", {
y: getCoordinatesForPDFLib(25,137, page1).y,
x: getCoordinatesForPDFLib(25,137,page1).x + 490 - fontBold.widthOfTextAtSize("Gesamt",12),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
let rowHeight = 145
let pageIndex = 0
invoiceData.rows.forEach((row,index) => {
if(row.mode !== 'pagebreak'){
pages[pageCounter - 1].drawText(String(row.pos), {
...getCoordinatesForPDFLib(21,rowHeight, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(`${row.quantity} ${row.unit}`, {
...getCoordinatesForPDFLib(35,rowHeight, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(row.text, {
...getCoordinatesForPDFLib(52,rowHeight, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240,
font: fontBold
})
if(row.description) {
pages[pageCounter - 1].drawText(row.description, {
...getCoordinatesForPDFLib(52,rowHeight + 7, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 220,
})
}
pages[pageCounter - 1].drawText(row.price, {
...getCoordinatesForPDFLib(135,rowHeight, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
pages[pageCounter - 1].drawText(row.rowAmount, {
y: getCoordinatesForPDFLib(25,rowHeight, page1).y,
x: getCoordinatesForPDFLib(25,rowHeight,page1).x + 490 - font.widthOfTextAtSize(row.rowAmount,10),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240,
})
if(row.discountPercent > 0) {
pages[pageCounter - 1].drawText(row.discountText, {
y: getCoordinatesForPDFLib(25,rowHeight + 5, page1).y,
x: getCoordinatesForPDFLib(25,rowHeight + 5,page1).x + 490 - font.widthOfTextAtSize(row.discountText,8),
size:8,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240,
})
}
if(row.description) {
rowHeight += 24
} else {
rowHeight += 14
}
pageIndex += 1
} else if(row.mode === 'pagebreak') {
const page = pdfDoc.addPage()
page.drawPage(secondPageBackground, {
x: 0,
y: 0,
})
//Falzmarke 1
page.drawLine({
start: getCoordinatesForPDFLib(0,105,page1),
end: getCoordinatesForPDFLib(7,105,page1),
thickness: 0.25,
color: rgb(0,0,0),
opacity: 1
})
//Lochmarke
page.drawLine({
start: getCoordinatesForPDFLib(0,148.5,page1),
end: getCoordinatesForPDFLib(7,148.5,page1),
thickness: 0.25,
color: rgb(0,0,0),
opacity: 1
})
//Falzmarke 2
page.drawLine({
start: getCoordinatesForPDFLib(0,210,page1),
end: getCoordinatesForPDFLib(7,210,page1),
thickness: 0.25,
color: rgb(0,0,0),
opacity: 1
})
page.drawRectangle({
...getCoordinatesForPDFLib(20,25, page1),
width: 180 * 2.83,
height: 8 * 2.83,
color: rgb(0,0,0),
opacity: 0.25
})
//Header
page.drawText("Pos", {
...getCoordinatesForPDFLib(21,22, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
page.drawText("Menge", {
...getCoordinatesForPDFLib(35,22, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
page.drawText("Bezeichnung", {
...getCoordinatesForPDFLib(52,22, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
page.drawText("Einheitspreis", {
...getCoordinatesForPDFLib(135,22, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
page.drawText("Gesamt", {
y: getCoordinatesForPDFLib(25,22, page1).y,
x: getCoordinatesForPDFLib(25,22,page1).x + 490 - fontBold.widthOfTextAtSize("Gesamt",12),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pageCounter += 1;
pageIndex = 0;
rowHeight = 30;
pages.push(page)
//console.log(pages)
}
})
//Pos 1
//Footer
console.log(rowHeight)
//rowHeight += 25
pages[pageCounter - 1].drawRectangle({
...getCoordinatesForPDFLib(20,rowHeight, page1),
width: 180 * 2.83,
height: 8 * 2.83,
color: rgb(0,0,0),
opacity: 0.25
})
pages[pageCounter - 1].drawRectangle({
...getCoordinatesForPDFLib(20,rowHeight +16, page1),
width: 180 * 2.83,
height: 8 * 2.83,
color: rgb(0,0,0),
opacity: 0.25
})
pages[pageCounter - 1].drawText("Nettobetrag", {
...getCoordinatesForPDFLib(21,rowHeight-3, page1),
size:11,
color:rgb(0,0,0),
lineHeight:11,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pages[pageCounter - 1].drawText(invoiceData.total.totalNet, {
y: getCoordinatesForPDFLib(21,rowHeight-3, page1).y,
x: getCoordinatesForPDFLib(21,rowHeight-3,page1).x + 500 - fontBold.widthOfTextAtSize(invoiceData.total.totalNet,11),
size:11,
color:rgb(0,0,0),
lineHeight:11,
opacity: 1,
maxWidth: 240,
font:fontBold
})
pages[pageCounter - 1].drawText("zzgl. 19% MwSt", {
...getCoordinatesForPDFLib(21,rowHeight+5, page1),
size:11,
color:rgb(0,0,0),
lineHeight:11,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pages[pageCounter - 1].drawText(invoiceData.total.total19, {
y: getCoordinatesForPDFLib(21,rowHeight+5, page1).y,
x: getCoordinatesForPDFLib(21,rowHeight+5,page1).x + 500 - fontBold.widthOfTextAtSize(invoiceData.total.total19,11),
size:11,
color:rgb(0,0,0),
lineHeight:11,
opacity: 1,
maxWidth: 240,
font:fontBold
})
pages[pageCounter - 1].drawText("Gesamtsumme", {
...getCoordinatesForPDFLib(21,rowHeight+13, page1),
size:11,
color:rgb(0,0,0),
lineHeight:11,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pages[pageCounter - 1].drawText(invoiceData.total.totalGross, {
y: getCoordinatesForPDFLib(21,rowHeight+13, page1).y,
x: getCoordinatesForPDFLib(21,rowHeight+13,page1).x + 500 - fontBold.widthOfTextAtSize(invoiceData.total.totalGross,11),
size:11,
color:rgb(0,0,0),
lineHeight:11,
opacity: 1,
maxWidth: 240,
font:fontBold
})
pages[pageCounter - 1].drawText(invoiceData.endText,{
...getCoordinatesForPDFLib(20,rowHeight+22, page1),
size: 10,
color: rgb(0,0,0),
lineHeight: 10,
opacity: 1,
maxWidth: 500
})
//console.log(await pdfDoc.saveAsBase64({dataUri: true}))
uri.value = await pdfDoc.saveAsBase64({dataUri: true})
//console.log(uri.value)
}
await genPDF()
//const pdfBytes = await pdfDoc.save()
//const pdfDataUri = await pdfDoc.saveAsBase64({dataUri: true})
return uri.value
//let blob = new Blob(pdfBytes, {type: "application/pdf"})
/*let link = document.createElement('a')
link.href = pdfDataUri//window.URL.createObjectURL(blob)
link.download = "test.pdf"
link.click()*/
}

31
composables/useSearch.js Normal file
View File

@@ -0,0 +1,31 @@
export const useSearch = (searchString,items) => {
const dataStore = useDataStore()
if(!searchString) {
return items
}
items = items.map(item => {
return {
...item,
customer: dataStore.getCustomerById(item.customer)
}
})
console.log(items)
return items.filter(i => JSON.stringify(i).includes(searchString))
/*return items.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.toLowerCase())
})
})*/
}