From 93e92cf62d4c0a43211a394d4e500461e6f0d21b Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Sun, 5 Mar 2023 18:43:22 +0100 Subject: [PATCH] Move call to mustGetTaxOptions of AddProducts I was trying to query the database while the connection was still busy quering the products. --- pkg/invoices.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/invoices.go b/pkg/invoices.go index e73f962..9850776 100644 --- a/pkg/invoices.go +++ b/pkg/invoices.go @@ -427,9 +427,9 @@ func (form *invoiceForm) Update() { func (form *invoiceForm) AddProducts(ctx context.Context, conn *Conn, productsId []string) { index := len(form.Products) + taxOptions := mustGetTaxOptions(ctx, conn, form.company) rows := conn.MustQuery(ctx, "select product_id, name, description, to_price(price, decimal_digits), 1 as quantity, 0 as discount, array_remove(array_agg(tax_id), null) from product join company using (company_id) join currency using (currency_code) left join product_tax using (product_id) where product_id = any ($1) group by product_id, name, description, price, decimal_digits", productsId) defer rows.Close() - taxOptions := mustGetTaxOptions(ctx, conn, form.company) for rows.Next() { product := newInvoiceProductForm(index, form.company, form.locale, taxOptions) if err := rows.Scan(product.ProductId, product.Name, product.Description, product.Price, product.Quantity, product.Discount, product.Tax); err != nil {