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