feat: custom template
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
.markdown h1 {
|
||||
font-size: 2.25em; /* relative to base 12pt */
|
||||
font-weight: 700; /* font-bold */
|
||||
font-size: 2.25em; /* relative to base 12pt */
|
||||
font-weight: 700; /* font-bold */
|
||||
margin-top: 1.5em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
@@ -49,8 +49,10 @@
|
||||
|
||||
.markdown code {
|
||||
background-color: #f3f4f6;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 0.875em; /* relative to base 12pt */
|
||||
font-family:
|
||||
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
|
||||
"Courier New", monospace;
|
||||
font-size: 0.875em; /* relative to base 12pt */
|
||||
padding: 0.125em 0.25em;
|
||||
border-radius: 0.25em;
|
||||
}
|
||||
@@ -58,7 +60,9 @@
|
||||
.markdown pre {
|
||||
background-color: #111827;
|
||||
color: #f3f4f6;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
font-family:
|
||||
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
|
||||
"Courier New", monospace;
|
||||
font-size: 0.875em;
|
||||
padding: 1em;
|
||||
border-radius: 0.5em;
|
||||
@@ -135,5 +139,3 @@
|
||||
padding-left: 1.5em;
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -3,29 +3,41 @@ package report
|
||||
import (
|
||||
"time"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/pkg/invoice/issue"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/pkg/invoice/model"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/pkg/invoice/report/qrbill"
|
||||
)
|
||||
|
||||
//go:embed assets/template.html
|
||||
var htmlTemplate string
|
||||
|
||||
type Report struct {
|
||||
Date time.Time
|
||||
Issues []issue.Issue
|
||||
Invoice qrbill.Invoice
|
||||
Rate float64
|
||||
Company model.Entity
|
||||
Client *model.Entity
|
||||
Date time.Time
|
||||
Issues []issue.Issue
|
||||
Invoice qrbill.Invoice
|
||||
Rate float64
|
||||
Company model.Entity
|
||||
Client *model.Entity
|
||||
template string
|
||||
}
|
||||
|
||||
func New(issues []issue.Issue, company model.Entity, client *model.Entity, rate float64) *Report {
|
||||
r := &Report{
|
||||
Date: time.Now(),
|
||||
Issues: issues,
|
||||
Rate: rate,
|
||||
Company: company,
|
||||
Client: client,
|
||||
func New(issues []issue.Issue, company model.Entity, client *model.Entity, rate float64) Report {
|
||||
r := Report{
|
||||
Date: time.Now(),
|
||||
Issues: issues,
|
||||
Rate: rate,
|
||||
Company: company,
|
||||
Client: client,
|
||||
template: htmlTemplate,
|
||||
}
|
||||
r.Invoice = qrbill.New(r.applyRate(r.Total()), r.Company, r.Client)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r Report) WithTemplate(template string) Report {
|
||||
r.template = template
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -9,9 +9,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
//go:embed assets/template.html
|
||||
var htmlTemplate string
|
||||
|
||||
//go:embed assets/style.css
|
||||
var style template.CSS
|
||||
|
||||
@@ -33,7 +30,7 @@ func (r Report) ToHTML() (html string, err error) {
|
||||
"time": fmtDateTime,
|
||||
"date": fmtDate,
|
||||
"duration": fmtDuration,
|
||||
}).Parse(htmlTemplate))
|
||||
}).Parse(r.template))
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user