%syntax-version=1.0.0 %project=numerus %uri=https://numerus.tandem.blog/ roles 2023-01-12T18:42:16Z jordi fita mas # Add database roles schema_auth [roles] 2023-01-12T19:15:55Z jordi fita mas # Add authentication schema schema_public [roles] 2023-01-12T19:24:29Z jordi fita mas # Set privileges to public schema schema_numerus [roles] 2023-01-12T22:57:22Z jordi fita mas # Add application schema extension_citext [schema_public] 2023-01-12T23:03:33Z jordi fita mas # Add citext extension email [schema_numerus extension_citext] 2023-01-12T23:09:59Z jordi fita mas # Add email domain language [schema_numerus] 2023-01-21T20:55:49Z jordi fita mas # Add relation of available languages available_languages [schema_numerus language] 2023-01-21T21:11:08Z jordi fita mas # Add the initial available languages user [roles schema_auth email language] 2023-01-12T23:44:03Z jordi fita mas # Create user relation ensure_role_exists [schema_auth user] 2023-01-12T23:57:59Z jordi fita mas # Add trigger to ensure the user’s role exists extension_pgcrypto [schema_auth] 2023-01-13T00:11:50Z jordi fita mas # Add pgcrypto extension encrypt_password [schema_auth user extension_pgcrypto] 2023-01-13T00:14:30Z jordi fita mas # Add trigger to encrypt user’s password login_attempt [schema_auth] 2023-01-17T14:05:49Z jordi fita mas # Add relation to log login attempts current_user_cookie [schema_numerus] 2023-01-21T20:16:28Z jordi fita mas # Add function to get the cookie of the current Numerus’ user current_user_email [schema_numerus] 2023-01-23T19:11:53Z jordi fita mas # Add function to get the email of the current Numerus’ user build_cookie [schema_numerus current_user_email current_user_cookie] 2023-01-23T19:46:13Z jordi fita mas # Add function to build the cookie for the current user login [roles schema_numerus schema_auth extension_pgcrypto email user login_attempt build_cookie] 2023-01-13T00:32:32Z jordi fita mas # Add function to login check_cookie [schema_public user build_cookie] 2023-01-17T17:48:49Z jordi fita mas # Add function to check if a user cookie is valid logout [schema_auth current_user_email current_user_cookie user] 2023-01-17T19:10:21Z jordi fita mas # Add function to logout set_cookie [schema_public check_cookie] 2023-01-19T11:00:22Z jordi fita mas # Add function to set the role based on the cookie user_profile [schema_numerus user current_user_email current_user_cookie] 2023-01-21T23:18:20Z jordi fita mas # Add view for user profile change_password [schema_numerus user] 2023-01-23T20:22:45Z jordi fita mas # Add function to change the current user’s password extension_vat [schema_public] 2023-01-24T10:28:17Z jordi fita mas # Add vat extension extension_pg_libphonenumber [schema_public] 2023-01-24T13:50:14Z jordi fita mas # Add extension for phone numbers extension_uri [schema_public] 2023-01-24T14:29:29Z jordi fita mas # Add extension for URIs currency_code [schema_numerus] 2023-01-24T14:36:04Z jordi fita mas # Add the domain for currency code in ISO 4217 currency [schema_numerus currency_code] 2023-01-24T14:45:26Z jordi fita mas # Add the relation for currencies available_currencies [schema_numerus currency] 2023-01-24T14:54:18Z jordi fita mas # Add the initial list of available currencies country_code [schema_numerus] 2023-01-27T18:33:26Z jordi fita mas # Add domain for country codes country [schema_numerus country_code] 2023-01-27T18:39:44Z jordi fita mas # Add the relation for countries country_i18n [schema_numerus country_code language country] 2023-01-27T19:20:43Z jordi fita mas # Add table for localization of country names available_countries [schema_numerus country country_i18n] 2023-01-27T18:49:28Z jordi fita mas # Add the list of available countries company [schema_numerus extension_vat email extension_pg_libphonenumber extension_uri currency_code currency country_code country] 2023-01-24T15:03:15Z jordi fita mas # Add the relation for companies company_user [schema_numerus user company] 2023-01-24T17:50:06Z jordi fita mas # Add the relation of companies and their users payment_method [schema_numerus company] 2023-03-03T15:00:41Z jordi fita mas # Add relation of payment method company_default_payment_method [schema_numerus company payment_method] 2023-03-04T20:25:20Z jordi fita mas # Add the company’s default payment method property tax_class [schema_numerus company] 2023-02-28T10:13:14Z jordi fita mas # Add the relation for tax classes tax_rate [schema_numerus] 2023-01-28T11:33:39Z jordi fita mas # Add domain for tax rates tax [schema_numerus company tax_rate tax_class] 2023-01-28T11:45:47Z jordi fita mas # Add relation for taxes tag_name [schema_numerus] 2023-03-10T11:06:11Z jordi fita mas # Add domain for tag names contact [schema_numerus company extension_vat email extension_pg_libphonenumber extension_uri country_code country tag_name] 2023-01-29T12:59:18Z jordi fita mas # Add the relation for contacts product [schema_numerus company tax tag_name] 2023-02-04T09:17:24Z jordi fita mas # Add relation for products parse_price [schema_public] 2023-02-05T11:04:54Z jordi fita mas # Add function to convert from price to cents to_price [schema_numerus] 2023-02-05T11:46:31Z jordi fita mas # Add function to format cents to prices invoice_status [schema_numerus] 2023-02-07T14:50:26Z jordi fita mas # A relation of invoice status invoice_status_i18n [schema_numerus invoice_status language] 2023-02-07T14:56:18Z jordi fita mas # Add relation for invoice status’ translatable texts available_invoice_status [schema_numerus invoice_status invoice_status_i18n] 2023-02-07T15:07:06Z jordi fita mas # Add the list of available invoice status product_tax [schema_numerus product tax] 2023-02-08T11:36:49Z jordi fita mas # Add relation of product taxes invoice [schema_numerus company contact invoice_status payment_method currency tag_name] 2023-02-09T09:52:21Z jordi fita mas # Add relation for invoice discount_rate [schema_numerus] 2023-02-10T17:22:40Z jordi fita mas # Add domain for discount rates invoice_product [schema_numerus invoice discount_rate] 2023-02-10T17:07:08Z jordi fita mas # Add relation for invoice product invoice_product_product [schema_numerus invoice_product product] 2023-04-19T16:06:30Z jordi fita mas # Add relation of invoice products and registered products add_product [schema_numerus product product_tax parse_price company currency tag_name] 2023-02-14T10:32:18Z jordi fita mas # Add function to add new products edit_product [schema_numerus product product_tax parse_price company currency tag_name] 2023-02-14T11:06:03Z jordi fita mas # Add function to edit products invoice_product_tax [schema_numerus invoice_product tax tax_rate] 2023-02-15T13:20:30Z jordi fita mas # Add relation for taxes in invoice products new_invoice_product [schema_numerus discount_rate] 2023-02-16T21:06:01Z jordi fita mas # Add type for passing products to new invoices invoice_number_counter [schema_numerus company] 2023-02-17T13:04:48Z jordi fita mas # Add relation to count invoice numbers next_invoice_number [schema_numerus invoice_number_counter] 2023-02-17T13:21:48Z jordi fita mas # Add function to retrieve the next invoice number add_invoice [schema_numerus invoice company currency parse_price new_invoice_product tax invoice_product invoice_product_product invoice_product_tax next_invoice_number tag_name] 2023-02-16T21:12:46Z jordi fita mas # Add function to create new invoices invoice_tax_amount [schema_numerus invoice_product invoice_product_tax] 2023-02-22T12:08:35Z jordi fita mas # Add view for invoice tax amount invoice_product_amount [schema_numerus invoice_product invoice_product_tax] 2023-03-01T11:18:05Z jordi fita mas # Add view for invoice product subtotal and total invoice_amount [schema_numerus invoice_product invoice_product_amount] 2023-02-22T12:58:46Z jordi fita mas # Add view to compute subtotal and total for invoices new_invoice_amount [schema_numerus] 2023-02-23T12:08:25Z jordi fita mas # Add type to return when computing new invoice amounts compute_new_invoice_amount [schema_numerus company currency tax new_invoice_product new_invoice_amount] 2023-02-23T12:20:13Z jordi fita mas # Add function to compute the subtotal, taxes, and total amounts for a new invoice edited_invoice_product [schema_numerus discount_rate] 2023-03-11T19:22:24Z jordi fita mas # Add typo for passing products to edited invoices edit_invoice [schema_numerus invoice currency parse_price edited_invoice_product tax invoice_product invoice_product_product invoice_product_tax tag_name] 2023-03-11T18:30:50Z jordi fita mas # Add function to edit invoices add_contact [schema_numerus extension_vat email extension_pg_libphonenumber extension_uri country_code tag_name contact] 2023-03-25T22:32:37Z jordi fita mas # Add function to create new contacts edit_contact [schema_numerus email extension_uri country_code tag_name contact extension_vat extension_pg_libphonenumber] 2023-03-25T23:20:27Z jordi fita mas # Add function to edit contacts expense [schema_numerus contact company currency_code currency tag_name] 2023-04-30T13:46:36Z jordi fita mas # Add the expense relation expense_tax [schema_numerus expense tax tax_rate] 2023-05-01T14:08:33Z jordi fita mas # Add relation of expense taxes add_expense [schema_numerus expense expense_tax tax company currency parse_price tag_name] 2023-05-02T08:00:26Z jordi fita mas # Add function to create new expenses edit_expense [schema_numerus expense currency parse_price tax tag_name] 2023-05-04T09:53:04Z jordi fita mas # Add function to edit expenses expense_attachment [schema_numerus expense] 2023-05-13T19:11:21Z jordi fita mas # Add relation of expense attachments attach_to_expense [schema_numerus expense expense_attachment] 2023-05-15T10:18:31Z jordi fita mas # Add function to attach documents to expenses expense_tax_amount [schema_numerus expense expense_tax] 2023-05-18T10:15:40Z jordi fita mas # Add vier for expense tax amount quote_status [roles schema_numerus] 2023-06-06T17:05:53Z jordi fita mas # Add relation for quote status quote_status_i18n [roles schema_numerus quote_status language] 2023-06-06T17:13:50Z jordi fita mas # Add relation for quote status’ translatable texts available_quote_status [schema_numerus quote_status quote_status_i18n] 2023-06-06T17:18:48Z jordi fita mas # Add the list of available quote status quote [roles schema_numerus company quote_status currency tag_name] 2023-06-06T17:46:27Z jordi fita mas # Add relation for sales quotations quote_contact [roles schema_numerus quote contact] 2023-06-06T18:17:50Z jordi fita mas # Add relation of quote contact quote_product [roles schema_numerus quote discount_rate] 2023-06-06T18:25:05Z jordi fita mas # Add relation for quote products quote_product_product [roles schema_numerus quote_product product] 2023-06-06T18:38:26Z jordi fita mas # Add relation of quote products and registered products quote_product_tax [roles schema_numerus quote_product tax tax_rate] 2023-06-06T18:46:33Z jordi fita mas # Add relation of quotation product tax quote_payment_method [roles schema_numerus quote payment_method] 2023-06-06T18:59:12Z jordi fita mas # Add relation for the payment method of quotes quote_number_counter [roles schema_numerus company] 2023-06-07T11:05:51Z jordi fita mas # Add relatin to keep a counter of quote numbers next_quote_number [roles schema_numerus quote_number_counter] 2023-06-07T11:20:54Z jordi fita mas # Add function to retrieve the next quote number new_quote_product [schema_numerus discount_rate] 2023-06-07T11:36:37Z jordi fita mas # Add type for passing products to new quotes add_quote [roles schema_numerus quote company currency parse_price new_quote_product tax quote_product quote_payment_method quote_contact quote_product_product quote_product_tax next_quote_number tag_name] 2023-06-07T11:39:45Z jordi fita mas # Add function to create new quotes quote_tax_amount [roles schema_numerus quote_product quote_product_tax] 2023-06-07T12:45:17Z jordi fita mas # Add add view for quote tax amount quote_product_amount [roles schema_numerus quote_product quote_product_tax] 2023-06-07T12:48:58Z jordi fita mas # Add view for quote product subtotal and total quote_amount [roles schema_numerus quote_product quote_product_amount] 2023-06-07T12:52:51Z jordi fita mas # Add view to compute subtotal and total for quotes new_quote_amount [schema_numerus] 2023-06-07T12:57:45Z jordi fita mas # Add type to return when computing new quote amounts compute_new_quote_amount [roles schema_numerus company tax new_quote_product new_quote_amount] 2023-06-07T13:00:07Z jordi fita mas # Add function to compute the subtotal, taxes, and total amounts for a new quotation edited_quote_product [schema_numerus discount_rate] 2023-06-07T13:03:23Z jordi fita mas # Add type for passing products to edit quotations edit_quote [roles schema_numerus quote currency parse_price edited_quote_product tax quote_contact quote_payment_method quote_product quote_product_tax quote_product_product tag_name] 2023-06-07T13:08:10Z jordi fita mas # Add function to edit quotations @v0 2023-06-12T14:05:34Z jordi fita mas # Tag version 0 contact_phone [roles schema_numerus extension_pg_libphonenumber] 2023-06-28T11:04:19Z jordi fita mas # Add relation to keep contacts’ phone numbers contact_email [roles schema_numerus email contact] 2023-06-28T11:47:19Z jordi fita mas # Add relation to keep contacts’ emails contact_web [roles schema_numerus extension_uri contact] 2023-06-28T12:01:07Z jordi fita mas # Add relation to keep contacts’ websites contact_tax_details [roles schema_numerus contact extension_vat country_code country] 2023-06-23T09:14:03Z jordi fita mas # Add relation of contact’s tax details tax_details [schema_numerus extension_vat country_code] 2023-06-29T10:57:57Z jordi fita mas # Add composite type for contacts’ tax details invoice_contact_id_fkey [schema_numerus invoice contact_tax_details] 2023-06-30T16:50:45Z jordi fita mas # Update invoice’s contact_id foreign key to point to tax sales extension_iban [schema_numerus] 2023-07-01T22:20:38Z jordi fita mas # Add IBAN extension contact_iban [schema_numerus roles contact extension_iban] 2023-07-01T22:27:38Z jordi fita mas # Add relation for contact iban bic [schema_numerus] 2023-07-01T22:46:30Z jordi fita mas # Add BIC domain contact_swift [schema_numerus roles contact bic] 2023-07-01T23:03:13Z jordi fita mas # Add relation for contact’s SWIFT-BIC add_contact [add_contact@v0 tax_details contact_web contact_email contact_phone contact_iban contact_swift] 2023-06-29T11:10:15Z jordi fita mas # Change add contact to accept a tax_detail parameter and use the new relations for web, email, phone, iban, and swift edit_contact [edit_contact@v0 tax_details contact_web contact_email contact_phone contact_iban contact_swift] 2023-06-29T11:50:41Z jordi fita mas # Change edit_contact to require tax_details parameter and to use new relations for web, email, phone, iban, and swift input_is_valid [schema_public roles] 2023-07-03T08:42:46Z jordi fita mas # add function to check if input is valid for a domain input_is_valid_phone [schema_public roles extension_pg_libphonenumber] 2023-07-03T08:59:36Z jordi fita mas # add function to validate phone number inputs import_contact [schema_numerus roles contact contact_web contact_phone contact_email contact_iban contact_swift contact_tax_details input_is_valid input_is_valid_phone] 2023-07-02T18:50:22Z jordi fita mas # Add functions to massively import customer data @v1 2023-07-03T09:32:51Z jordi fita mas # Tag version 1 expense_status [schema_numerus roles] 2023-07-11T11:56:39Z jordi fita mas # Add the relation of expense status expense_status_i18n [schema_numerus roles expense_status language] 2023-07-11T12:09:48Z jordi fita mas # Add relation for expense status’ translatable texts available_expense_status [schema_numerus expense_status expense_status_i18n] 2023-07-11T12:13:45Z jordi fita mas # Add the list of available expense status expense_expense_status [expense] 2023-07-11T12:28:58Z jordi fita mas # Add expense_status to expense relation add_expense [add_expense@v1 expense_status expense_expense_status] 2023-07-11T13:16:16Z jordi fita mas # Add expense_status parameter to add_expense edit_expense [edit_expense@v1 expense_status expense_expense_status] 2023-07-11T13:21:17Z jordi fita mas # Add expense_status parameter to edit_expense invoice_attachment [schema_numerus roles invoice] 2023-07-12T17:10:58Z jordi fita mas # Add relation for invoice attachment attach_to_invoice [schema_numerus roles invoice invoice_attachment] 2023-07-12T17:21:19Z jordi fita mas # Add function to attachment a document to invoices new_expense_amount [schema_numerus] 2023-07-13T17:45:33Z jordi fita mas # Add type to return when computing new expense amounts compute_new_expense_amount [schema_numerus roles company tax new_expense_amount] 2023-07-13T17:34:12Z jordi fita mas # Add function to compute the taxes and total for a new expense parse_price [parse_price@v1] 2023-08-25T11:59:54Z jordi fita mas # Throw when subtotal is empty string @v2 2024-08-04T05:21:18Z jordi fita mas # Tag version 2 payment_account_type [roles schema_numerus] 2024-08-01T23:00:18Z jordi fita mas # Add payment_account_type enum payment_account_type_i18n [roles schema_numerus payment_account_type language] 2024-08-08T17:05:28Z jordi fita mas # Add relation for payment account type’s translations available_payment_account_types [schema_numerus payment_account_type payment_account_type_i18n] 2024-08-08T17:09:24Z jordi fita mas # Add the list of available payment account types payment_account [roles schema_numerus company payment_account_type extension_pgcrypto] 2024-08-01T23:11:54Z jordi fita mas # Add relation of payment account payment_account_bank [roles schema_numerus payment_account extension_iban] 2024-08-01T23:40:34Z jordi fita mas # Add relation for payment account bank payment_account_card [roles schema_numerus payment_account] 2024-08-02T00:10:54Z jordi fita mas # Add relation for payment account card add_payment_account_bank [roles schema_numerus payment_account payment_account_bank] 2024-08-03T00:24:18Z jordi fita mas # Add function to insert bank payment accounts edit_payment_account_bank [roles schema_numerus payment_account payment_account_bank extension_iban] 2024-08-10T00:04:03Z jordi fita mas # Add function to update bank payment accounts add_payment_account_card [roles schema_numerus payment_account payment_account_card] 2024-08-03T00:41:18Z jordi fita mas # Add function to insert card payment accounts edit_payment_account_card [roles schema_numerus payment_account payment_account_card] 2024-08-10T00:22:37Z jordi fita mas # Add function to update card payment accounts add_payment_account_cash [roles schema_numerus payment_account] 2024-08-03T00:49:07Z jordi fita mas # Add function to insert cash payment accounts edit_payment_account_cash [roles schema_numerus payment_account] 2024-08-10T00:34:19Z jordi fita mas # Add function to update cash payment accounts add_payment_account_other [roles schema_numerus payment_account] 2024-08-03T00:49:15Z jordi fita mas # Add function to insert other payment accounts edit_payment_account_other [roles schema_numerus payment_account] 2024-08-10T00:41:38Z jordi fita mas # Add function to update other payment accounts payment_status [roles schema_numerus] 2024-08-04T03:02:06Z jordi fita mas # Add relation of payment status payment_status_i18n [roles schema_numerus payment_status language] 2024-08-04T03:05:41Z jordi fita mas # Add relation of payment status’ translated name available_payment_status [schema_numerus payment_status payment_status_i18n] 2024-08-04T03:08:42Z jordi fita mas # Add the list of available payment status payment [roles schema_numerus company payment_account currency tag_name payment_status extension_pgcrypto] 2024-08-01T01:28:59Z jordi fita mas # Add relation for accounts payable expense_payment [roles schema_numerus expense payment] 2024-08-04T03:44:30Z jordi fita mas # Add relation of expense payments available_expense_status [available_expense_status@v2] 2024-08-04T05:24:08Z jordi fita mas # Add “partial” expense status update_expense_payment_status [roles schema_numerus expense payment expense_payment expense_tax_amount available_expense_status available_payment_status] 2024-08-04T06:36:00Z jordi fita mas # Add function to update payment and expense status add_payment [roles schema_numerus payment expense_payment company currency parse_price tag_name update_expense_payment_status] 2024-08-04T03:16:55Z jordi fita mas # Add function to insert new payments edit_payment [roles schema_numerus payment expense_payment currency parse_price tag_name update_expense_payment_status] 2024-08-04T03:31:45Z jordi fita mas # Add function to update payments payment_attachment [roles schema_numerus payment] 2024-08-11T21:01:50Z jordi fita mas # Add relation of payment attachments attach_to_payment [roles schema_numerus payment payment_attachment] 2024-08-11T21:33:36Z jordi fita mas # Add function to attach files to payments remove_payment [roles schema_numerus expense_payment payment payment_attachment update_expense_payment_status] 2024-08-11T00:30:58Z jordi fita mas # Add function to remove payments add_expense [add_expense@v2] 2024-08-12T23:48:07Z jordi fita mas # Remove the status parameter from add_expense edit_expense [edit_expense@v2] 2024-08-12T23:53:48Z jordi fita mas # Remove the expense_status from edit_expense collection [roles schema_numerus company payment_account currency tag_name payment_status extension_pgcrypto] 2024-08-18T02:54:28Z jordi fita mas # Add relation of cash (payment) collection invoice_collection [roles schema_numerus invoice collection] 2024-08-18T03:22:09Z jordi fita mas # Add relation of invoice collections available_invoice_status [available_invoice_status@v2] 2024-08-18T03:34:13Z jordi fita mas # Add “partial” invoice status, and remove “sent” and “unpaid” update_invoice_collection_status [roles schema_numerus invoice collection invoice_collection invoice_amount available_invoice_status available_payment_status] 2024-08-19T01:20:56Z jordi fita mas # Add function to update invoice and collection status add_collection [roles schema_numerus collection invoice_collection company currency parse_price tag_name update_invoice_collection_status] 2024-08-19T01:26:01Z jordi fita mas # Add function to insert new collections edit_collection [roles schema_numerus collection invoice_collection currency parse_price tag_name update_invoice_collection_status] 2024-08-19T23:58:36Z jordi fita mas # Add function to update collections collection_attachment [roles schema_numerus collection] 2024-08-20T00:34:09Z jordi fita mas # Add relation of collection attachments attach_to_collection [roles schema_numerus collection collection_attachment] 2024-08-20T00:41:53Z jordi fita mas # Add function to attach files to collections remove_collection [roles schema_numerus invoice_collection collection collection_attachment update_invoice_collection_status] 2024-08-20T00:47:27Z jordi fita mas # Add function to remove collections edit_invoice [edit_invoice@v2] 2024-08-26T08:18:08Z jordi fita mas # Remove the invoice_status parameter from edit_invoice