From 772a133ca10f5a9e08c5c6e99ba02d726500a723 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Wed, 17 Feb 2021 20:28:51 +0100 Subject: [PATCH] bgpwtf/invoice: render SP/GTU codes on invoices Change-Id: I2f47595c67ae0c945fa680b394cb7d5212cd389a --- bgpwtf/invoice/render.go | 17 +++++++++++++++++ bgpwtf/invoice/templates/invoice_en.html | 9 +++++++++ bgpwtf/invoice/templates/invoice_pl.html | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/bgpwtf/invoice/render.go b/bgpwtf/invoice/render.go index 693aa62e..c0eeca11 100644 --- a/bgpwtf/invoice/render.go +++ b/bgpwtf/invoice/render.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "html/template" + "strings" "time" wkhtml "github.com/sebastiaanklippert/go-wkhtmltopdf" @@ -41,6 +42,20 @@ func renderInvoicePDF(i *pb.Invoice, language string) ([]byte, error) { Total string } + symbols := "" + var parts []string + for _, code := range i.Data.SpCode { + parts = append(parts, code.String()) + } + for _, code := range i.GtuCode { + parts = append(parts, code.String()) + } + if len(parts) > 0 { + symbols = strings.Join(parts, ", ") + "." + } else { + symbols = "brak." + } + data := struct { InvoiceNumber string InvoicerBilling []string @@ -60,6 +75,7 @@ func renderInvoicePDF(i *pb.Invoice, language string) ([]byte, error) { VATTotal string Total string DeliveryCharge string + Symbols template.HTML }{ InvoiceNumber: i.FinalUid, Date: time.Unix(0, i.Date), @@ -75,6 +91,7 @@ func renderInvoicePDF(i *pb.Invoice, language string) ([]byte, error) { InvoicerBilling: make([]string, len(i.Data.InvoicerBilling)), InvoiceeBilling: make([]string, len(i.Data.CustomerBilling)), + Symbols: template.HTML(symbols), } for d, s := range i.Data.InvoicerBilling { diff --git a/bgpwtf/invoice/templates/invoice_en.html b/bgpwtf/invoice/templates/invoice_en.html index 6a92022a..976dbdfe 100644 --- a/bgpwtf/invoice/templates/invoice_en.html +++ b/bgpwtf/invoice/templates/invoice_en.html @@ -91,6 +91,9 @@ div.bgtext div { color: #ddd; -webkit-transform: rotate(-45deg); text-transform: uppercase; +} +div.symbols { + padding: 0 0 0.5rem 0.1rem; } @@ -153,6 +156,9 @@ div.bgtext div {
+
+ Oznaczenia: {{ .Symbols }} +
@@ -195,5 +201,8 @@ div.bgtext div {
Name of goods / service{{ .Total }}
+ diff --git a/bgpwtf/invoice/templates/invoice_pl.html b/bgpwtf/invoice/templates/invoice_pl.html index 15f5d084..b09086bc 100644 --- a/bgpwtf/invoice/templates/invoice_pl.html +++ b/bgpwtf/invoice/templates/invoice_pl.html @@ -91,6 +91,9 @@ div.bgtext div { color: #ddd; -webkit-transform: rotate(-45deg); text-transform: uppercase; +} +div.symbols { + padding: 0 0 0.5rem 0.1rem; } @@ -154,6 +157,9 @@ div.bgtext div {
+
+ Oznaczenia: {{ .Symbols }} +
Nazwa towaru lub usługi