Make sure the selected taxes in show expense is nil if there is none

For some reason, pgx tries to convert [""] to an int array and fails,
because "" is not a number, of course.
This commit is contained in:
jordi fita mas 2023-10-02 12:49:54 +02:00
parent 831becf6fd
commit 80a6a802a2
3 changed files with 39 additions and 35 deletions

View File

@ -357,7 +357,7 @@ func (form *expenseForm) MustFillFromDatabase(ctx context.Context, conn *Conn, s
, invoice_number
, invoice_date
, to_price(amount, decimal_digits)
, array_agg(tax_id)
, array_agg(tax_id) filter ( where tax_id is not null )
, expense_status
, tags
from expense
@ -382,6 +382,10 @@ func (form *expenseForm) MustFillFromDatabase(ctx context.Context, conn *Conn, s
form.ExpenseStatus.Selected = selectedExpenseStatus
return false
}
if len(form.Tax.Selected) == 1 && form.Tax.Selected[0] == "" {
form.Tax.Selected = nil
}
fmt.Println(form.Tax.Selected)
return true
}
func HandleUpdateExpense(w http.ResponseWriter, r *http.Request, params httprouter.Params) {

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: numerus\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-10-02 12:11+0200\n"
"POT-Creation-Date: 2023-10-02 12:49+0200\n"
"PO-Revision-Date: 2023-01-18 17:08+0100\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\n"
@ -735,37 +735,37 @@ msgid "Name"
msgstr "Nom"
#: pkg/products.go:177 pkg/products.go:303 pkg/quote.go:174 pkg/quote.go:708
#: pkg/expenses.go:307 pkg/expenses.go:471 pkg/invoices.go:174
#: pkg/expenses.go:307 pkg/expenses.go:475 pkg/invoices.go:174
#: pkg/invoices.go:746 pkg/invoices.go:1331 pkg/contacts.go:154
#: pkg/contacts.go:362
msgctxt "input"
msgid "Tags"
msgstr "Etiquetes"
#: pkg/products.go:181 pkg/quote.go:178 pkg/expenses.go:481 pkg/invoices.go:178
#: pkg/products.go:181 pkg/quote.go:178 pkg/expenses.go:485 pkg/invoices.go:178
#: pkg/contacts.go:158
msgctxt "input"
msgid "Tags Condition"
msgstr "Condició de les etiquetes"
#: pkg/products.go:185 pkg/quote.go:182 pkg/expenses.go:485 pkg/invoices.go:182
#: pkg/products.go:185 pkg/quote.go:182 pkg/expenses.go:489 pkg/invoices.go:182
#: pkg/contacts.go:162
msgctxt "tag condition"
msgid "All"
msgstr "Totes"
#: pkg/products.go:186 pkg/expenses.go:486 pkg/invoices.go:183
#: pkg/products.go:186 pkg/expenses.go:490 pkg/invoices.go:183
#: pkg/contacts.go:163
msgid "Invoices must have all the specified labels."
msgstr "Les factures han de tenir totes les etiquetes."
#: pkg/products.go:190 pkg/quote.go:187 pkg/expenses.go:490 pkg/invoices.go:187
#: pkg/products.go:190 pkg/quote.go:187 pkg/expenses.go:494 pkg/invoices.go:187
#: pkg/contacts.go:167
msgctxt "tag condition"
msgid "Any"
msgstr "Qualsevol"
#: pkg/products.go:191 pkg/expenses.go:491 pkg/invoices.go:188
#: pkg/products.go:191 pkg/expenses.go:495 pkg/invoices.go:188
#: pkg/contacts.go:168
msgid "Invoices must have at least one of the specified labels."
msgstr "Les factures han de tenir com a mínim una de les etiquetes."
@ -1028,7 +1028,7 @@ msgctxt "input"
msgid "Quotation Status"
msgstr "Estat del pressupost"
#: pkg/quote.go:154 pkg/expenses.go:476 pkg/invoices.go:154
#: pkg/quote.go:154 pkg/expenses.go:480 pkg/invoices.go:154
msgid "All status"
msgstr "Tots els estats"
@ -1037,12 +1037,12 @@ msgctxt "input"
msgid "Quotation Number"
msgstr "Número de pressupost"
#: pkg/quote.go:164 pkg/expenses.go:461 pkg/invoices.go:164
#: pkg/quote.go:164 pkg/expenses.go:465 pkg/invoices.go:164
msgctxt "input"
msgid "From Date"
msgstr "A partir de la data"
#: pkg/quote.go:169 pkg/expenses.go:466 pkg/invoices.go:169
#: pkg/quote.go:169 pkg/expenses.go:470 pkg/invoices.go:169
msgctxt "input"
msgid "To Date"
msgstr "Fins la data"
@ -1063,8 +1063,8 @@ msgstr "pressuposts.zip"
msgid "quotations.ods"
msgstr "pressuposts.ods"
#: pkg/quote.go:634 pkg/quote.go:1176 pkg/quote.go:1184 pkg/expenses.go:680
#: pkg/expenses.go:706 pkg/invoices.go:677 pkg/invoices.go:1306
#: pkg/quote.go:634 pkg/quote.go:1176 pkg/quote.go:1184 pkg/expenses.go:684
#: pkg/expenses.go:710 pkg/invoices.go:677 pkg/invoices.go:1306
#: pkg/invoices.go:1314
msgid "Invalid action"
msgstr "Acció invàlida."
@ -1223,7 +1223,7 @@ msgstr "Any anterior"
msgid "Select a contact."
msgstr "Escolliu un contacte."
#: pkg/expenses.go:258 pkg/expenses.go:450
#: pkg/expenses.go:258 pkg/expenses.go:454
msgctxt "input"
msgid "Contact"
msgstr "Contacte"
@ -1248,7 +1248,7 @@ msgctxt "input"
msgid "File"
msgstr "Fitxer"
#: pkg/expenses.go:301 pkg/expenses.go:475
#: pkg/expenses.go:301 pkg/expenses.go:479
msgctxt "input"
msgid "Expense Status"
msgstr "Estat de la despesa"
@ -1273,16 +1273,16 @@ msgstr "Limport ha de ser un número major a zero."
msgid "Selected expense status is not valid."
msgstr "Heu seleccionat un estat de despesa que no és vàlid."
#: pkg/expenses.go:451
#: pkg/expenses.go:455
msgid "All contacts"
msgstr "Tots els contactes"
#: pkg/expenses.go:456 pkg/invoices.go:159
#: pkg/expenses.go:460 pkg/invoices.go:159
msgctxt "input"
msgid "Invoice Number"
msgstr "Número de factura"
#: pkg/expenses.go:704
#: pkg/expenses.go:708
msgid "expenses.ods"
msgstr "despeses.ods"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: numerus\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-10-02 12:11+0200\n"
"POT-Creation-Date: 2023-10-02 12:49+0200\n"
"PO-Revision-Date: 2023-01-18 17:45+0100\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\n"
@ -735,37 +735,37 @@ msgid "Name"
msgstr "Nombre"
#: pkg/products.go:177 pkg/products.go:303 pkg/quote.go:174 pkg/quote.go:708
#: pkg/expenses.go:307 pkg/expenses.go:471 pkg/invoices.go:174
#: pkg/expenses.go:307 pkg/expenses.go:475 pkg/invoices.go:174
#: pkg/invoices.go:746 pkg/invoices.go:1331 pkg/contacts.go:154
#: pkg/contacts.go:362
msgctxt "input"
msgid "Tags"
msgstr "Etiquetes"
#: pkg/products.go:181 pkg/quote.go:178 pkg/expenses.go:481 pkg/invoices.go:178
#: pkg/products.go:181 pkg/quote.go:178 pkg/expenses.go:485 pkg/invoices.go:178
#: pkg/contacts.go:158
msgctxt "input"
msgid "Tags Condition"
msgstr "Condición de las etiquetas"
#: pkg/products.go:185 pkg/quote.go:182 pkg/expenses.go:485 pkg/invoices.go:182
#: pkg/products.go:185 pkg/quote.go:182 pkg/expenses.go:489 pkg/invoices.go:182
#: pkg/contacts.go:162
msgctxt "tag condition"
msgid "All"
msgstr "Todas"
#: pkg/products.go:186 pkg/expenses.go:486 pkg/invoices.go:183
#: pkg/products.go:186 pkg/expenses.go:490 pkg/invoices.go:183
#: pkg/contacts.go:163
msgid "Invoices must have all the specified labels."
msgstr "Las facturas deben tener todas las etiquetas."
#: pkg/products.go:190 pkg/quote.go:187 pkg/expenses.go:490 pkg/invoices.go:187
#: pkg/products.go:190 pkg/quote.go:187 pkg/expenses.go:494 pkg/invoices.go:187
#: pkg/contacts.go:167
msgctxt "tag condition"
msgid "Any"
msgstr "Cualquiera"
#: pkg/products.go:191 pkg/expenses.go:491 pkg/invoices.go:188
#: pkg/products.go:191 pkg/expenses.go:495 pkg/invoices.go:188
#: pkg/contacts.go:168
msgid "Invoices must have at least one of the specified labels."
msgstr "Las facturas deben tener como mínimo una de las etiquetas."
@ -1028,7 +1028,7 @@ msgctxt "input"
msgid "Quotation Status"
msgstr "Estado del presupuesto"
#: pkg/quote.go:154 pkg/expenses.go:476 pkg/invoices.go:154
#: pkg/quote.go:154 pkg/expenses.go:480 pkg/invoices.go:154
msgid "All status"
msgstr "Todos los estados"
@ -1037,12 +1037,12 @@ msgctxt "input"
msgid "Quotation Number"
msgstr "Número de presupuesto"
#: pkg/quote.go:164 pkg/expenses.go:461 pkg/invoices.go:164
#: pkg/quote.go:164 pkg/expenses.go:465 pkg/invoices.go:164
msgctxt "input"
msgid "From Date"
msgstr "A partir de la fecha"
#: pkg/quote.go:169 pkg/expenses.go:466 pkg/invoices.go:169
#: pkg/quote.go:169 pkg/expenses.go:470 pkg/invoices.go:169
msgctxt "input"
msgid "To Date"
msgstr "Hasta la fecha"
@ -1063,8 +1063,8 @@ msgstr "presupuestos.zip"
msgid "quotations.ods"
msgstr "presupuestos.ods"
#: pkg/quote.go:634 pkg/quote.go:1176 pkg/quote.go:1184 pkg/expenses.go:680
#: pkg/expenses.go:706 pkg/invoices.go:677 pkg/invoices.go:1306
#: pkg/quote.go:634 pkg/quote.go:1176 pkg/quote.go:1184 pkg/expenses.go:684
#: pkg/expenses.go:710 pkg/invoices.go:677 pkg/invoices.go:1306
#: pkg/invoices.go:1314
msgid "Invalid action"
msgstr "Acción inválida."
@ -1223,7 +1223,7 @@ msgstr "Año anterior"
msgid "Select a contact."
msgstr "Escoged un contacto"
#: pkg/expenses.go:258 pkg/expenses.go:450
#: pkg/expenses.go:258 pkg/expenses.go:454
msgctxt "input"
msgid "Contact"
msgstr "Contacto"
@ -1248,7 +1248,7 @@ msgctxt "input"
msgid "File"
msgstr "Archivo"
#: pkg/expenses.go:301 pkg/expenses.go:475
#: pkg/expenses.go:301 pkg/expenses.go:479
msgctxt "input"
msgid "Expense Status"
msgstr "Estado del gasto"
@ -1273,16 +1273,16 @@ msgstr "El importe tiene que ser un número mayor a cero."
msgid "Selected expense status is not valid."
msgstr "Habéis escogido un estado de gasto que no es válido."
#: pkg/expenses.go:451
#: pkg/expenses.go:455
msgid "All contacts"
msgstr "Todos los contactos"
#: pkg/expenses.go:456 pkg/invoices.go:159
#: pkg/expenses.go:460 pkg/invoices.go:159
msgctxt "input"
msgid "Invoice Number"
msgstr "Número de factura"
#: pkg/expenses.go:704
#: pkg/expenses.go:708
msgid "expenses.ods"
msgstr "gastos.ods"