numerus/verify
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
..
add_contact.sql Add IBAN and BIC fields to contacts 2023-07-02 02:08:45 +02:00
add_contact@v0.sql Split contact relation into tax_details, phone, web, and email 2023-06-30 21:32:48 +02:00
add_expense.sql Add expenses statuses 2023-07-11 15:33:26 +02:00
add_expense@v1.sql Add expenses statuses 2023-07-11 15:33:26 +02:00
add_invoice.sql Remove the number field from new invoice form 2023-04-01 15:57:56 +02:00
add_product.sql Add tags for products too 2023-03-26 13:51:57 +02:00
add_quote.sql Add function to create new quotes 2023-06-07 14:14:48 +02:00
attach_to_expense.sql Add attach_to_expense SQL function 2023-05-15 12:38:40 +02:00
attach_to_invoice.sql Add attachments to invoices 2023-07-12 20:06:53 +02:00
available_countries.sql Use a select for company’s country field 2023-01-27 21:30:14 +01:00
available_currencies.sql Add the company relation and read-only form to edit 2023-01-24 21:46:07 +01:00
available_expense_status.sql Add expenses statuses 2023-07-11 15:33:26 +02:00
available_invoice_status.sql Add the invoice_status relation and its i18n 2023-02-07 16:45:27 +01:00
available_languages.sql Add currency_pattern to language relation 2023-02-23 12:12:33 +01:00
available_quote_status.sql Add the “invoiced” quote status 2023-06-11 22:19:43 +02:00
bic.sql Add IBAN and BIC fields to contacts 2023-07-02 02:08:45 +02:00
build_cookie.sql Use user’ß email for auth funcs and return cookie on email change 2023-01-23 21:18:55 +01:00
change_password.sql Add function to change the current user’s password 2023-01-23 21:41:14 +01:00
check_cookie.sql Move check_cookie to public and give access to authenticator 2023-01-18 14:12:59 +01:00
company.sql Add function to create new quotes 2023-06-07 14:14:48 +02:00
company_default_payment_method.sql Add company’s default payment method 2023-03-04 22:15:52 +01:00
company_user.sql Verify, not just test, that company has RLS with policy 2023-01-28 13:10:30 +01:00
compute_new_expense_amount.sql Compute the total amount, base plus taxes, of all expenses 2023-07-13 20:50:26 +02:00
compute_new_invoice_amount.sql Show the invoice subtotal, taxes, and total when creating it 2023-02-23 15:31:57 +01:00
compute_new_quote_amount.sql Added SQL views to compute computations amounts and edit them 2023-06-07 15:31:20 +02:00
contact.sql Replace tag relations with array attributes 2023-04-07 21:31:35 +02:00
contact_email.sql Split contact relation into tax_details, phone, web, and email 2023-06-30 21:32:48 +02:00
contact_iban.sql Add IBAN and BIC fields to contacts 2023-07-02 02:08:45 +02:00
contact_phone.sql Split contact relation into tax_details, phone, web, and email 2023-06-30 21:32:48 +02:00
contact_swift.sql Add IBAN and BIC fields to contacts 2023-07-02 02:08:45 +02:00
contact_tax_details.sql Split contact relation into tax_details, phone, web, and email 2023-06-30 21:32:48 +02:00
contact_web.sql Split contact relation into tax_details, phone, web, and email 2023-06-30 21:32:48 +02:00
country.sql Use a select for company’s country field 2023-01-27 21:30:14 +01:00
country_code.sql Use a select for company’s country field 2023-01-27 21:30:14 +01:00
country_i18n.sql Use a select for company’s country field 2023-01-27 21:30:14 +01:00
currency.sql Add the company relation and read-only form to edit 2023-01-24 21:46:07 +01:00
currency_code.sql Add the company relation and read-only form to edit 2023-01-24 21:46:07 +01:00
current_user_cookie.sql Use user’ß email for auth funcs and return cookie on email change 2023-01-23 21:18:55 +01:00
current_user_email.sql Use user’ß email for auth funcs and return cookie on email change 2023-01-23 21:18:55 +01:00
discount_rate.sql Add discount_rate domain and invoice_product relation 2023-02-10 19:02:04 +01:00
edit_contact.sql Add IBAN and BIC fields to contacts 2023-07-02 02:08:45 +02:00
edit_contact@v0.sql Split contact relation into tax_details, phone, web, and email 2023-06-30 21:32:48 +02:00
edit_expense.sql Add expenses statuses 2023-07-11 15:33:26 +02:00
edit_expense@v1.sql Add expenses statuses 2023-07-11 15:33:26 +02:00
edit_invoice.sql Add function to edit invoices 2023-03-11 20:58:20 +01:00
edit_product.sql Add tags for products too 2023-03-26 13:51:57 +02:00
edit_quote.sql Added SQL views to compute computations amounts and edit them 2023-06-07 15:31:20 +02:00
edited_invoice_product.sql Add function to edit invoices 2023-03-11 20:58:20 +01:00
edited_quote_product.sql Added SQL views to compute computations amounts and edit them 2023-06-07 15:31:20 +02:00
email.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
encrypt_password.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
ensure_role_exists.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
expense.sql Add the expense relation 2023-04-30 16:06:16 +02:00
expense_attachment.sql Add the relation to store the expense’s attachment files 2023-05-13 21:23:24 +02:00
expense_expense_status.sql Add expenses statuses 2023-07-11 15:33:26 +02:00
expense_status.sql Add expenses statuses 2023-07-11 15:33:26 +02:00
expense_status_i18n.sql Add expenses statuses 2023-07-11 15:33:26 +02:00
expense_tax.sql Add the relation of expense taxes 2023-05-01 16:17:36 +02:00
expense_tax_amount.sql Add expense_tax_amount to properly compute the net income 2023-05-18 12:36:18 +02:00
extension_citext.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
extension_iban.sql Add IBAN and BIC fields to contacts 2023-07-02 02:08:45 +02:00
extension_pg_libphonenumber.sql Add the company relation and read-only form to edit 2023-01-24 21:46:07 +01:00
extension_pgcrypto.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
extension_uri.sql Add the company relation and read-only form to edit 2023-01-24 21:46:07 +01:00
extension_vat.sql Add the company relation and read-only form to edit 2023-01-24 21:46:07 +01:00
import_contact.sql Allow importing contacts from Holded 2023-07-03 00:05:47 +02:00
input_is_valid.sql Create validation function for SQL domains and for phones 2023-07-03 11:31:59 +02:00
input_is_valid_phone.sql Create validation function for SQL domains and for phones 2023-07-03 11:31:59 +02:00
invoice.sql Replace tag relations with array attributes 2023-04-07 21:31:35 +02:00
invoice_amount.sql Add views to compute taxes and total amount of invoices 2023-02-22 14:39:38 +01:00
invoice_attachment.sql Add attachments to invoices 2023-07-12 20:06:53 +02:00
invoice_contact_id_fkey.sql Split contact relation into tax_details, phone, web, and email 2023-06-30 21:32:48 +02:00
invoice_number_counter.sql Add the function to get the next invoice number 2023-02-17 14:48:24 +01:00
invoice_product.sql Move the product_id field from invoice_product to a separate table 2023-04-19 19:30:12 +02:00
invoice_product_amount.sql Add discount and tax classes columns to invoice 2023-03-01 14:08:12 +01:00
invoice_product_product.sql Move the product_id field from invoice_product to a separate table 2023-04-19 19:30:12 +02:00
invoice_product_tax.sql Add invoice product tax relation 2023-02-15 14:49:06 +01:00
invoice_status.sql Add the invoice_status relation and its i18n 2023-02-07 16:45:27 +01:00
invoice_status_i18n.sql Add the invoice_status relation and its i18n 2023-02-07 16:45:27 +01:00
invoice_tax_amount.sql Add views to compute taxes and total amount of invoices 2023-02-22 14:39:38 +01:00
language.sql Add currency_pattern to language relation 2023-02-23 12:12:33 +01:00
login.sql Implement login cookie, its verification, and logout 2023-01-17 20:58:13 +01:00
login_attempt.sql Implement login cookie, its verification, and logout 2023-01-17 20:58:13 +01:00
logout.sql Implement login cookie, its verification, and logout 2023-01-17 20:58:13 +01:00
new_expense_amount.sql Compute the total amount, base plus taxes, of all expenses 2023-07-13 20:50:26 +02:00
new_invoice_amount.sql Show the invoice subtotal, taxes, and total when creating it 2023-02-23 15:31:57 +01:00
new_invoice_product.sql Add PL/pgSQL function to add invoices 2023-02-16 23:09:10 +01:00
new_quote_amount.sql Added SQL views to compute computations amounts and edit them 2023-06-07 15:31:20 +02:00
new_quote_product.sql Add function to create new quotes 2023-06-07 14:14:48 +02:00
next_invoice_number.sql Add the function to get the next invoice number 2023-02-17 14:48:24 +01:00
next_quote_number.sql Add function to create new quotes 2023-06-07 14:14:48 +02:00
parse_price.sql Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00
parse_price@v1.sql Fix compute_new_expense_amount to set 0.00 to taxes when subtotal is '' 2023-08-25 14:19:27 +02:00
payment_method.sql Add the payment method relation and corresponding form 2023-03-03 16:49:06 +01:00
product.sql Replace tag relations with array attributes 2023-04-07 21:31:35 +02:00
product_tax.sql Allow multiple taxes, and even not tax, for products 2023-02-08 13:47:36 +01:00
quote.sql Add relations for sales quotations and their products 2023-06-06 21:08:31 +02:00
quote_amount.sql Added SQL views to compute computations amounts and edit them 2023-06-07 15:31:20 +02:00
quote_contact.sql Add relations for sales quotations and their products 2023-06-06 21:08:31 +02:00
quote_number_counter.sql Add function to create new quotes 2023-06-07 14:14:48 +02:00
quote_payment_method.sql Add relations for sales quotations and their products 2023-06-06 21:08:31 +02:00
quote_product.sql Add relations for sales quotations and their products 2023-06-06 21:08:31 +02:00
quote_product_amount.sql Added SQL views to compute computations amounts and edit them 2023-06-07 15:31:20 +02:00
quote_product_product.sql Add relations for sales quotations and their products 2023-06-06 21:08:31 +02:00
quote_product_tax.sql Add relations for sales quotations and their products 2023-06-06 21:08:31 +02:00
quote_status.sql Add relations for sales quotations and their products 2023-06-06 21:08:31 +02:00
quote_status_i18n.sql Add relations for sales quotations and their products 2023-06-06 21:08:31 +02:00
quote_tax_amount.sql Added SQL views to compute computations amounts and edit them 2023-06-07 15:31:20 +02:00
roles.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
schema_auth.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
schema_numerus.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
schema_public.sql Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
set_cookie.sql Add a function to set request settings and the role 2023-01-19 13:07:32 +01:00
tag_name.sql Add invoice tags 2023-03-10 14:02:55 +01:00
tax.sql Introduce the concept of tax class 2023-02-28 12:02:27 +01:00
tax_class.sql Introduce the concept of tax class 2023-02-28 12:02:27 +01:00
tax_details.sql Split contact relation into tax_details, phone, web, and email 2023-06-30 21:32:48 +02:00
tax_rate.sql Add the tax relation with very rough form and handler 2023-01-28 14:18:58 +01:00
to_price.sql Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00
user.sql Add user_profile view to update the profile with form 2023-01-22 02:23:09 +01:00
user_profile.sql Add cross-request forgery detection 2023-02-02 11:39:34 +01:00