This commit is contained in:
Joerg Lehmann 2020-08-05 07:46:56 +02:00
parent 43b028a31b
commit 4ab3666a98
2 changed files with 4 additions and 31 deletions

View File

@ -1,26 +0,0 @@
---
metadata:
invoice_nr: 6060900045
invoice_info: Rechnung Nummer 6060900045
invoice_date: 2. April 2020
vat: 7.7
account: CH92 0023 5235 5662 3601 G
due_date: 2019-10-31
sender_address:
name: nbit Informatik GmbH
street: Kirchweg 2
zip: 3510
city: Konolfingen
tel_no: +41 31 792 00 40
email: joerg.lehmann@nbit.ch
billing_address:
name: Coopers Group GmbH
street: Seestrasse 72b
zip: 6052
city: Hergiswil
invoice_items:
- text: Arbeitseinsatz von Jörg Lehmann als Linux Engineer bei Post_CH_AG gemäss IT Beratungsdienstleistungsvertrag vom 28.1.2020
quantity: 142
price_per_unit: 115
- text:
- text: Monat Mai 2020, Stunden gemäss beigelegtem Zeitnachweis

View File

@ -18,7 +18,6 @@ import (
// Metadata type
type Metadata struct {
InvoiceNr string `yaml:"invoice_nr"`
InvoiceInfo string `yaml:"invoice_info"`
InvoiceDate string `yaml:"invoice_date"`
Vat float64 `yaml:"vat"`
Account string `yaml:"account"`
@ -86,7 +85,7 @@ const tabstopPricePerUnit = tabstopRight - widthPrice - widthPricePerUnit
const tabstopPrice = tabstopRight - widthPrice
const itemsTopFirstPage = 105
const itemsTopNotFirstPage = 50
const totalsTop = 165
const totalsTop = 158
const maxYPos = 265
func round5rappen(f float64) float64 {
@ -232,7 +231,7 @@ func maybeNewPage() {
func printItems() {
for _, i := range invoiceData.InvoiceItems {
if i.Quantity != 0 {
writeText(tabstopQuantity, yPos, widthQuantity, fmt.Sprintf("%.1f", i.Quantity), "TR")
writeText(tabstopQuantity, yPos, widthQuantity, fmt.Sprintf("%g", i.Quantity), "TR")
writeText(tabstopPricePerUnit, yPos, widthPricePerUnit, fmt.Sprintf("%.2f", i.PricePerUnit), "TR")
itemNetAmount := round5rappen(i.Quantity * i.PricePerUnit)
totalNetAmount = totalNetAmount + itemNetAmount
@ -289,7 +288,7 @@ func printQR() {
"--creditor-street", invoiceData.SenderAddress.Street,
"--creditor-postalcode", invoiceData.SenderAddress.Zip,
"--creditor-city", invoiceData.SenderAddress.City,
"--extra-infos", invoiceData.Metadata.InvoiceInfo,
"--extra-infos", "Rechnung Nummer " + invoiceData.Metadata.InvoiceNr,
"--debtor-name", invoiceData.BillingAddress.Name,
"--debtor-street", invoiceData.BillingAddress.Street,
"--debtor-postalcode", invoiceData.BillingAddress.Zip,
@ -306,7 +305,7 @@ func printQR() {
opt.ImageType = "png"
opt.ReadDpi = true
pdf.ImageOptions("qr-images/"+invoiceData.Metadata.InvoiceNr+".png", 0, 200, -1, -1, false, opt, 0, "")
pdf.ImageOptions("qr-images/"+invoiceData.Metadata.InvoiceNr+".png", 0, 193, -1, -1, false, opt, 0, "")
}
func CreateInvoice() {