Added Agriculture

Removed Prices for Delivery Notes
This commit is contained in:
2024-11-21 21:27:40 +01:00
parent 3633b8ee37
commit 60658a2ef9
2 changed files with 279 additions and 199 deletions

View File

@@ -565,28 +565,33 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
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
})
if( invoiceData.type !== "deliveryNotes") {
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
})
}
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
@@ -619,65 +624,95 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
console.log(row.text.match(/.{1,35}/g))
pages[pageCounter - 1].drawText(row.text.match(/.{1,35}/g).join("\n"), {
...getCoordinatesForPDFLib(52,rowHeight, page1),
size:10,
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),
if(invoiceData.type !== "deliveryNotes") {
pages[pageCounter - 1].drawText(row.text.match(/.{1,35}/g).join("\n"), {
...getCoordinatesForPDFLib(52,rowHeight, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
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, {
...getCoordinatesForPDFLib(135,rowHeight, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240
})
//let textLineBreaks = (row.text.match(/\n/g) || []).length
let textAutoLines = (invoiceData.type !== "deliveryNotes" ? row.text.match(/.{1,35}/g) : row.text.match(/.{1,80}/g) || []).length
console.log(textAutoLines)
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,
})
console.log(row)
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,
if(row.descriptionText) {
if(invoiceData.type !== "deliveryNotes") {
pages[pageCounter - 1].drawText(row.descriptionText.match(/.{1,70}/g).join("\n"), {
...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),
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.descriptionText) {
let lineBreaks = (row.descriptionText.match(/\n/g) || []).length
let autoLines = (row.descriptionText.match(/.{1,70}/g) || []).length
@@ -766,26 +801,30 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
font: fontBold
})
page.drawText("Einheitspreis", {
...getCoordinatesForPDFLib(135,22, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
if(invoiceData.type !== "deliveryNotes"){
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
})
}
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;
@@ -848,7 +887,7 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
})
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,
color:rgb(0,0,0),
lineHeight:12,
@@ -868,11 +907,15 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
lineHeight:10,
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
//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
})
if(invoiceData.type !== "deliveryNotes"){
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].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].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(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("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("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.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(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("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("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),