chore: fix tests
All checks were successful
Go / build (push) Successful in 15s
Release / publish (push) Successful in 1m5s

This commit is contained in:
2025-08-27 22:20:03 +02:00
parent a84994ffd1
commit 8180b38225
3 changed files with 14 additions and 18 deletions

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"time"
@@ -19,26 +18,24 @@ func (s Service) createInvoice(w http.ResponseWriter, r *http.Request) {
err := json.NewDecoder(r.Body).Decode(&req)
if err != nil {
s.sendErrf(w, http.StatusBadRequest, "cannot read body: %v", err)
s.sendErr(w, http.StatusBadRequest, "cannot read body")
return
}
repos, err := req.GetRepos()
if err != nil {
s.sendErr(w, 500, err.Error())
s.sendErr(w, http.StatusInternalServerError, "cannot get repos")
return
}
invoice, report, err := s.invoice.Generate(req.Creditor, req.Debtor, time.Duration(req.DurationThreshold), req.HourlyRate, repos)
if err != nil {
log.Println("error while processing invoice:", err)
fmt.Fprint(w, "internal server error")
w.WriteHeader(http.StatusInternalServerError)
s.sendErr(w, http.StatusInternalServerError, "internal server error")
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")
s.sendErrf(w, http.StatusNotFound, "no suitable issues to be billed")
return
}