Commit Graph

403 Commits

Author SHA1 Message Date
jordi fita mas ba6f51ac5d Fix getting quote’s terms and conditions from form and database 2023-06-08 12:50:16 +02:00
jordi fita mas 9931796744 Add HTTP controller and view to add quotes
It still does not support quotes without contact or payment.
2023-06-07 16:35:31 +02:00
jordi fita mas efbb4da07f Added SQL views to compute computations amounts and edit them 2023-06-07 15:31:20 +02:00
jordi fita mas f54681de93 Require invoice_product_product for edit_invoice 2023-06-07 15:09:35 +02:00
jordi fita mas 86bf8765fc Use the correct integer literal for invoice_amount
PostgreSQL actually already casts the strings to integers, but best if
everything is as it should.
2023-06-07 14:54:29 +02:00
jordi fita mas a066726c2e Add function to create new quotes
I had to add the quote_number_format to company, similar to how we do
with invoices.
2023-06-07 14:14:48 +02:00
jordi fita mas aeca90256c Remove setting custom number invoice format from add_expense test
It is not necessary for this test and, since the column already has a
default value, setting it there seems like it might have any
consequence.
2023-06-07 13:27:49 +02:00
jordi fita mas 0e20eab46a Add test for invoice_number_counter counter_zero_or_positive constraint 2023-06-07 13:19:06 +02:00
jordi fita mas 775cdef097 Add foreign key constraint to invoice_number_counter.company_id 2023-06-07 13:11:29 +02:00
jordi fita mas 35b12f7ea4 Add relations for sales quotations and their products
They are mostly the same as invoices, but the contact and payment method
are optional, thus, like other optionals fields, i created relations to
link these that have payment method or contact, to avoid NULL columns in
quote.

Still missing functions to add and edit quotations, and views to compute
their tax and total amount.
2023-06-06 21:08:31 +02:00
jordi fita mas d7a256804f Move available_language.sql before user.sql in sqitch.plan
This is because when i create the demo users then i can no remove the
available languages before users, due the constrain, and i can no use
sqitch rebase or revert.
2023-06-06 19:09:48 +02:00
jordi fita mas 0ed0edeff6 Specify build_cookie dependency for login function 2023-06-04 22:59:25 +02:00
jordi fita mas 083d14e324 Allow to change the current year’s invoice number counter
This is for new users that do not start using the application from the
beginning of the current fiscal year and, therefore, need to create
invoices starting from a specific number.

I had to change the constraint on the currval to allow zero, otherwise
it would not be possible to set 1 as the next number, because users
can also not delete the row.
2023-05-31 20:01:00 +02:00
jordi fita mas 1855122d16 Update translations 2023-05-29 00:02:55 +02:00
jordi fita mas 8529da1615 Use HTMx to delete and restore invoice products
It is better that way because it works without JavaScript; if HTMx is
not available, it will just use regulars forms.

The problem is that most of the submit buttons where using formaction
to send the request to a different action, and only one button was the
“real” action.  Since i could not pass the formaction to
invoice-product-form template, i have changed the “default” action to
the one with “ancillary” functions.

I have to use a different action to remove for each product because i
can not pass the index to the backend without JavaScript: it only
depends on the button click, that already has a name for the action.
Thus, in a way, i have “merged” the action and the index in a single
name.
2023-05-29 00:01:11 +02:00
jordi fita mas 07a28639f2 There is no need for array_to_string() in tags 2023-05-27 21:36:10 +02:00
jordi fita mas 27a266097a Do not use pointer to point when retrieving tags to edit
It is the same with go 16, but with Debian’s go 15 it fails and
I believe, but i am not sure, this is the reason.
2023-05-27 20:51:36 +02:00
jordi fita mas 19f81128ec Keep the invoice number when requesting an update while editing 2023-05-26 14:02:39 +02:00
jordi fita mas d8812ba2f1 Add delete button to remove a product from the invoice form
With this button, it is no longer necessary to set the quantity to zero
to remove, at least not with JavaScript.  This is why i am using Alpine:
to use x-cloak and hide it from non-JavaScript users.

Although, i wonder if it would not be better to use HTMx for that?
2023-05-26 13:51:10 +02:00
jordi fita mas 689eab3a08 Use “Save” for all submit buttons of new/edit forms
Oriol says it is easier to understand for users.
2023-05-26 13:38:04 +02:00
jordi fita mas bec1305e8a Add an empty product to blank invoice form
There is no point in creating a new invoice without products, thus we
were forcing users to always use the “Add product” button for no reason
other than it was easier for me….

I wanted to add the product inside ServeInvoice, when the slug is “new”,
but then it tried to compute the invoice total without price or quantity
and it failed.  Thus, i add that product after it has done the
computation query.
2023-05-26 13:33:49 +02:00
jordi fita mas cbe868b6d6 Remove “shadow” variables inside invoices.ServeInvoice 2023-05-26 13:30:45 +02:00
jordi fita mas 992bbf32a9 Toggle filters forms
I tried this already when i started adding filters, but i tried to use
AlpineJS for that, and could not because it would reset the context each
time i submitted the filters, due to HTMx replacing the whole content.

I realized that the only thing i need is some “flag” to show and hide
the form with CSS.  I do not even need AlpineJS for that, but i used it
anyway because then i can use the x-cloak thing to hidde the toggle
button for users with JavaScript disabled.

Similarly, the body by default has that “flag” set in the markup, and is
removed when AlpineJS is initialized, thus if JavaScript is disabled the
filters form is shown nevertheless.
2023-05-24 12:13:09 +02:00
jordi fita mas 92edbdfc4d Reindent numerus.css with IntelliJ 2023-05-24 12:06:03 +02:00
jordi fita mas e68eb52578 Don’t show the “(optional)” label for filter inputs
It adds nothing, as all input fields for filters show be optional.
2023-05-24 11:41:48 +02:00
oriol carbonell pujolàs 79ec3ae4d6 Improve the CSS and general design 2023-05-23 23:13:21 +02:00
jordi fita mas bf2796190f Change the rows of the product description to 1 2023-05-23 15:25:55 +02:00
jordi fita mas d2a06dd1c0 Add class=filters to filters forms 2023-05-23 14:50:46 +02:00
jordi fita mas 9096cfe4f2 Wrap filter buttons with <noscript>
Since forms are already submitted on change, Oriol does not like the
idea of having a useless button around breaking the form grid.
2023-05-23 14:34:46 +02:00
jordi fita mas e974406870 Remove the “all” columns from products and contacts
That column was supposed to have a checkbox for batch operations, but
we do not have any operation that would like to perform to many products
or contacts at the same time.  For now, at least.
2023-05-23 14:21:04 +02:00
jordi fita mas 6c7762057c Change “Edit Invoice” button to just “Save” 2023-05-23 14:18:26 +02:00
jordi fita mas 65ee8a139c Use white-space: pre-line for invoice notes and payment instructions
I want the `white-space: pre` to preserve the newline characters that
users may have used, but this prevents line wrapping and long lines are
not confined within the page margins.

`pre-line` preserves the newlines, but collapses spaces and tabs, and
wraps long text, which is more what i want.
2023-05-22 11:23:19 +02:00
jordi fita mas 5cae0efe8f Fix validation of product ID for invoice products that have none
For some reason, i assumed that if the invoice product has and ID, that
is it comes from the database, it must also have a product ID, which is
incorrect, because we allow invoice lines with products not added to the
product relation.

I am using zero to mean “no product ID”, so now that validation has to
include the zero as well.
2023-05-22 11:16:21 +02:00
jordi fita mas bbabf5c733 Use a null as product ID when adding new products to invoices
Otherwise, pgx (rightfully) tries to convert a "" into a integer, as
this is the field’s type, cannot, and panics with an error.

Added a IntegerOrNull method to FormField because this is exactly the
same that happens with the invoiceProductId, and made no sense to have
to do the logic twice, or in a function inside form.
2023-05-22 11:06:06 +02:00
jordi fita mas 46b079cb0b Add tooltips to the SVG chart with date and amount 2023-05-21 19:22:46 +02:00
jordi fita mas 02a4fad443 Refactor a bit the code that draws SVG polylines in circles 2023-05-21 18:59:42 +02:00
jordi fita mas eb47988464 Add a background rectangle to the chart and fix NaN when max = 0 2023-05-21 00:14:48 +02:00
jordi fita mas 39b0b801b2 Add income and expenses chart in SVG 2023-05-20 15:53:59 +02:00
jordi fita mas d1b978054b Fix dashboard period ranges and add previous month and quarter options
Oriol told me what he actually wants: a way to see the current month,
quarter, and year for both double-check that the taxes form are filled
in correct and to see whether the business is doing well.  This is
specially important for the quarter period, as he has to fill taxes
each quarter.  Thus, the “last 90 days” thing i did was easier for me,
but completely useless for him.

We also decided to add previous month and previous quarter options
because it would be unfair to expect users check that data exactly the
last day or “lose access” to it.
2023-05-19 14:05:57 +02:00
jordi fita mas 121f03b63c Add expense_tax_amount to properly compute the net income 2023-05-18 12:36:18 +02:00
oriol carbonell pujolàs 31eff5e3ab Update 'web/static/numerus.css' 2023-05-17 15:50:08 +00:00
jordi fita mas 987a99e0df Add a period filter for the dashboard
I do not yet know whether Oriol wants a YTD or MAT period, and i went
for the easiest for me: everything is MAT.
2023-05-17 12:05:30 +02:00
jordi fita mas f68aba1387 Coalesce individual dashboard results to 0 when computing net income 2023-05-16 15:24:14 +02:00
jordi fita mas ef1003a685 Coalesce dashboard results to 0 2023-05-16 15:14:20 +02:00
jordi fita mas ce42880697 Begin the dashboard with expenses, gross income, net income, and taxes
For now i use a too-long SQL query for that, but will probably replace
it with a view.  I have to check that it is correct before i do so,
however.
2023-05-16 14:56:49 +02:00
jordi fita mas 7921b9cf80 Add attach_to_expense SQL function
Just to avoid SQL “logic” in Go source.
2023-05-15 12:38:40 +02:00
jordi fita mas ee2ed598a3 Fix invoice’s colspan for the empty index table’s row 2023-05-14 18:47:16 +02:00
jordi fita mas 3161d54aba Add expense’s file input to new and edit forms
I had to change MethodOverrider to check whether the form is encoded as
multipart/form-data or i would not be able to get the method field from
forms with files.

For now i add the file manually, i.e., outside add_expense and
edit_expense PL/pgSQL functions, because it was faster for me, but i
will probably add an attach_to_expense function, or something like that,
to avoid having the whole ON CONFLICT logic inside Golang—this belongs
to the database.
2023-05-14 18:46:16 +02:00
jordi fita mas 5d46bbb95b Add the relation to store the expense’s attachment files
It is a separate table because we allow expenses to not have such an
attachment, although we allow only an attachment per expense, and i do
not want to have a bunch of nullable columns for that.

I decided to keep the files in the database, contrary to “conventional
wisdom” of storing files in the filesystem, because these attachments
are invoices and such documets that are an integral part of the expense
relation.  In other words, losing these files would render the expense
(almost) useless.  Thus, the ACID guarantees of the database are the
most appropriate place for them.
2023-05-13 21:23:24 +02:00
jordi fita mas f639602170 Add contact’s inline form for tags 2023-05-12 11:32:39 +02:00