feat: user templates
This commit was merged in pull request #9.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user