Added Agriculture
Removed Prices for Delivery Notes
This commit is contained in:
@@ -565,28 +565,33 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
|
|||||||
font: fontBold
|
font: fontBold
|
||||||
})
|
})
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText("Einheitspreis", {
|
if( invoiceData.type !== "deliveryNotes") {
|
||||||
...getCoordinatesForPDFLib(135,137, page1),
|
pages[pageCounter - 1].drawText("Einheitspreis", {
|
||||||
size:12,
|
...getCoordinatesForPDFLib(135,137, page1),
|
||||||
color:rgb(0,0,0),
|
size:12,
|
||||||
lineHeight:12,
|
color:rgb(0,0,0),
|
||||||
opacity: 1,
|
lineHeight:12,
|
||||||
maxWidth: 240,
|
opacity: 1,
|
||||||
font: fontBold
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
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 rowHeight = 145.5
|
||||||
|
|
||||||
let pageIndex = 0
|
let pageIndex = 0
|
||||||
|
|
||||||
@@ -619,65 +624,95 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
|
|||||||
|
|
||||||
console.log(row.text.match(/.{1,35}/g))
|
console.log(row.text.match(/.{1,35}/g))
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText(row.text.match(/.{1,35}/g).join("\n"), {
|
if(invoiceData.type !== "deliveryNotes") {
|
||||||
...getCoordinatesForPDFLib(52,rowHeight, page1),
|
pages[pageCounter - 1].drawText(row.text.match(/.{1,35}/g).join("\n"), {
|
||||||
size:10,
|
...getCoordinatesForPDFLib(52,rowHeight, page1),
|
||||||
color:rgb(0,0,0),
|
|
||||||
lineHeight:10,
|
|
||||||
opacity: 1,
|
|
||||||
font: fontBold
|
|
||||||
})
|
|
||||||
|
|
||||||
//let textLineBreaks = (row.text.match(/\n/g) || []).length
|
|
||||||
let textAutoLines = (row.text.match(/.{1,35}/g) || []).length
|
|
||||||
console.log(textAutoLines)
|
|
||||||
|
|
||||||
|
|
||||||
if(row.descriptionText) {
|
|
||||||
pages[pageCounter - 1].drawText(row.descriptionText.match(/.{1,70}/g).join("\n"), {
|
|
||||||
...getCoordinatesForPDFLib(52,rowHeight + ( textAutoLines * 4), page1),
|
|
||||||
size:10,
|
size:10,
|
||||||
color:rgb(0,0,0),
|
color:rgb(0,0,0),
|
||||||
lineHeight:10,
|
lineHeight:10,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
|
font: fontBold
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
pages[pageCounter - 1].drawText(row.text.match(/.{1,80}/g).join("\n"), {
|
||||||
|
...getCoordinatesForPDFLib(52,rowHeight, page1),
|
||||||
|
size:10,
|
||||||
|
color:rgb(0,0,0),
|
||||||
|
lineHeight:10,
|
||||||
|
opacity: 1,
|
||||||
|
font: fontBold
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText(row.price, {
|
//let textLineBreaks = (row.text.match(/\n/g) || []).length
|
||||||
...getCoordinatesForPDFLib(135,rowHeight, page1),
|
let textAutoLines = (invoiceData.type !== "deliveryNotes" ? row.text.match(/.{1,35}/g) : row.text.match(/.{1,80}/g) || []).length
|
||||||
size:10,
|
console.log(textAutoLines)
|
||||||
color:rgb(0,0,0),
|
|
||||||
lineHeight:10,
|
|
||||||
opacity: 1,
|
|
||||||
maxWidth: 240
|
|
||||||
})
|
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText(row.rowAmount, {
|
console.log(row)
|
||||||
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, {
|
if(row.descriptionText) {
|
||||||
y: getCoordinatesForPDFLib(25,rowHeight + 5, page1).y,
|
if(invoiceData.type !== "deliveryNotes") {
|
||||||
x: getCoordinatesForPDFLib(25,rowHeight + 5,page1).x + 490 - font.widthOfTextAtSize(row.discountText,8),
|
pages[pageCounter - 1].drawText(row.descriptionText.match(/.{1,70}/g).join("\n"), {
|
||||||
size:8,
|
...getCoordinatesForPDFLib(52,rowHeight + ( textAutoLines * 4), page1),
|
||||||
|
size:10,
|
||||||
|
color:rgb(0,0,0),
|
||||||
|
lineHeight:10,
|
||||||
|
opacity: 1,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
pages[pageCounter - 1].drawText(row.descriptionText.match(/.{1,80}/g).join("\n"), {
|
||||||
|
...getCoordinatesForPDFLib(52,rowHeight + ( textAutoLines * 4), page1),
|
||||||
|
size:10,
|
||||||
|
color:rgb(0,0,0),
|
||||||
|
lineHeight:10,
|
||||||
|
opacity: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(invoiceData.type !== "deliveryNotes") {
|
||||||
|
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),
|
color:rgb(0,0,0),
|
||||||
lineHeight:10,
|
lineHeight:10,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
maxWidth: 240,
|
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.descriptionText) {
|
if(row.descriptionText) {
|
||||||
let lineBreaks = (row.descriptionText.match(/\n/g) || []).length
|
let lineBreaks = (row.descriptionText.match(/\n/g) || []).length
|
||||||
let autoLines = (row.descriptionText.match(/.{1,70}/g) || []).length
|
let autoLines = (row.descriptionText.match(/.{1,70}/g) || []).length
|
||||||
@@ -766,26 +801,30 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
|
|||||||
font: fontBold
|
font: fontBold
|
||||||
})
|
})
|
||||||
|
|
||||||
page.drawText("Einheitspreis", {
|
if(invoiceData.type !== "deliveryNotes"){
|
||||||
...getCoordinatesForPDFLib(135,22, page1),
|
page.drawText("Einheitspreis", {
|
||||||
size:12,
|
...getCoordinatesForPDFLib(135,22, page1),
|
||||||
color:rgb(0,0,0),
|
size:12,
|
||||||
lineHeight:12,
|
color:rgb(0,0,0),
|
||||||
opacity: 1,
|
lineHeight:12,
|
||||||
maxWidth: 240,
|
opacity: 1,
|
||||||
font: fontBold
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
pageCounter += 1;
|
||||||
pageIndex = 0;
|
pageIndex = 0;
|
||||||
@@ -848,7 +887,7 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText(row.text.match(/.{1,60}/g).join("\n"), {
|
pages[pageCounter - 1].drawText(row.text.match(/.{1,60}/g).join("\n"), {
|
||||||
...getCoordinatesForPDFLib(21,rowHeight - 3, page1),
|
...getCoordinatesForPDFLib(21,rowHeight - 2.6, page1),
|
||||||
size:12,
|
size:12,
|
||||||
color:rgb(0,0,0),
|
color:rgb(0,0,0),
|
||||||
lineHeight:12,
|
lineHeight:12,
|
||||||
@@ -868,11 +907,15 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
|
|||||||
lineHeight:10,
|
lineHeight:10,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let addHeight = (row.descriptionText.match(/.{1,80}/g) || []).length * 4 + 10
|
||||||
|
console.log(addHeight)
|
||||||
|
rowHeight += addHeight
|
||||||
|
} else {
|
||||||
|
rowHeight += 6
|
||||||
}
|
}
|
||||||
|
|
||||||
let addHeight = (row.descriptionText.match(/.{1,80}/g) || []).length * 4 + 10
|
|
||||||
console.log(addHeight)
|
|
||||||
rowHeight += addHeight
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,84 +932,89 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
|
|||||||
//Footer
|
//Footer
|
||||||
//console.log(rowHeight)
|
//console.log(rowHeight)
|
||||||
//rowHeight += 25
|
//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({
|
if(invoiceData.type !== "deliveryNotes"){
|
||||||
...getCoordinatesForPDFLib(20,rowHeight +16, page1),
|
pages[pageCounter - 1].drawRectangle({
|
||||||
width: 180 * 2.83,
|
...getCoordinatesForPDFLib(20,rowHeight, page1),
|
||||||
height: 8 * 2.83,
|
width: 180 * 2.83,
|
||||||
color: rgb(0,0,0),
|
height: 8 * 2.83,
|
||||||
opacity: 0.25
|
color: rgb(0,0,0),
|
||||||
})
|
opacity: 0.25
|
||||||
|
})
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText("Nettobetrag", {
|
pages[pageCounter - 1].drawRectangle({
|
||||||
...getCoordinatesForPDFLib(21,rowHeight-3, page1),
|
...getCoordinatesForPDFLib(20,rowHeight +16, page1),
|
||||||
size:11,
|
width: 180 * 2.83,
|
||||||
color:rgb(0,0,0),
|
height: 8 * 2.83,
|
||||||
lineHeight:11,
|
color: rgb(0,0,0),
|
||||||
opacity: 1,
|
opacity: 0.25
|
||||||
maxWidth: 240,
|
})
|
||||||
font: fontBold
|
|
||||||
})
|
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText(invoiceData.total.totalNet, {
|
pages[pageCounter - 1].drawText("Nettobetrag", {
|
||||||
y: getCoordinatesForPDFLib(21,rowHeight-3, page1).y,
|
...getCoordinatesForPDFLib(21,rowHeight-3, page1),
|
||||||
x: getCoordinatesForPDFLib(21,rowHeight-3,page1).x + 500 - fontBold.widthOfTextAtSize(invoiceData.total.totalNet,11),
|
size:11,
|
||||||
size:11,
|
color:rgb(0,0,0),
|
||||||
color:rgb(0,0,0),
|
lineHeight:11,
|
||||||
lineHeight:11,
|
opacity: 1,
|
||||||
opacity: 1,
|
maxWidth: 240,
|
||||||
maxWidth: 240,
|
font: fontBold
|
||||||
font:fontBold
|
})
|
||||||
})
|
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText("zzgl. 19% MwSt", {
|
pages[pageCounter - 1].drawText(invoiceData.total.totalNet, {
|
||||||
...getCoordinatesForPDFLib(21,rowHeight+5, page1),
|
y: getCoordinatesForPDFLib(21,rowHeight-3, page1).y,
|
||||||
size:11,
|
x: getCoordinatesForPDFLib(21,rowHeight-3,page1).x + 500 - fontBold.widthOfTextAtSize(invoiceData.total.totalNet,11),
|
||||||
color:rgb(0,0,0),
|
size:11,
|
||||||
lineHeight:11,
|
color:rgb(0,0,0),
|
||||||
opacity: 1,
|
lineHeight:11,
|
||||||
maxWidth: 240,
|
opacity: 1,
|
||||||
font: fontBold
|
maxWidth: 240,
|
||||||
})
|
font:fontBold
|
||||||
|
})
|
||||||
|
|
||||||
pages[pageCounter - 1].drawText(invoiceData.total.total19, {
|
pages[pageCounter - 1].drawText("zzgl. 19% MwSt", {
|
||||||
y: getCoordinatesForPDFLib(21,rowHeight+5, page1).y,
|
...getCoordinatesForPDFLib(21,rowHeight+5, page1),
|
||||||
x: getCoordinatesForPDFLib(21,rowHeight+5,page1).x + 500 - fontBold.widthOfTextAtSize(invoiceData.total.total19,11),
|
size:11,
|
||||||
size:11,
|
color:rgb(0,0,0),
|
||||||
color:rgb(0,0,0),
|
lineHeight:11,
|
||||||
lineHeight:11,
|
opacity: 1,
|
||||||
opacity: 1,
|
maxWidth: 240,
|
||||||
maxWidth: 240,
|
font: fontBold
|
||||||
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("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,{
|
pages[pageCounter - 1].drawText(invoiceData.endText,{
|
||||||
...getCoordinatesForPDFLib(20,rowHeight+22, page1),
|
...getCoordinatesForPDFLib(20,rowHeight+22, page1),
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import dayjs from "dayjs"
|
import dayjs from "dayjs"
|
||||||
import Handlebars from "handlebars"
|
import Handlebars from "handlebars"
|
||||||
|
import {useNumberRange} from "~/composables/useNumberRange.js";
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
@@ -102,6 +104,48 @@ const setupPage = async () => {
|
|||||||
|
|
||||||
setContactPersonData()
|
setContactPersonData()
|
||||||
|
|
||||||
|
if(route.query.linkedDocuments) {
|
||||||
|
|
||||||
|
let linkedDocuments = (await supabase.from("createddocuments").select().in("id",JSON.parse(route.query.linkedDocuments))).data
|
||||||
|
|
||||||
|
//TODO: Implement Checking for Same Customer, Contact and Project
|
||||||
|
|
||||||
|
itemInfo.value.customer = linkedDocuments[0].customer
|
||||||
|
itemInfo.value.project = linkedDocuments[0].project
|
||||||
|
itemInfo.value.contact = linkedDocuments[0].contact
|
||||||
|
|
||||||
|
setCustomerData()
|
||||||
|
|
||||||
|
linkedDocuments.forEach(doc => {
|
||||||
|
let lastId = 0
|
||||||
|
itemInfo.value.rows.forEach(row => {
|
||||||
|
if(row.id > lastId) lastId = row.id
|
||||||
|
})
|
||||||
|
|
||||||
|
itemInfo.value.rows.push(...[
|
||||||
|
{
|
||||||
|
id:uuidv4(),
|
||||||
|
mode: "text",
|
||||||
|
text: doc.title
|
||||||
|
},
|
||||||
|
...doc.rows
|
||||||
|
])
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
if(linkedDocuments.find(i => i.agriculture)){
|
||||||
|
itemInfo.value.rows = itemInfo.value.rows.filter(i => i.key !== "dieselPos")
|
||||||
|
|
||||||
|
itemInfo.value.rows.push({
|
||||||
|
id:uuidv4(),
|
||||||
|
mode: "text",
|
||||||
|
text: "Allgemein"
|
||||||
|
})
|
||||||
|
|
||||||
|
processDieselPosition()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(route.query.linkedDocument) {
|
if(route.query.linkedDocument) {
|
||||||
itemInfo.value.linkedDocument = route.query.linkedDocument
|
itemInfo.value.linkedDocument = route.query.linkedDocument
|
||||||
|
|
||||||
@@ -228,7 +272,7 @@ const addPosition = (mode) => {
|
|||||||
|
|
||||||
if(mode === 'free'){
|
if(mode === 'free'){
|
||||||
let rowData = {
|
let rowData = {
|
||||||
id: lastId +1,
|
id: uuidv4(),
|
||||||
mode: "free",
|
mode: "free",
|
||||||
text: "",
|
text: "",
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
@@ -242,7 +286,7 @@ const addPosition = (mode) => {
|
|||||||
|
|
||||||
} else if(mode === 'normal'){
|
} else if(mode === 'normal'){
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
id: lastId +1,
|
id: uuidv4(),
|
||||||
mode: "normal",
|
mode: "normal",
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
price: 0,
|
price: 0,
|
||||||
@@ -252,7 +296,7 @@ const addPosition = (mode) => {
|
|||||||
})
|
})
|
||||||
} else if(mode === 'service'){
|
} else if(mode === 'service'){
|
||||||
let rowData = {
|
let rowData = {
|
||||||
id: lastId +1,
|
id: uuidv4(),
|
||||||
mode: "service",
|
mode: "service",
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
price: 0,
|
price: 0,
|
||||||
@@ -265,17 +309,17 @@ const addPosition = (mode) => {
|
|||||||
itemInfo.value.rows.push({...rowData, ...dataStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
itemInfo.value.rows.push({...rowData, ...dataStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
||||||
} else if(mode === "pagebreak") {
|
} else if(mode === "pagebreak") {
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
id: lastId +1,
|
id: uuidv4(),
|
||||||
mode: "pagebreak",
|
mode: "pagebreak",
|
||||||
})
|
})
|
||||||
} else if(mode === "title") {
|
} else if(mode === "title") {
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
id: lastId +1,
|
id: uuidv4(),
|
||||||
mode: "title",
|
mode: "title",
|
||||||
})
|
})
|
||||||
} else if(mode === "text") {
|
} else if(mode === "text") {
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
id: lastId +1,
|
id: uuidv4(),
|
||||||
mode: "text",
|
mode: "text",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -434,9 +478,15 @@ const getDocumentData = () => {
|
|||||||
|
|
||||||
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
|
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
|
||||||
let contactData = dataStore.getContactById(itemInfo.value.contact)
|
let contactData = dataStore.getContactById(itemInfo.value.contact)
|
||||||
let userData = dataStore.getProfileById(user.value.id)
|
|
||||||
let businessInfo = dataStore.ownTenant.businessInfo
|
let businessInfo = dataStore.ownTenant.businessInfo
|
||||||
|
|
||||||
|
if(dataStore.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 : ""}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
let rows = itemInfo.value.rows.map(row => {
|
let rows = itemInfo.value.rows.map(row => {
|
||||||
|
|
||||||
@@ -446,6 +496,16 @@ const getDocumentData = () => {
|
|||||||
if(row.mode === 'normal') row.text = dataStore.getProductById(row.product).name
|
if(row.mode === 'normal') row.text = dataStore.getProductById(row.product).name
|
||||||
if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name
|
if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name
|
||||||
|
|
||||||
|
console.log(row)
|
||||||
|
|
||||||
|
if(row.agriculture?.description) {
|
||||||
|
console.log("Row has Agri")
|
||||||
|
row.descriptionText = row.agriculture.description
|
||||||
|
} else if(row.description) {
|
||||||
|
console.log("Row has no Agri")
|
||||||
|
row.descriptionText = row.description
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...row,
|
...row,
|
||||||
rowAmount: `${getRowAmount(row)} €`,
|
rowAmount: `${getRowAmount(row)} €`,
|
||||||
@@ -463,37 +523,6 @@ const getDocumentData = () => {
|
|||||||
//Compile Start & EndText
|
//Compile Start & EndText
|
||||||
const templateStartText = Handlebars.compile(itemInfo.value.startText);
|
const templateStartText = Handlebars.compile(itemInfo.value.startText);
|
||||||
const templateEndText = Handlebars.compile(itemInfo.value.endText);
|
const templateEndText = Handlebars.compile(itemInfo.value.endText);
|
||||||
/*console.log(templateStartText({
|
|
||||||
vorname: contactData ? contactData.firstName : "",
|
|
||||||
nachname: contactData ? contactData.lastName : ""
|
|
||||||
}))*/
|
|
||||||
//console.log(templateEndText({zahlungsziel_in_tagen: itemInfo.value.paymentDays}))
|
|
||||||
|
|
||||||
|
|
||||||
if(dataStore.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 : ""}`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check if Agricultural Description is Present
|
|
||||||
itemInfo.value.rows = itemInfo.value.rows.map(row => {
|
|
||||||
|
|
||||||
let descriptionText = ""
|
|
||||||
|
|
||||||
if(row.agriculture && row.agriculture.description) {
|
|
||||||
descriptionText = row.agriculture.description
|
|
||||||
} else {
|
|
||||||
descriptionText = row.description ? row.description : null
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...row,
|
|
||||||
descriptionText: descriptionText
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const generateContext = (itemInfo, contactData) => {
|
const generateContext = (itemInfo, contactData) => {
|
||||||
return {
|
return {
|
||||||
@@ -508,6 +537,7 @@ const getDocumentData = () => {
|
|||||||
|
|
||||||
|
|
||||||
const returnData = {
|
const returnData = {
|
||||||
|
type: itemInfo.value.type,
|
||||||
adressLine: `${businessInfo.name}, ${businessInfo.street}, ${businessInfo.zip} ${businessInfo.city}`,
|
adressLine: `${businessInfo.name}, ${businessInfo.street}, ${businessInfo.zip} ${businessInfo.city}`,
|
||||||
recipient: {
|
recipient: {
|
||||||
name: customerData.name,
|
name: customerData.name,
|
||||||
@@ -1285,11 +1315,11 @@ setupPage()
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Menge</th>
|
<th>Menge</th>
|
||||||
<th>Einheit</th>
|
<th>Einheit</th>
|
||||||
<th>Preis</th>
|
<th v-if="itemInfo.type !== 'deliveryNotes'">Preis</th>
|
||||||
<th>Steuer</th>
|
<th v-if="itemInfo.type !== 'deliveryNotes'">Steuer</th>
|
||||||
<th>Rabatt</th>
|
<th v-if="itemInfo.type !== 'deliveryNotes'">Rabatt</th>
|
||||||
<th>Beschreibung</th>
|
<th>Beschreibung</th>
|
||||||
<th>Gesamt</th>
|
<th v-if="itemInfo.type !== 'deliveryNotes'">Gesamt</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -1504,7 +1534,7 @@ setupPage()
|
|||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="w-40"
|
class="w-40"
|
||||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
v-if="!['pagebreak','title','text'].includes(row.mode) && itemInfo.type !== 'deliveryNotes'"
|
||||||
>
|
>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="row.price"
|
v-model="row.price"
|
||||||
@@ -1518,7 +1548,7 @@ setupPage()
|
|||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="w-40"
|
class="w-40"
|
||||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
v-if="!['pagebreak','title','text'].includes(row.mode)&& itemInfo.type !== 'deliveryNotes'"
|
||||||
|
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
@@ -1536,7 +1566,7 @@ setupPage()
|
|||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="w-40"
|
class="w-40"
|
||||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
v-if="!['pagebreak','title','text'].includes(row.mode)&& itemInfo.type !== 'deliveryNotes'"
|
||||||
>
|
>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="row.discountPercent"
|
v-model="row.discountPercent"
|
||||||
@@ -1628,7 +1658,7 @@ setupPage()
|
|||||||
</UModal>
|
</UModal>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
v-if="!['pagebreak','title','text'].includes(row.mode) && itemInfo.type !== 'deliveryNotes'"
|
||||||
>
|
>
|
||||||
|
|
||||||
<p class="text-right font-bold whitespace-nowrap"><span v-if="row.discountPercent !== 0" class="line-through mr-2 text-rose-500">{{getRowAmountUndiscounted(row)}} €</span>{{getRowAmount(row)}} €</p>
|
<p class="text-right font-bold whitespace-nowrap"><span v-if="row.discountPercent !== 0" class="line-through mr-2 text-rose-500">{{getRowAmountUndiscounted(row)}} €</span>{{getRowAmount(row)}} €</p>
|
||||||
@@ -1703,6 +1733,8 @@ setupPage()
|
|||||||
|
|
||||||
<div class="w-full flex justify-end">
|
<div class="w-full flex justify-end">
|
||||||
<table class="w-1/3">
|
<table class="w-1/3">
|
||||||
|
<div class="w-full flex justify-end" v-if="itemInfo.type !== 'deliveryNotes'">
|
||||||
|
<table class="w-1/3" v-if="itemInfo.rows.length > 0">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font-bold">Netto:</td>
|
<td class="font-bold">Netto:</td>
|
||||||
<td class="text-right">{{documentTotal.totalNet}}</td>
|
<td class="text-right">{{documentTotal.totalNet}}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user