Compare commits

..

No commits in common. "65ee8a139c8d3bdc9b18e874f790b1d21c0049b0" and "46b079cb0b4f6751b0f97533a5af6dd3acf3f72d" have entirely different histories.

6 changed files with 52 additions and 66 deletions

View File

@ -70,15 +70,6 @@ func (field *InputField) Integer() int {
return value
}
func (field *InputField) IntegerOrNil() interface{} {
if field.Val != "" {
if i := field.Integer(); i > 0 {
return i
}
}
return nil
}
func (field *InputField) Float64() float64 {
value, err := strconv.ParseFloat(field.Val, 64)
if err != nil {

View File

@ -862,10 +862,7 @@ func (form *invoiceProductForm) Parse(r *http.Request) error {
func (form *invoiceProductForm) Validate() bool {
validator := newFormValidator()
if form.InvoiceProductId.Val != "" {
validator.CheckValidInteger(form.InvoiceProductId, 1, math.MaxInt32, gettext("Invoice product ID must be a number greater than zero.", form.locale))
}
if form.ProductId.Val != "" {
validator.CheckValidInteger(form.ProductId, 0, math.MaxInt32, gettext("Product ID must be a positive number or zero.", form.locale))
validator.CheckValidInteger(form.ProductId, 1, math.MaxInt32, gettext("Product ID must be a number greater than zero.", form.locale))
}
validator.CheckRequiredInput(form.Name, gettext("Name can not be empty.", form.locale))
if validator.CheckRequiredInput(form.Price, gettext("Price can not be empty.", form.locale)) {

View File

@ -48,9 +48,15 @@ func (src EditedInvoiceProductArray) EncodeBinary(ci *pgtype.ConnInfo, buf []byt
}
var values [][]interface{}
for _, form := range src {
var invoiceProductId interface{} = nil
if form.InvoiceProductId.Val != "" {
if id := form.InvoiceProductId.Integer(); id > 0 {
invoiceProductId = id
}
}
values = append(values, []interface{}{
form.InvoiceProductId.IntegerOrNil(),
form.ProductId.IntegerOrNil(),
invoiceProductId,
form.ProductId.Val,
form.Name.Val,
form.Description.Val,
form.Price.Val,

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-05-22 11:12+0200\n"
"POT-Creation-Date: 2023-05-19 13:55+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"
@ -565,7 +565,7 @@ msgstr "Nom"
#: pkg/products.go:169 pkg/products.go:290 pkg/expenses.go:202
#: pkg/expenses.go:361 pkg/invoices.go:187 pkg/invoices.go:597
#: pkg/invoices.go:1047 pkg/contacts.go:140 pkg/contacts.go:325
#: pkg/invoices.go:1044 pkg/contacts.go:140 pkg/contacts.go:325
msgctxt "input"
msgid "Tags"
msgstr "Etiquetes"
@ -613,25 +613,25 @@ msgctxt "input"
msgid "Taxes"
msgstr "Imposts"
#: pkg/products.go:309 pkg/profile.go:92 pkg/invoices.go:870
#: pkg/products.go:309 pkg/profile.go:92 pkg/invoices.go:867
msgid "Name can not be empty."
msgstr "No podeu deixar el nom en blanc."
#: pkg/products.go:310 pkg/invoices.go:871
#: pkg/products.go:310 pkg/invoices.go:868
msgid "Price can not be empty."
msgstr "No podeu deixar el preu en blanc."
#: pkg/products.go:311 pkg/invoices.go:872
#: pkg/products.go:311 pkg/invoices.go:869
msgid "Price must be a number greater than zero."
msgstr "El preu ha de ser un número major a zero."
#: pkg/products.go:313 pkg/expenses.go:227 pkg/expenses.go:232
#: pkg/invoices.go:880
#: pkg/invoices.go:877
msgid "Selected tax is not valid."
msgstr "Heu seleccionat un impost que no és vàlid."
#: pkg/products.go:314 pkg/expenses.go:228 pkg/expenses.go:233
#: pkg/invoices.go:881
#: pkg/invoices.go:878
msgid "You can only select a tax of each class."
msgstr "Només podeu seleccionar un impost de cada classe."
@ -739,37 +739,37 @@ msgstr "La confirmació no és igual a la contrasenya."
msgid "Selected language is not valid."
msgstr "Heu seleccionat un idioma que no és vàlid."
#: pkg/dashboard.go:138
#: pkg/dashboard.go:131
msgctxt "input"
msgid "Period"
msgstr "Període"
#: pkg/dashboard.go:141
#: pkg/dashboard.go:134
msgctxt "period option"
msgid "Month"
msgstr "Mes"
#: pkg/dashboard.go:145
#: pkg/dashboard.go:138
msgctxt "period option"
msgid "Previous month"
msgstr "Mes anterior"
#: pkg/dashboard.go:149
#: pkg/dashboard.go:142
msgctxt "period option"
msgid "Quarter"
msgstr "Trimestre"
#: pkg/dashboard.go:153
#: pkg/dashboard.go:146
msgctxt "period option"
msgid "Previous quarter"
msgstr "Trimestre anterior"
#: pkg/dashboard.go:157
#: pkg/dashboard.go:150
msgctxt "period option"
msgid "Year"
msgstr "Any"
#: pkg/dashboard.go:161
#: pkg/dashboard.go:154
msgctxt "period option"
msgid "Previous year"
msgstr "Any anterior"
@ -860,7 +860,7 @@ msgstr "Escolliu un client a facturar."
msgid "invoices.zip"
msgstr "factures.zip"
#: pkg/invoices.go:530 pkg/invoices.go:1031
#: pkg/invoices.go:530 pkg/invoices.go:1028
msgid "Invalid action"
msgstr "Acció invàlida."
@ -906,26 +906,22 @@ msgid "Discount (%)"
msgstr "Descompte (%)"
#: pkg/invoices.go:865
msgid "Invoice product ID must be a number greater than zero."
msgstr "LID del producte de factura ha de ser un número major a zero."
msgid "Product ID must be a number greater than zero."
msgstr "LID del producte ha de ser un número major a zero."
#: pkg/invoices.go:868
msgid "Product ID must be a positive number or zero."
msgstr "LID del producte ha de ser un número positiu o zero."
#: pkg/invoices.go:874
#: pkg/invoices.go:871
msgid "Quantity can not be empty."
msgstr "No podeu deixar la quantitat en blanc."
#: pkg/invoices.go:875
#: pkg/invoices.go:872
msgid "Quantity must be a number greater than zero."
msgstr "La quantitat ha de ser un número major a zero."
#: pkg/invoices.go:877
#: pkg/invoices.go:874
msgid "Discount can not be empty."
msgstr "No podeu deixar el descompte en blanc."
#: pkg/invoices.go:878
#: pkg/invoices.go:875
msgid "Discount must be a percentage between 0 and 100."
msgstr "El descompte ha de ser un percentatge entre 0 i 100."

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-05-22 11:12+0200\n"
"POT-Creation-Date: 2023-05-19 13:55+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"
@ -565,7 +565,7 @@ msgstr "Nombre"
#: pkg/products.go:169 pkg/products.go:290 pkg/expenses.go:202
#: pkg/expenses.go:361 pkg/invoices.go:187 pkg/invoices.go:597
#: pkg/invoices.go:1047 pkg/contacts.go:140 pkg/contacts.go:325
#: pkg/invoices.go:1044 pkg/contacts.go:140 pkg/contacts.go:325
msgctxt "input"
msgid "Tags"
msgstr "Etiquetes"
@ -613,25 +613,25 @@ msgctxt "input"
msgid "Taxes"
msgstr "Impuestos"
#: pkg/products.go:309 pkg/profile.go:92 pkg/invoices.go:870
#: pkg/products.go:309 pkg/profile.go:92 pkg/invoices.go:867
msgid "Name can not be empty."
msgstr "No podéis dejar el nombre en blanco."
#: pkg/products.go:310 pkg/invoices.go:871
#: pkg/products.go:310 pkg/invoices.go:868
msgid "Price can not be empty."
msgstr "No podéis dejar el precio en blanco."
#: pkg/products.go:311 pkg/invoices.go:872
#: pkg/products.go:311 pkg/invoices.go:869
msgid "Price must be a number greater than zero."
msgstr "El precio tiene que ser un número mayor a cero."
#: pkg/products.go:313 pkg/expenses.go:227 pkg/expenses.go:232
#: pkg/invoices.go:880
#: pkg/invoices.go:877
msgid "Selected tax is not valid."
msgstr "Habéis escogido un impuesto que no es válido."
#: pkg/products.go:314 pkg/expenses.go:228 pkg/expenses.go:233
#: pkg/invoices.go:881
#: pkg/invoices.go:878
msgid "You can only select a tax of each class."
msgstr "Solo podéis escoger un impuesto de cada clase."
@ -739,37 +739,37 @@ msgstr "La confirmación no corresponde con la contraseña."
msgid "Selected language is not valid."
msgstr "Habéis escogido un idioma que no es válido."
#: pkg/dashboard.go:138
#: pkg/dashboard.go:131
msgctxt "input"
msgid "Period"
msgstr "Periodo"
#: pkg/dashboard.go:141
#: pkg/dashboard.go:134
msgctxt "period option"
msgid "Month"
msgstr "Mes"
#: pkg/dashboard.go:145
#: pkg/dashboard.go:138
msgctxt "period option"
msgid "Previous month"
msgstr "Mes anterior"
#: pkg/dashboard.go:149
#: pkg/dashboard.go:142
msgctxt "period option"
msgid "Quarter"
msgstr "Trimestre"
#: pkg/dashboard.go:153
#: pkg/dashboard.go:146
msgctxt "period option"
msgid "Previous quarter"
msgstr "Trimestre anterior"
#: pkg/dashboard.go:157
#: pkg/dashboard.go:150
msgctxt "period option"
msgid "Year"
msgstr "Año"
#: pkg/dashboard.go:161
#: pkg/dashboard.go:154
msgctxt "period option"
msgid "Previous year"
msgstr "Año anterior"
@ -860,7 +860,7 @@ msgstr "Escoged un cliente a facturar."
msgid "invoices.zip"
msgstr "facturas.zip"
#: pkg/invoices.go:530 pkg/invoices.go:1031
#: pkg/invoices.go:530 pkg/invoices.go:1028
msgid "Invalid action"
msgstr "Acción inválida."
@ -906,26 +906,22 @@ msgid "Discount (%)"
msgstr "Descuento (%)"
#: pkg/invoices.go:865
msgid "Invoice product ID must be a number greater than zero."
msgstr "El ID de producto de factura tiene que ser un número mayor a cero."
msgid "Product ID must be a number greater than zero."
msgstr "El ID de producto tiene que ser un número mayor a cero."
#: pkg/invoices.go:868
msgid "Product ID must be a positive number or zero."
msgstr "El ID de producto tiene que ser un número positivo o cero."
#: pkg/invoices.go:874
#: pkg/invoices.go:871
msgid "Quantity can not be empty."
msgstr "No podéis dejar la cantidad en blanco."
#: pkg/invoices.go:875
#: pkg/invoices.go:872
msgid "Quantity must be a number greater than zero."
msgstr "La cantidad tiene que ser un número mayor a cero."
#: pkg/invoices.go:877
#: pkg/invoices.go:874
msgid "Discount can not be empty."
msgstr "No podéis dejar el descuento en blanco."
#: pkg/invoices.go:878
#: pkg/invoices.go:875
msgid "Discount must be a percentage between 0 and 100."
msgstr "El descuento tiene que ser un porcentaje entre 0 y 100."

View File

@ -56,7 +56,7 @@
}
.invoice .notes, .invoice .payment-instructions {
white-space: pre-line;
white-space: pre;
text-align: right;
}