Handle case of no tag given for invoice
In that case, strings.Split() return an array with a single empty string element, that does not pass the domain check for tag_name in the database. And an invoice with no tags would get an array of a single NULL in array_agg, so i had to convert it to an empty string in order for it to work as expected.
This commit is contained in:
parent
041017adc3
commit
356d0a0892
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue