Commit Graph

421 Commits

Author SHA1 Message Date
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
jordi fita mas 72f8a329d2 Use pre-authorization to accept payment, rather than charge
Customer wants this because the booking is not automatically created,
thus it is possible to overbook.  They want to accept the payment of
those that they can actually book.
2024-03-24 22:06:59 +01:00
jordi fita mas d71d974abd Change demo’s email address
Since this address is used to send notifications when a new payment is
received, is quite important not to use the same address as in
production, or there is a non-trivial chance of confusion.
2024-03-24 20:28:48 +01:00
jordi fita mas 1b46f4224e Compute the subtotal of dogs using their number, not as a boolean
I swear i believe sometime before we said that the number of dogs is not
important and should be used only as a boolean, but apparently it is
wrong: it should be number_dogs * cost_per_pet.
2024-03-20 18:17:58 +01:00
jordi fita mas fc9ac321d5 Tag database with version 6 2024-03-20 18:10:49 +01:00
jordi fita mas dbbd06cf85 Change the verify for season_calendar_season_id_fkey
It failed in build.opensuse.org; possibly the view in information_scheme
is different.
2024-03-14 22:28:46 +01:00
jordi fita mas 0412ffca05 Compute ACSI discount
After months of keeping what does the ACSI checkbox mean, now customer
told us that we should add a discount based on a series of
arbitrary conditions that, and need to be done NOW!

There is no UI to edit the conditions due to lack of time.
2024-03-14 22:08:01 +01:00
jordi fita mas cc1b334639 Add missing foreign key between season_calendar and season 2024-03-14 18:38:58 +01:00
jordi fita mas cb1e3afb44 Tag database with v5 2024-03-13 20:55:58 +01:00
jordi fita mas 864286e52a Fix the scheme used in flush payments’ cronjob 2024-03-13 18:28:46 +01:00
jordi fita mas 5cf45dcd41 Add flush_payments to clean up draft and pending payments
I always intended to delete draft payments after some time. I follow
WooCommerce’s default times: 1 day for draft and 1 hour for pending. No
other reason than we are used to it.

I added a cron job, rather than a systemd timer, because i want email
notifications, and because i do not yet know how to add many service
files in a Debian package.
2024-03-13 14:54:30 +01:00
jordi fita mas 75e0d8e197 Increase HTTP timeout
We have some clients that are on slow connections that have trouble
uploading large images due to timeout, and receive a “Guru Meditation”
from Varnish that it could not fetch.
2024-03-05 12:05:00 +01:00
jordi fita mas 365fed55b1 Grant SELECT on payment_status to guest
It is necessary to send the details email from the notification handler.
2024-02-29 18:06:50 +01:00
jordi fita mas 0ba088e5e2 Remove an HTML tag from email’s body in plain text 2024-02-29 17:39:00 +01:00
jordi fita mas dc9e45dfde Send a notification email to the company too on successful payment 2024-02-29 16:59:30 +01:00
jordi fita mas 334904fc03 Actually log request to stdout to be captured by systemd 2024-02-29 16:12:08 +01:00
jordi fita mas 9dc4c4ef8d Remove a fmt.Println leftover from a debug session 2024-02-29 16:11:23 +01:00
jordi fita mas 4e2df3f3c3 Return HTTP 200 instead of HTTP 204 for payment notifications
Redsys are a bunch of … something: they **only** recognize HTTP 200
as success; HTTP 204 apparently is an error for they, and don’t get
me started in not understanding what to do with an HTP 301.

Let’s just give in, and relax.
2024-02-28 13:42:12 +01:00
jordi fita mas 62d15970bf Reduce booking’s change delay to 500 ms 2024-02-28 13:36:14 +01:00
jordi fita mas 80835256cc Use idiomorph and a delay in the booking form
This is specially for the departure date: Firefox triggers a change each
time the user writes something, but since the date may be outside the
allowed range while the user is typing, the form replaces the input with
the “corrected” one.  The idiomorph thing is to keep the focus in the
“same” field, from the point of view of the user.

It still happens if one is slow enough, but i guess people that want to
write instead of picking the date are usually fast typist. Let’s hope.
2024-02-27 20:06:28 +01:00
jordi fita mas 97831668e5 Add the number of maximum nights that tourist tax applies
This is required by law.

I do not know why i have this value and the tax amount in the database,
but the payment percent and the number of days are hardcoded. I guess i
am such an inconsistent mess.
2024-02-27 20:06:28 +01:00
jordi fita mas 9ba9bac2a8 Tag sqitch with version version 4 2024-02-27 20:06:28 +01:00
oriol carbonell pujolàs 087108fe90 Add plausible script 2024-02-27 20:06:02 +01:00
jordi fita mas 9761f334be Translate footer links 2024-02-26 19:13:17 +01:00
oriol carbonell pujolàs b6387446b4 Add links to credits, terms and conditions, and reservation conditions 2024-02-26 19:10:27 +01:00
jordi fita mas 23e2fe956f Add a warning on the booking page when payment is using test environment
Apparently, the bank has to validate the fucking thing on the actual
domain, because of reasons, so we have to replace the current web in
production with this version in test mode, meaning that users **will**
believe they have paid, when in fact they have not.

The warning is for these few people that actually read such notices.
2024-02-26 16:00:29 +01:00
jordi fita mas 950bae16e1 Make address, postcode, and city require for booking
Customer changed their mind.
2024-02-24 20:03:11 +01:00
oriol carbonell pujolàs c848330751 Fix gap and margin for booking’s checkbox 2024-02-15 16:55:35 +01:00
jordi fita mas 6c14973076 Open port 8069 for camper.tandem.ws
This way i can expose that port when testing webhooks and stuff.
2024-02-15 16:36:31 +01:00
jordi fita mas a159bc75f0 Show a disclaimer on top of book button that it is in fact a prebooking 2024-02-15 15:54:22 +01:00
jordi fita mas 3bc4175580 Add authorization holding for payments
This is the mode they want to work with, but i could not test it because
they do not have it enabled in Redsys.  For now, just add the status and
the code to handle the responses.

Now i store all responses, if they are for a valid payment, just in case
i fucked something up. I also needed it because an authorization hold
needs at least two responses: one to accept the hold, and another for
the settlement.
2024-02-15 15:17:21 +01:00
jordi fita mas f2143cd0e6 Add the admin page to see payments
Had to do a couple of changes to the database: add the currency_code to
the payment relation, to format the price according to the payment’s
currency instead of the company’s; and the reference SQL function, to
replace the equivalent golang function, so that i can use it to index
payments.

The rest is mostly the same as any other page, except that the
individual payment’s page is not a form, but a regular info dump.

I also moved the payment settings as a sub-route of payments, as i
believe this makes more sense than an additional user menu item.
2024-02-14 04:54:42 +01:00
jordi fita mas bd84df8169 Add down payment
Customer wants to require a down payment of 30 % for bookings made
one week or more before the actual date, and to make the full payment
otherwise.

This would require yet another relation to keep these values. Fuck it;
i added them to the function, as they are very unlikely to change.

That forced me to change the test for draft_payment to use relative
dates, otherwise there is no way i can have stable results in the
future.
2024-02-13 23:45:25 +01:00
jordi fita mas af31daba8a Add positive_integer and nonnegative_integer domains
This is easier to read and requires less unit tests, but i only used
them in the new relations and fields for HEAD, because i do not see any
point on creating migrations just for that.
2024-02-13 22:12:30 +01:00