mirror of https://gerrit.hackerspace.pl/hscloud
parent
3976e3cee8
commit
ac140b3427
|
@ -4,6 +4,8 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"code.hackerspace.pl/hscloud/go/mirko"
|
||||
"code.hackerspace.pl/hscloud/go/statusz"
|
||||
|
@ -31,8 +33,8 @@ const invoicesFragment = `
|
|||
{{ .Msg }}
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>Internal ID</th>
|
||||
<th>Number</th>
|
||||
<th>Created/Issued</th>
|
||||
<th>Customer</th>
|
||||
<th>Amount (net)</th>
|
||||
<th>Actions</th>
|
||||
|
@ -43,8 +45,8 @@ const invoicesFragment = `
|
|||
{{ else }}
|
||||
<tr style="opacity: 0.5">
|
||||
{{ end }}
|
||||
<td>{{ .Uid }}</td>
|
||||
<td>{{ .FinalUid }}</td>
|
||||
<td>{{ .DatePretty.Format "2006/01/02 15:04:05" }}</td>
|
||||
<td>{{ index .Data.CustomerBilling 0 }}</td>
|
||||
<td>{{ .TotalNetPretty }}</td>
|
||||
<td>
|
||||
|
@ -59,6 +61,7 @@ const invoicesFragment = `
|
|||
type templateInvoice struct {
|
||||
*pb.Invoice
|
||||
TotalNetPretty string
|
||||
DatePretty time.Time
|
||||
}
|
||||
|
||||
func (s *service) setupStatusz(m *mirko.Mirko) {
|
||||
|
@ -73,6 +76,7 @@ func (s *service) setupStatusz(m *mirko.Mirko) {
|
|||
res.Invoices[i] = templateInvoice{
|
||||
Invoice: inv,
|
||||
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)
|
||||
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
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue