Go to file
jordi fita mas 52256c3cb9 Fix compute_new_expense_amount to set 0.00 to taxes when subtotal is ''
The problem is that parse_price('', 2) returned NULL instead of throwing
and exception: it seems that accessing var[1] of a text[] variable set
to the empty array, {}, returns NULL, and NULL::integer is, of course,
still NULL.

Apparently, this is the only case, until now, that i had an empty
subtotal, and i did not know what to do: should i keep the function as
is and just handle its NULL return, change it to return 0 in that case,
or raise an exception?

The argument for the first two options, to leave it as is or to
return zero, was that it was convenient for me to allow empty strings as
input values, because that’s what i get from an empty <input>; returning
zero would avoid an extra coalesce everywhere the function was used.

The argument in favor to the last option, an exception, was that the
empty string does not represent an integer, nor a “unknown” (NULL)
integer, therefore the function should do the same when i pass in any
other string that does not represent an integer, just as “a.b”.

At the end i went for option three, because it is the one that breaks
fewer expectatives: casting an empty string to integer, or passing
an empty string as the first value to to_number() throw and exception in
PostgreSQL; my function should do the same.  Heck, that what **i**
expected it to do because of the casting inside the function.

To still allow empty strings as parameter to compute_new_expense_amount,
the only case so far, i only had to check for that empty string and
convert it to the string representation of zero, so that parse_price
returns the value i want for that function.  This, of course, breaks
the same expectatives as returning NULL for to_price, but i think it is
OK in this case because to_price is more general—used in many more
cases—than compute_new_expense_amount, which is only intended for that
HTML form.

Closes #77.
2023-08-25 14:19:27 +02:00
cmd/numerus Implement login cookie, its verification, and logout 2023-01-17 20:58:13 +01:00
debian Add the customer name to the invoice’s PDF file name 2023-07-07 11:34:34 +02:00
demo Add empty IBAN and BIC to demo contacts 2023-07-02 02:26:35 +02:00
deploy Fix compute_new_expense_amount to set 0.00 to taxes when subtotal is '' 2023-08-25 14:19:27 +02:00
pkg Do not give “false ID” to invoice products that come from quotations 2023-08-11 19:47:10 +02:00
po Add option to export the list of quotes, invoices, and expenses to ODS 2023-07-18 13:29:36 +02:00
revert Fix compute_new_expense_amount to set 0.00 to taxes when subtotal is '' 2023-08-25 14:19:27 +02:00
test Fix compute_new_expense_amount to set 0.00 to taxes when subtotal is '' 2023-08-25 14:19:27 +02:00
verify Fix compute_new_expense_amount to set 0.00 to taxes when subtotal is '' 2023-08-25 14:19:27 +02:00
web Add option to export the list of quotes, invoices, and expenses to ODS 2023-07-18 13:29:36 +02:00
.gitignore Ignore IntelliJ’s project files 2023-01-30 16:42:15 +01:00
COPYING Rename LICENSE to COPYING 2023-01-15 04:08:35 +01:00
Makefile Rename extension of templates to .gohtml 2023-01-30 16:48:21 +01:00
go.mod Add the customer name to the invoice’s PDF file name 2023-07-07 11:34:34 +02:00
go.sum Add the customer name to the invoice’s PDF file name 2023-07-07 11:34:34 +02:00
sqitch.conf Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
sqitch.plan Fix compute_new_expense_amount to set 0.00 to taxes when subtotal is '' 2023-08-25 14:19:27 +02:00