Commit Graph

461 Commits

Author SHA1 Message Date
jordi fita mas fe7a9a78c6 Add Expander control to show “advanced controls” on login
I want to allow people to set all options of QSqlDatabase, that way i do
not force the ‘service=camper’ thing, and everyone can use whatever
parameters they see fit.

I plan to store these other options as Settings, because usualy this
should only be done once at setup, and then we only need to input the
username and login to enter.  For that same reason, i do not want to
show them all the time; only if the user wants to change anything.

As far as i know, neither QtWidgets nor Qt Quick Controls have anything
that works as Gtk’s Expander, so i had to create that component.  HTML
calls it <details>, Apple “disclosure control”[0], and both Microsoft
and Gtk “expander”[1, 2]. I’ve choosen Gtk name, but macOS looks.

[0]: https://developer.apple.com/design/human-interface-guidelines/
disclosure-controls
[1]: https://learn.microsoft.com/en-us/windows/apps/design/controls/
expander
[2]: https://docs.gtk.org/gtk4/class.Expander.html
2024-12-22 04:18:56 +01:00
jordi fita mas 392d993c8a Add MnemonicLabel and MnemonicAction components
Looks like i am going to do many Labels and Actions that require
mnemonics, and i do not want to setup the properties everytime.
2024-12-21 05:13:46 +01:00
jordi fita mas 268f4329c0 Add Mnemonic attached property
This is to accept Alt+(whatever has & in front in the label) for labels,
buttons, actions, and whatever requires a nmenonic.

I created an attached property because it is kind of similar to QML’s
Keys property.
2024-12-21 04:56:09 +01:00
jordi fita mas ca882f992b Do not keep a copy of database’s connection name
Since i only plan to use a single connection, i can use QtSql’s default
connection name.

According to the documentation, i have to make sure that no query or
database object is open when i remove the database.  I now use C++
scopes for that, but i need to have a QString declared outside of it to
get the default connection’s name.
2024-12-20 21:29:46 +01:00
jordi fita mas 5cc7192387 Move the logout button to the page’s toolbar 2024-12-19 22:29:48 +01:00
jordi fita mas 7343174056 Add login and reservations page in a StackView 2024-12-19 01:53:12 +01:00
jordi fita mas 4766d01ead Add ComponentBehavior QML pragma 2024-12-19 01:05:12 +01:00
jordi fita mas 3193e4469b Manually include moc_database.cpp
It consistently makes the build take a couple seconds(!) less than
leaving the compilation of these files to CMake; i have no idea why.
2024-12-16 19:22:39 +01:00
jordi fita mas 07705b012a Add a very ugly login page to test database connection
I want to perform all SQL queries in a thread, to avoid freezing the UI,
that sometimes might happen when there is a lot of data to fetch; should
not happen very often, though.

Neither libpq nor Qt SQL allow queries on the same connection from
differents threads, and, in Qt SQL, all queries must be performed from
the same thread where the connection was established.  In Qt5 i had to
either create a connection per thread, or use a QThread-derived object
to hold the connection and use signals and slots to pass query and
response data between the UI and database threads; it was usable but not
pretty.

With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead,
that are not as cumbersome as with Qt5, because i no longer need
QFutureWatcher.  I still have the problem that all queries must be done
from within the same thread, and QThreadPool uses an arbitrary thread.
The solution is to create a “pool” with a single, non-expirable thread,
and call all Concurrent::run onto that pool.

I have to test it properly, and first need to open the database to test
whether that, at least, works. I added a simple “login page” for that,
and to make a first attempt to error messages; i use a control that is
like Kirigami’s InlineMessage for now, but i am not sure.

I also do not know how i will configure database’s connection details. I
usually make use of pg_service.conf, because then the application only
need to know its service name, but i am not sure whether other people
would find it as comfortable as i do.
2024-12-16 12:59:19 +01:00
jordi fita mas 49b2c035ad Add skeleton for a QML application 2024-12-14 01:19:20 +01:00
jordi fita mas 7c6bac1986 Add season dates for “next year”
This is to test the booking form’s behavior when there is a gap between
bookable dates, especially around New Year’s.
2024-11-20 19:43:59 +01:00
jordi fita mas 5b89c97b00 Add operating_dates to campsite type table
We forgot that different accommodation types are not always operating on
the whole season calendar, thus we need a specific date for each type.

Someday i will add the field in the administration panel, but for now i
will have to add them by hand, as people are starting to book plots on
dates that are not operating.
2024-07-15 23:41:47 +02:00
jordi fita mas d8524c347e Fix French typo 2024-07-15 23:12:12 +02:00
jordi fita mas c54e147173 Change “ACSI” to “ACSI / ANWB”
Apparently, ANWB is a camping card similar to ACSI from the Netherlands,
and both cards have the exact same discounts.
2024-05-13 10:40:21 +02:00
jordi fita mas 92c0cb4de0 Add filters and pagination to login attempts 2024-05-03 20:45:14 +02:00
jordi fita mas b4ccdeff2f Add filters and pagination to payments 2024-05-03 20:09:07 +02:00
jordi fita mas 48c1529e6c Add pagination to invoices
I’ve removed the total amount because it is very difficult to get it
with pagination, and customer never saw it (it was from Numerus), thus
they won’t miss it—i hope.
2024-05-03 19:13:49 +02:00
jordi fita mas 674cdff87b Add a new Cursor form type
To hold the common logic of detecting pagination, forming the key, and
splitting its values later on.

I can take advantage that a form with action="get" already adds its
fields to the query string to have a common template for pagination. The
only problem is that i have different column spans for different tables,
therefore had to add a colspan to the struct.
2024-05-03 19:00:02 +02:00
jordi fita mas 3a7d454826 Add filtering and pagination to customer section 2024-05-03 18:10:16 +02:00
jordi fita mas 50548c29ab Move booking filter form struct into a separate file 2024-05-03 18:09:55 +02:00
jordi fita mas e5253f9adb Allow to cancel bookings 2024-05-03 17:21:20 +02:00
oriol carbonell pujolàs e425b88477 Fix spacing of booking forms 2024-05-03 12:55:43 +02:00
jordi fita mas c84b58a0d5 Add the section of prebookings
It is just the index of bookings in the created state, but we thought it
would make easier to understand the difference between a booking from
a customer not yet confirmed, from a booking confirmed or created by the
staff.
2024-05-03 01:01:01 +02:00
jordi fita mas 5d4fe15e88 Add filtering and pagination for bookings 2024-05-03 00:28:48 +02:00
jordi fita mas b2ee4dfea3 Add marshal_payment and unmarshal_booking functions
The idea is that we will marshal the payment, send it to the campsite’s
instance by email, and then unmarshal it as a booking, that way we can
have a one way replication from the internal to the public instance with
a way back to send the payments.

For testing purposes, i just create the booking in the same instance.

Had to change the booking relation’s permissions to allow insert from
a guest, much like for payments, because the notification from Redsys
comes as a guest connection.  I need this even with all the
marshal/unmarshal shenanigans because not everyone will have an internal
instance, thus need to allow bookings from guest connections.
2024-04-29 20:59:22 +02:00
jordi fita mas 7edf3a3ed1 Pre-fill all guests with the holder’s address
Most will be families living at the same address.  And, if they are not,
it is far easier to replace the incorrect address with the actual,
rather than write the same address to all family members under the same
household.
2024-04-29 17:49:38 +02:00
jordi fita mas f71ad2cc65 Redirect to invoice after create, not booking 2024-04-28 22:50:56 +02:00
jordi fita mas 90d8247c0f Fix null problems 2024-04-28 22:49:04 +02:00
jordi fita mas 2299f2325e Allow to create the customer to invoice “in flight”
That way i can get the data from the booking or the actual customer.
2024-04-28 22:36:21 +02:00
jordi fita mas ff9f33dfba Add invoicing of bookings
It is a bit user-hostile because you have to create a new customer prior
to create the invoice, but that’s what it is for now.
2024-04-28 21:56:51 +02:00
jordi fita mas 205d1f1e99 Include weasyprint as dependency of camper package 2024-04-28 21:47:44 +02:00
jordi fita mas d0f6c9734a Confirm a created booking if admin saves it 2024-04-28 21:00:15 +02:00
jordi fita mas 17f7520876 Add customer and invoices sections
Copied as much as i could from Numerus, and made as few modifications as
i could to adapt to this code base; it is, quite frankly, a piece of
shit.

We need to be able to create invoices from scratch “just in case”,
apparently, but it is not yet possible to create an invoice from a
booking.
2024-04-28 20:28:45 +02:00
jordi fita mas 3559ff311b Chose the actual campsite when double-clicking on the accommodation grid 2024-04-26 17:31:39 +02:00
jordi fita mas 846ca0bc5c Add an empty value to the “choose country” option in booking form
Otherwise, the value is the same as the label
2024-04-26 17:31:13 +02:00
jordi fita mas f2b24a83a3 Add check-in form
I based the form from the documentation given by the Mossos
d’Esquadra[0], required by law.

https://registreviatgers.mossos.gencat.cat/mossos_hotels/AppJava/fitxaviatger.do?reqCode=create
2024-04-26 17:09:36 +02:00
jordi fita mas c9e8165f83 Allow updating bookings
I need to retrieve the values from the database and put them in the
form, like all other forms, but in this case the processing is done as
if it were a new form, because everything comes from the query string
and there is no need to do any extra work then.

Had to move the <footer> from the fields.gohtml to form.gohtml because
then it could not know that it was editing an existing booking.  Had to
move the <fieldset> out too, in order to give it an ID and make it
htmx’s target, or it would replace the form, causing even more problems
—the button would disappear then—.  The target **must** be in <form>
because it is needed for tis children’s hx-get and for its own hx-put.
2024-04-25 20:27:08 +02:00
jordi fita mas 30e87c309e Remove useless fields from paymentDraft
At first i thought i would need to keep the second query of draftPayment
in newBookingCart, its caller, and i added these fields to pass back
the parsed or retrieved values, but when i could move that query within
draftPayment i forgot to remove them.
2024-04-25 13:17:07 +02:00
jordi fita mas 9eb6483cb9 Allow opening a booking or creating a new from the booking grid
I wanted to use a regular <a>, but apparently rendering that many
anchors is too resource-intensive for Firefox, and it is noticeably
slower.  It was even worse, in fact, because i had to have different
content for the main grid and the grid show in the new booking form,
as i did not want to have these links there, and had call a template for
each cell: 3 months × ~30 days × ~100 campsites = 9000 calls!

Using JavaScript for that is shameful, but it does not add much to the
existing markup, and no need for template fuckery.

I am using double-click to follow these links, instead of single click,
because it would be too easy to misclik on the grid, but that forced me
to add `user-select: none` to prevent the selection of text when double-
clicking.
2024-04-25 12:29:43 +02:00
jordi fita mas 2d4055b653 Fix insert of booking in demo SQL file 2024-04-24 20:39:19 +02:00
jordi fita mas b7e7d79177 Add alter column back to integer for booking.number_dogs in reverse 2024-04-24 20:29:23 +02:00
jordi fita mas fdf9502c8b “Finish” the new booking form
Had to bring the same fields that i have for a payment to booking,
except that some of those should be nullable, because it is unreasonable
to ask front desk to gather all customer data when they have a booking
via phone, for instance.

Therefore, i can not take advantage of the validation for customer data
that i use in the public-facing form, but, fortunately, most of the
validations where in separated functions, thus only had to rewrite that
one for this case.

I already have to create a booking from a payment, when receiving a
payment from the public instance, thus i made that function and reused
it here.  Then i “overwrite” the newly created pre-booking with the
customer data from the form, and set is as confirmed, as we do not see
any point of allowing pre-bookings from employees.
2024-04-24 20:19:13 +02:00
jordi fita mas 3aa53cf1a9 “Mockup” for the new booking form
It does nothing but compute the total of a booking, much like it does
for guests.  In fact, i use the same payment relations to do the exact
same computation, otherwise i am afraid i will make a mistake in the
ACSI or such, now or in future version; better if both are exactly the
same.

The idea is that once the user creates the booking, i will delete that
payment, because it makes no sense to keep it in this case; nobody is
going to pay for it.

Had to reuse the grid showing the bookings of campsites because
employees need to select one or more campsites to book, and need to see
which are available.  In this case, i have to filter by campsite type
and use the arrival and departure dates to filter the months, now up to
the day, not just month.

Had to change max width of th and td in the grid to take into account
that now a month could have a single day, for instance, and the month
heading can not stretch the day or booking spans would not be in their
correct positions.

For that, i needed to access campsiteEntry, bookingEntry, and Month from
campsite package, but campsite imports campsite/types, and
campsite/types already imports booking for the BookingDates type.  To
break the cycle, had to move all that to booking and use from campsite;
it is mostly unchanged, except for the granularity of dates up to days
instead of just months.

The design of this form calls for a different way of showing the totals,
because here employees have to see the amount next to the input with
the units, instead of having a footer with the table.  I did not like
the idea of having to query the database for that, therefore i “lifter”
the payment draft into a struct that both public and admin forms use
to show they respective views of the cart.
2024-04-23 21:07:41 +02:00
jordi fita mas 598354e8b7 Add missing autocomplete attribute to town or village 2024-04-22 18:44:48 +02:00
jordi fita mas dab19bbc4d Fix attributes of country select in public booking page 2024-04-22 18:44:22 +02:00
jordi fita mas 0e22096447 Tag version 8 of the database
I will need to change draft_payment **again**, and possibly many times,
during the development of the booking admin section.  Many times.
2024-04-22 13:43:38 +02:00
jordi fita mas a26e9c6e12 Fix tests for booking and booking_campsite 2024-04-21 21:57:34 +02:00
jordi fita mas 7eb718dfd9 Allow many campsites for each reservation
This is actually only used for plots, but, of course, it means that
every booking now can potentially have many booked campsites, and have
to create a relation for it.

I now have a conundrum regarding stay dates: i need them to be in the
same table as the campsite_id, because constraints only work on a single
relation and without the dates i can not make sure that i am not
overbooking a given campsite; but, on the other hand, all campsites
under the same booking must be for the same dates.

Where does stay belong, then? In booking or booking_campsite? If in
booking then i can not have a constraint that most assuredly will bite
me in the back, but if in booking_campsite then each campsite could
potentially have different dates.

As far as i can see, i can not use a exclude constraint with <> for
dates in booking_campsite to ensure that all rows with the same
booking_id have the same stay (i.e., exclude those that have a different
stay for the same booking_id).

For now, the say is in **both** relations: in booking, because i need it
when it is a prebooking, at least, and in booking_campsite for the
aforementioned constraint requirements.

Will this come back and bite me? Yes, it will. But what can i do?
2024-04-21 21:28:41 +02:00
jordi fita mas cba892c4c0 Fix booking list to use stay instead of arrival_date and departure_date 2024-04-19 21:29:36 +02:00
jordi fita mas cdd91c815e Show booking on booking grid
I need the campsite_id in booking to know what row to show the booking
at. Besides the need of knowing which actual campsite has been booked,
of course.

This field is nullable because we can not now it until an employee has
confirmed the booking; until that point we only know the campsite type
customer requested.  I do not care much if the campsite_id is from a
different campsite_type, because maybe the customer requested the change
by phone or what have you, therefore the database can not be that
strict.  It must have a value if the booking is confirmed.

It helps me if the arrival_date and departure_date is a single
daterange, because then i can use `&&` and other range operators to work
with these dates.  For instance, i have to intersect it with the range
displayed on the screen in order to know which day i have to put it.
But then i have to know whether the booking begins and ends in the
display range, because i only have to show arrival and departure (i.e.,
the box half-way within the first or last boxes) on these days only.
2024-04-19 21:09:28 +02:00