package report

import (
	"time"

	"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"
)

type Report struct {
	Date    time.Time
	Issues  []issue.Issue
	Invoice qrbill.Invoice
	Rate    float64
	Company model.Entity
	Client  *model.Entity
}

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,
	}
	r.Invoice = qrbill.New(r.applyRate(r.Total()), r.Company, r.Client)

	return r
}
