forked from hswaw/hscloud
bgpwtf/invoice: render SP/GTU codes on invoices
Change-Id: I2f47595c67ae0c945fa680b394cb7d5212cd389amaster
parent
3d116b2952
commit
772a133ca1
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
wkhtml "github.com/sebastiaanklippert/go-wkhtmltopdf"
|
wkhtml "github.com/sebastiaanklippert/go-wkhtmltopdf"
|
||||||
|
@ -41,6 +42,20 @@ func renderInvoicePDF(i *pb.Invoice, language string) ([]byte, error) {
|
||||||
Total string
|
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 = "<i>brak</i>."
|
||||||
|
}
|
||||||
|
|
||||||
data := struct {
|
data := struct {
|
||||||
InvoiceNumber string
|
InvoiceNumber string
|
||||||
InvoicerBilling []string
|
InvoicerBilling []string
|
||||||
|
@ -60,6 +75,7 @@ func renderInvoicePDF(i *pb.Invoice, language string) ([]byte, error) {
|
||||||
VATTotal string
|
VATTotal string
|
||||||
Total string
|
Total string
|
||||||
DeliveryCharge string
|
DeliveryCharge string
|
||||||
|
Symbols template.HTML
|
||||||
}{
|
}{
|
||||||
InvoiceNumber: i.FinalUid,
|
InvoiceNumber: i.FinalUid,
|
||||||
Date: time.Unix(0, i.Date),
|
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)),
|
InvoicerBilling: make([]string, len(i.Data.InvoicerBilling)),
|
||||||
InvoiceeBilling: make([]string, len(i.Data.CustomerBilling)),
|
InvoiceeBilling: make([]string, len(i.Data.CustomerBilling)),
|
||||||
|
Symbols: template.HTML(symbols),
|
||||||
}
|
}
|
||||||
|
|
||||||
for d, s := range i.Data.InvoicerBilling {
|
for d, s := range i.Data.InvoicerBilling {
|
||||||
|
|
|
@ -91,6 +91,9 @@ div.bgtext div {
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
-webkit-transform: rotate(-45deg);
|
-webkit-transform: rotate(-45deg);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
div.symbols {
|
||||||
|
padding: 0 0 0.5rem 0.1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
@ -153,6 +156,9 @@ div.bgtext div {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear: both; height: 1em;"></div>
|
<div style="clear: both; height: 1em;"></div>
|
||||||
|
<div class="symbols">
|
||||||
|
<b>Oznaczenia</b>: {{ .Symbols }}
|
||||||
|
</div>
|
||||||
<table class="items">
|
<table class="items">
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 60%;">Name of goods / service</th>
|
<th style="width: 60%;">Name of goods / service</th>
|
||||||
|
@ -195,5 +201,8 @@ div.bgtext div {
|
||||||
<td><b>{{ .Total }}</b></td>
|
<td><b>{{ .Total }}</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="footer">
|
||||||
|
{{ .Footer }}
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -91,6 +91,9 @@ div.bgtext div {
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
-webkit-transform: rotate(-45deg);
|
-webkit-transform: rotate(-45deg);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
div.symbols {
|
||||||
|
padding: 0 0 0.5rem 0.1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
@ -154,6 +157,9 @@ div.bgtext div {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear: both; height: 1em;"></div>
|
<div style="clear: both; height: 1em;"></div>
|
||||||
|
<div class="symbols">
|
||||||
|
<b>Oznaczenia</b>: {{ .Symbols }}
|
||||||
|
</div>
|
||||||
<table class="items">
|
<table class="items">
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 60%;">Nazwa towaru lub usługi</th>
|
<th style="width: 60%;">Nazwa towaru lub usługi</th>
|
||||||
|
|
Loading…
Reference in New Issue