diff --git a/pkg/invoices.go b/pkg/invoices.go index ed95288..6878312 100644 --- a/pkg/invoices.go +++ b/pkg/invoices.go @@ -56,7 +56,7 @@ func mustCollectInvoiceEntries(ctx context.Context, conn *Conn, company *Company , invoice_number , contact.business_name , contact.slug - , array_agg(tag.name::text) + , array_agg(coalesce(tag.name::text, '')) , invoice.invoice_status , isi18n.name , to_price(total, decimal_digits) @@ -583,7 +583,7 @@ func (form *invoiceForm) MustFillFromDatabase(ctx context.Context, conn *Conn, s , invoice_date , notes , payment_method_id - , string_agg(tag.name, ', ') + , string_agg(tag.name, ',') from invoice left join invoice_tag using (invoice_id) left join tag using(tag_id) where slug = $1 @@ -609,7 +609,11 @@ func mustGetTaxOptions(ctx context.Context, conn *Conn, company *Company) []*Sel func (form *invoiceForm) SplitTags() []string { reg := regexp.MustCompile("[^a-z0-9-]+") - return strings.Split(reg.ReplaceAllString(form.Tags.Val, " "), " ") + tags := strings.Split(reg.ReplaceAllString(form.Tags.Val, ","), ",") + if len(tags) == 1 && len(tags[0]) == 0 { + return []string{} + } + return tags } type invoiceProductForm struct {