mirror of https://gerrit.hackerspace.pl/hscloud
parent
3976e3cee8
commit
ac140b3427
|
@ -4,6 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sort"
|
||||||
|
"time"
|
||||||
|
|
||||||
"code.hackerspace.pl/hscloud/go/mirko"
|
"code.hackerspace.pl/hscloud/go/mirko"
|
||||||
"code.hackerspace.pl/hscloud/go/statusz"
|
"code.hackerspace.pl/hscloud/go/statusz"
|
||||||
|
@ -31,8 +33,8 @@ const invoicesFragment = `
|
||||||
{{ .Msg }}
|
{{ .Msg }}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Internal ID</th>
|
|
||||||
<th>Number</th>
|
<th>Number</th>
|
||||||
|
<th>Created/Issued</th>
|
||||||
<th>Customer</th>
|
<th>Customer</th>
|
||||||
<th>Amount (net)</th>
|
<th>Amount (net)</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
|
@ -43,8 +45,8 @@ const invoicesFragment = `
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<tr style="opacity: 0.5">
|
<tr style="opacity: 0.5">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<td>{{ .Uid }}</td>
|
|
||||||
<td>{{ .FinalUid }}</td>
|
<td>{{ .FinalUid }}</td>
|
||||||
|
<td>{{ .DatePretty.Format "2006/01/02 15:04:05" }}</td>
|
||||||
<td>{{ index .Data.CustomerBilling 0 }}</td>
|
<td>{{ index .Data.CustomerBilling 0 }}</td>
|
||||||
<td>{{ .TotalNetPretty }}</td>
|
<td>{{ .TotalNetPretty }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -59,6 +61,7 @@ const invoicesFragment = `
|
||||||
type templateInvoice struct {
|
type templateInvoice struct {
|
||||||
*pb.Invoice
|
*pb.Invoice
|
||||||
TotalNetPretty string
|
TotalNetPretty string
|
||||||
|
DatePretty time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) setupStatusz(m *mirko.Mirko) {
|
func (s *service) setupStatusz(m *mirko.Mirko) {
|
||||||
|
@ -73,6 +76,7 @@ func (s *service) setupStatusz(m *mirko.Mirko) {
|
||||||
res.Invoices[i] = templateInvoice{
|
res.Invoices[i] = templateInvoice{
|
||||||
Invoice: inv,
|
Invoice: inv,
|
||||||
TotalNetPretty: fmt.Sprintf("%.2f %s", float64(inv.TotalNet)/100, inv.Unit),
|
TotalNetPretty: fmt.Sprintf("%.2f %s", float64(inv.TotalNet)/100, inv.Unit),
|
||||||
|
DatePretty: time.Unix(0, inv.Date),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +84,8 @@ func (s *service) setupStatusz(m *mirko.Mirko) {
|
||||||
glog.Errorf("Could not get invoices for statusz: %v", err)
|
glog.Errorf("Could not get invoices for statusz: %v", err)
|
||||||
res.Msg = fmt.Sprintf("Could not get invoices: %v", err)
|
res.Msg = fmt.Sprintf("Could not get invoices: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Slice(res.Invoices, func(i, j int) bool { return res.Invoices[i].Date > res.Invoices[j].Date })
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue