Remove “shadow” variables inside invoices.ServeInvoice

This commit is contained in:
jordi fita mas 2023-05-26 13:30:45 +02:00
parent 992bbf32a9
commit cbe868b6d6
1 changed files with 3 additions and 5 deletions

View File

@ -234,14 +234,12 @@ func ServeInvoice(w http.ResponseWriter, r *http.Request, params httprouter.Para
w.WriteHeader(http.StatusOK)
mustRenderNewInvoiceForm(w, r, form)
case "product-form":
company := mustGetCompany(r)
query := r.URL.Query()
index, _ := strconv.Atoi(query.Get("index"))
conn := getConn(r)
form := newInvoiceProductForm(index, company, getLocale(r), mustGetTaxOptions(r.Context(), conn, company))
slug := query.Get("slug")
if len(slug) > 0 {
if !form.MustFillFromDatabase(r.Context(), conn, slug) {
productSlug := query.Get("slug")
if len(productSlug) > 0 {
if !form.MustFillFromDatabase(r.Context(), conn, productSlug) {
http.NotFound(w, r)
return
}