Add an empty product to blank invoice form
There is no point in creating a new invoice without products, thus we were forcing users to always use the “Add product” button for no reason other than it was easier for me…. I wanted to add the product inside ServeInvoice, when the slug is “new”, but then it tried to compute the invoice total without price or quantity and it failed. Thus, i add that product after it has done the computation query.
This commit is contained in:
parent
cbe868b6d6
commit
bec1305e8a
|
@ -413,6 +413,9 @@ func newNewInvoicePage(form *invoiceForm, r *http.Request) *newInvoicePage {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
if len(form.Products) == 0 {
|
||||||
|
form.Products = append(form.Products, newInvoiceProductForm(0, company, getLocale(r), mustGetTaxOptions(r.Context(), conn, company)))
|
||||||
|
}
|
||||||
return page
|
return page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue