Commit Graph

454 Commits

Author SHA1 Message Date
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
jordi fita mas bc5fd61d5d Move the booking’s filter to the bottom
The first thing to show, the most important, is the grid; then users
can change the grid’s output.
2024-04-19 17:39:44 +02:00
jordi fita mas 23d16fa162 Only show individual campsite and “Add campsite” links to admin
Regular users do not need, or can use, those links.
2024-04-19 17:37:28 +02:00
jordi fita mas e726bde025 Replace admin’s campsite map with a booking grid
Customer told us that they are used to a view of the booking status of
each campsite in the form of a grid: each campsite is a row, and each
day a column; bookings are show as boxes from the first day to the last
day on the corresponding campsite’s row.

I do not yet show the booking boxes, but at least now i have the grid
and date selector form in place.

In the form i would need a couple of input[type=month], but this is not
yet supported in Firefox and Safari. According to MDN, one common way
to bypass that problem is to have two fields, one for the month and the
other for the year; i just did that, but had to create a new input type
in the `form` package just for this.
2024-04-19 11:29:52 +02:00
jordi fita mas 746aa013d3 Group ACSI options and allow for usage in different groups
It turns out that, **this time**, at least, the way to compute the
discount is not by “the more expensive”, but “the more expensive _in a
given group_”.

However, there are a couple of options, such as motorhome, that can be
in different groups but only must be used once.
2024-04-03 12:56:52 +02:00
jordi fita mas b291ac34fc Tag database with version 7 2024-04-03 09:34:36 +02:00
jordi fita mas 6c18529317 Take only into account the more expensive option when computing ACSI
Apparently, this is how it is done, now.
2024-03-25 17:47:43 +01:00
jordi fita mas 75c94a95f5 Remove a paste error from camper.css 2024-03-25 16:43:58 +01:00