diff --git a/mkinvoice.go b/mkinvoice.go index f4046e7..676f534 100644 --- a/mkinvoice.go +++ b/mkinvoice.go @@ -22,7 +22,6 @@ type Metadata struct { InvoiceDate string `yaml:"invoice_date"` Vat float64 `yaml:"vat"` Account string `yaml:"account"` - DueDate string `yaml:"due_date"` VatNumber string `yaml:"vat_number"` } @@ -63,11 +62,12 @@ var totalNetAmount float64 var totalInvoiceAmount float64 const defaultFontSize = 9 +const smallFontSize = 7 const marginTop = 7 const logoTop = 6 const logoHeight = 20 const lineSpacing = 5 -const lineSpacingSmall = 3.5 +const lineSpacingSmall = 4.5 const addressTop = 50 const metadataTopFirstPage = 70 const metadataTopNotFirstPage = 30 @@ -96,7 +96,7 @@ func round5rappen(f float64) float64 { func floatToString(f float64) string { p := message.NewPrinter(language.English) s := strings.ReplaceAll(p.Sprintf("%.2f", f), ",", "'") - fmt.Printf("--- s: @%s@\n", s) + //fmt.Printf("--- s: @%s@\n", s) return s } @@ -113,8 +113,7 @@ func readInvoiceData(filename string) { log.Fatalf("error: %v", err) } - fmt.Printf("--- t:\n%v\n\n", invoiceData) - fmt.Printf("%s\n", invoiceData.BillingAddress.Name) + //fmt.Printf("--- t:\n%v\n\n", invoiceData) } func writeText(x float64, y float64, w float64, text string, alignStr ...string) { @@ -257,25 +256,27 @@ func printItems() { func printTotals() { yPos = totalsTop - pdf.Line(tabstopRight-widthPrice, yPos, tabstopRight, yPos) + pdf.Line(tabstopRight-widthPrice, yPos + (lineSpacing / 2), tabstopRight, yPos + (lineSpacing / 2)) pdf.SetFont("Dejavusans-Bold", "", defaultFontSize) yPos = yPos + lineSpacing - writeText(tabstopLeft, yPos, 0, "Netto (exkl. MwSt.)") + writeText(tabstopLeft, yPos, 0, "Summe") pdf.SetFont("Dejavusans", "", defaultFontSize) writeText(tabstopPrice, yPos, widthPrice, floatToString(totalNetAmount), "TR") yPos = yPos + lineSpacing - yPos = yPos + lineSpacing pdf.SetFont("Dejavusans-Bold", "", defaultFontSize) writeText(tabstopLeft, yPos, 0, fmt.Sprintf("MwSt. %.1f%%", invoiceData.Metadata.Vat)) mwstAmount := round5rappen(totalNetAmount * invoiceData.Metadata.Vat / 100) pdf.SetFont("Dejavusans", "", defaultFontSize) writeText(tabstopPrice, yPos, widthPrice, floatToString(mwstAmount), "TR") - yPos = yPos + lineSpacing +yPos = yPos + lineSpacing yPos = yPos + lineSpacing pdf.SetFont("Dejavusans-Bold", "", defaultFontSize) - writeText(tabstopLeft, yPos, 0, "Rechnungbetrag inkl. MwSt. in CHF") + writeText(tabstopLeft, yPos, 0, "Rechnungbetrag in CHF") totalInvoiceAmount = totalNetAmount + mwstAmount writeText(tabstopPrice, yPos, widthPrice, floatToString(totalNetAmount+mwstAmount), "TR") + yPos = yPos + lineSpacingSmall + pdf.SetFont("Dejavusans", "", smallFontSize) + writeText(tabstopLeft, yPos, 0, "30 Tage netto") } func printQR() { @@ -293,7 +294,6 @@ func printQR() { "--debtor-street", invoiceData.BillingAddress.Street, "--debtor-postalcode", invoiceData.BillingAddress.Zip, "--debtor-city", invoiceData.BillingAddress.City, - "--due-date", invoiceData.Metadata.DueDate, "--language", "de") cmd.Env = append(os.Environ(), "INVNO="+invoiceData.Metadata.InvoiceNr, @@ -303,7 +303,6 @@ func printQR() { if err != nil { log.Fatal(err) } - fmt.Printf("%s\n", stdoutStderr) opt.ImageType = "png" opt.ReadDpi = true diff --git a/qrbill.sh b/qrbill.sh index 5403701..5ebea3f 100755 --- a/qrbill.sh +++ b/qrbill.sh @@ -35,6 +35,5 @@ fi inkscape ${mydir}/temp/${INVNO}.svg --export-dpi=300 --export-filename ${mydir}/qr-images/${INVNO}.png #cairosvg ${mydir}/temp/${INVNO}.svg -o ${mydir}/qr-images/${INVNO}.png if [ $? -eq 0 ]; then - echo blabla - #rm ${mydir}/temp/${INVNO}.svg + rm ${mydir}/temp/${INVNO}.svg fi