Minor Changes in Invoice Creation

This commit is contained in:
2024-09-19 19:34:41 +02:00
parent c546e2cf3c
commit 93a2d96c21
2 changed files with 25 additions and 13 deletions

View File

@@ -595,6 +595,8 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
if(row.mode !== 'pagebreak' && row.mode !== 'title'){ if(row.mode !== 'pagebreak' && row.mode !== 'title'){
console.log(row)
pages[pageCounter - 1].drawText(String(row.pos), { pages[pageCounter - 1].drawText(String(row.pos), {
...getCoordinatesForPDFLib(21,rowHeight, page1), ...getCoordinatesForPDFLib(21,rowHeight, page1),
size:10, size:10,
@@ -613,19 +615,24 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
maxWidth: 240 maxWidth: 240
}) })
pages[pageCounter - 1].drawText(row.text, { pages[pageCounter - 1].drawText(row.text.match(/.{1,35}/g).join("\n"), {
...getCoordinatesForPDFLib(52,rowHeight, page1), ...getCoordinatesForPDFLib(52,rowHeight, page1),
size:10, size:10,
color:rgb(0,0,0), color:rgb(0,0,0),
lineHeight:10, lineHeight:10,
opacity: 1, opacity: 1,
maxWidth: 240, maxWidth: 10,
font: fontBold font: fontBold
}) })
//let textLineBreaks = (row.text.match(/\n/g) || []).length
let textAutoLines = (row.text.match(/.{1,35}/g) || []).length
console.log(textAutoLines)
if(row.description) { if(row.description) {
pages[pageCounter - 1].drawText(row.description, { pages[pageCounter - 1].drawText(row.description.match(/.{1,70}/g).join("\n"), {
...getCoordinatesForPDFLib(52,rowHeight + 5, page1), ...getCoordinatesForPDFLib(52,rowHeight + ( textAutoLines * 4), page1),
size:10, size:10,
color:rgb(0,0,0), color:rgb(0,0,0),
lineHeight:10, lineHeight:10,
@@ -671,8 +678,8 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
if(row.description) { if(row.description) {
let lineBreaks = (row.description.match(/\n/g) || []).length let lineBreaks = (row.description.match(/\n/g) || []).length
let autoLines = (row.description.match(/.{1,50}/g) || []).length let autoLines = (row.description.match(/.{1,70}/g) || []).length
rowHeight += 14 + (lineBreaks + autoLines) * 2.5 rowHeight += 14 + (lineBreaks + autoLines + textAutoLines) * 2.5
} else { } else {
rowHeight += 10 rowHeight += 10
} }

View File

@@ -207,7 +207,8 @@ const addPosition = (mode) => {
quantity: 1, quantity: 1,
price: 0, price: 0,
taxPercent: 19, taxPercent: 19,
discountPercent: 0 discountPercent: 0,
unit: 1
}) })
} else if(mode === 'service'){ } else if(mode === 'service'){
itemInfo.value.rows.push({ itemInfo.value.rows.push({
@@ -216,7 +217,8 @@ const addPosition = (mode) => {
quantity: 1, quantity: 1,
price: 0, price: 0,
taxPercent: 19, taxPercent: 19,
discountPercent: 0 discountPercent: 0,
unit: 1
}) })
} else if(mode === "pagebreak") { } else if(mode === "pagebreak") {
itemInfo.value.rows.push({ itemInfo.value.rows.push({
@@ -515,7 +517,7 @@ setupPage()
<div v-if="item.label === 'Editor'"> <div v-if="item.label === 'Editor'">
<InputGroup> <InputGroup>
<div class="flex-auto mr-5"> <div class="w-1/3 mr-5">
<UFormGroup <UFormGroup
label="Dokumenttyp:" label="Dokumenttyp:"
> >
@@ -708,7 +710,7 @@ setupPage()
</InputGroup> </InputGroup>
</UFormGroup> </UFormGroup>
</div> </div>
<div class="flex-auto"> <div class="w-2/3">
<UFormGroup <UFormGroup
:label="itemInfo.documentNumberTitle + ':'" :label="itemInfo.documentNumberTitle + ':'"
> >
@@ -977,7 +979,6 @@ setupPage()
> >
<UInput <UInput
v-model="row.text" v-model="row.text"
maxlength="40"
placeholder="Name" placeholder="Name"
/> />
</td> </td>
@@ -986,7 +987,9 @@ setupPage()
v-else-if="row.mode === 'normal'" v-else-if="row.mode === 'normal'"
> >
<USelectMenu <USelectMenu
class="w-40"
:options="dataStore.products" :options="dataStore.products"
:color="row.product ? 'primary' : 'rose'"
option-attribute="name" option-attribute="name"
value-attribute="id" value-attribute="id"
searchable searchable
@@ -994,7 +997,7 @@ setupPage()
:search-attributes="['name']" :search-attributes="['name']"
v-model="row.product" v-model="row.product"
@change="row.unit = dataStore.getProductById(row.product).unit, @change="row.unit = dataStore.getProductById(row.product).unit,
row.price = dataStore.getProductById(row.product).sellingPrice || 0, row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
row.description = dataStore.getProductById(row.product).description" row.description = dataStore.getProductById(row.product).description"
> >
<template #label> <template #label>
@@ -1010,7 +1013,9 @@ setupPage()
v-else-if="row.mode === 'service'" v-else-if="row.mode === 'service'"
> >
<USelectMenu <USelectMenu
class="w-40"
:options="dataStore.services" :options="dataStore.services"
:color="row.service ? 'primary' : 'rose'"
option-attribute="name" option-attribute="name"
value-attribute="id" value-attribute="id"
searchable searchable
@@ -1022,7 +1027,7 @@ setupPage()
row.description = dataStore.getServiceById(row.service).description" row.description = dataStore.getServiceById(row.service).description"
> >
<template #label> <template #label>
{{dataStore.getServiceById(row.service) ? dataStore.getServiceById(row.service).name : "Keine Leistung ausgewählt" }} <span class="truncate">{{dataStore.getServiceById(row.service) ? dataStore.getServiceById(row.service).name : "Keine Leistung ausgewählt" }}</span>
</template> </template>
</USelectMenu> </USelectMenu>
</td> </td>