This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/internal/email"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/pkg/invoice"
|
||||
)
|
||||
|
||||
const bufSize = 1024 * 1024 // 1Mib
|
||||
@@ -28,7 +29,9 @@ func (s Service) createInvoice(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
invoice, report, err := s.invoice.Generate(req.Creditor, &req.Debtor, time.Duration(req.DurationThreshold), req.HourlyRate, repos)
|
||||
opts := invoice.DefaultOptions
|
||||
opts.Mindur = time.Duration(req.DurationThreshold)
|
||||
invoice, report, err := s.invoice.Generate(req.Creditor, &req.Debtor, req.HourlyRate, repos, &opts)
|
||||
if err != nil {
|
||||
s.sendErr(w, http.StatusInternalServerError, "internal server error")
|
||||
return
|
||||
@@ -65,11 +68,15 @@ func (s Service) sendInvoice(w http.ResponseWriter, r *http.Request) {
|
||||
s.sendErr(w, 500, err.Error())
|
||||
return
|
||||
}
|
||||
invoice, report, err := s.invoice.Generate(req.Invoice.Creditor, &req.Invoice.Debtor, time.Duration(req.Invoice.DurationThreshold), req.Invoice.HourlyRate, repos)
|
||||
|
||||
opts := invoice.DefaultOptions
|
||||
opts.Mindur = time.Duration(req.Invoice.DurationThreshold)
|
||||
invoice, report, err := s.invoice.Generate(req.Invoice.Creditor, &req.Invoice.Debtor, req.Invoice.HourlyRate, repos, &opts)
|
||||
if err != nil {
|
||||
s.sendErr(w, http.StatusInternalServerError, "error while processing invoice:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// if no time has to be billed aka if bill for 0 CHF
|
||||
if report.Total() <= time.Duration(0) {
|
||||
s.sendErr(w, http.StatusNotFound, "no suitable issues to be billed")
|
||||
|
||||
Reference in New Issue
Block a user