This commit is contained in:
@@ -2,7 +2,6 @@ package invoice
|
||||
|
||||
import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/pkg/invoice/issue"
|
||||
@@ -10,7 +9,10 @@ import (
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/pkg/invoice/report"
|
||||
)
|
||||
|
||||
func (s *Service) Generate(creditor model.Entity, deptor *model.Entity, mindur time.Duration, rate float64, repos []Repo) (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
|
||||
}
|
||||
var is []*gitea.Issue
|
||||
for _, repo := range repos {
|
||||
iss, _, err := s.gitea.ListRepoIssues(
|
||||
@@ -18,9 +20,9 @@ func (s *Service) Generate(creditor model.Entity, deptor *model.Entity, mindur t
|
||||
repo.Repo,
|
||||
gitea.ListIssueOption{
|
||||
ListOptions: gitea.ListOptions{Page: 0, PageSize: 99999},
|
||||
Since: time.Now().AddDate(0, -1, 0),
|
||||
Before: time.Now(),
|
||||
State: gitea.StateClosed,
|
||||
Since: config.Since,
|
||||
Before: config.Before,
|
||||
State: config.IssueState,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -30,13 +32,8 @@ func (s *Service) Generate(creditor model.Entity, deptor *model.Entity, mindur t
|
||||
is = append(is, iss...)
|
||||
}
|
||||
|
||||
is = filter(
|
||||
is,
|
||||
func(i *gitea.Issue) bool {
|
||||
return i.Closed != nil && i.Closed.After(time.Now().AddDate(0, -1, 0))
|
||||
},
|
||||
)
|
||||
issues := issue.FromGiteas(is, mindur)
|
||||
is = filter(is, config.IssueFilter)
|
||||
issues := issue.FromGiteas(is, config.Mindur)
|
||||
r = report.New(
|
||||
issues,
|
||||
creditor,
|
||||
|
||||
Reference in New Issue
Block a user