feat: custom template

This commit is contained in:
2025-11-09 13:04:23 +01:00
parent 8adff6ade2
commit e57185b057
9 changed files with 68 additions and 48 deletions

View File

@@ -9,7 +9,7 @@ import (
"git.schreifuchs.ch/lou-taylor/accounting/pkg/invoice/report"
)
func (s *Service) Generate(creditor model.Entity, deptor *model.Entity, rate float64, repos []Repo, config *Options) (document io.ReadCloser, r *report.Report, err error) {
func (s *Service) Generate(creditor model.Entity, deptor *model.Entity, rate float64, repos []Repo, config *Options) (document io.ReadCloser, r report.Report, err error) {
if config == nil {
config = &DefaultOptions
}
@@ -26,7 +26,7 @@ func (s *Service) Generate(creditor model.Entity, deptor *model.Entity, rate flo
},
)
if err != nil {
return nil, nil, err
return nil, r, err
}
is = append(is, iss...)
@@ -40,6 +40,10 @@ func (s *Service) Generate(creditor model.Entity, deptor *model.Entity, rate flo
deptor,
rate,
)
if len(config.CustomTemplate) > 1 {
r = r.WithTemplate(config.CustomTemplate)
}
html, err := r.ToHTML()
if err != nil {
return document, r, err