camper/deploy/booking__payment_fields.sql
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

49 lines
1.8 KiB
PL/PgSQL

-- Deploy camper:booking__payment_fields to pg
-- requires: booking
-- requires: positive_integer
-- requires: nonnegative_integer
begin;
set search_path to camper, public;
alter table booking
add column address text
, add column postal_code text
, add column city text
, add column country_code country_code references country
, add column email email
, add column phone packed_phone_number
, add lang_tag text not null default 'und' references language
, add zone_preferences text not null default ''
, add subtotal_nights nonnegative_integer not null default 0
, add number_adults positive_integer not null default 1
, add subtotal_adults nonnegative_integer not null default 0
, add number_teenagers nonnegative_integer not null default 0
, add subtotal_teenagers nonnegative_integer not null default 0
, add number_children nonnegative_integer not null default 0
, add subtotal_children nonnegative_integer not null default 0
, alter column number_dogs type nonnegative_integer
, add subtotal_dogs nonnegative_integer not null default 0
, add subtotal_tourist_tax nonnegative_integer not null default 0
, add total nonnegative_integer not null default 0
, add currency_code currency_code not null default 'EUR' references currency
;
alter table booking
alter column zone_preferences drop default
, alter column subtotal_nights drop default
, alter column number_adults drop default
, alter column subtotal_adults drop default
, alter column number_teenagers drop default
, alter column subtotal_teenagers drop default
, alter column number_children drop default
, alter column subtotal_children drop default
, alter column subtotal_dogs drop default
, alter column subtotal_tourist_tax drop default
, alter column total drop default
, alter column currency_code drop default
;
commit;