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.
This commit is contained in:
parent
d8524c347e
commit
5b89c97b00
|
@ -0,0 +1,12 @@
|
|||
-- Deploy camper:campsite_type__operating_dates to pg
|
||||
-- requires: campsite_type
|
||||
|
||||
begin;
|
||||
|
||||
set search_path to camper, public;
|
||||
|
||||
alter table campsite_type
|
||||
add column operating_dates daterange not null default 'empty'
|
||||
;
|
||||
|
||||
commit;
|
|
@ -245,14 +245,14 @@ func NewDateFields(ctx context.Context, conn *database.Conn, campsiteType string
|
|||
row := conn.QueryRow(ctx, `
|
||||
select lower(bookable_nights),
|
||||
upper(bookable_nights) - 1,
|
||||
greatest(min(lower(season_range)), current_timestamp::date),
|
||||
max(upper(season_range))
|
||||
greatest(min(lower(season_range)), lower(operating_dates), current_timestamp::date),
|
||||
least(max(upper(season_range)), upper(operating_dates))
|
||||
from campsite_type
|
||||
join campsite_type_cost using (campsite_type_id)
|
||||
join season_calendar using (season_id)
|
||||
where campsite_type.slug = $1
|
||||
and season_range >> daterange(date_trunc('year', current_timestamp)::date, date_trunc('year', current_timestamp)::date + 1)
|
||||
group by bookable_nights;
|
||||
group by bookable_nights, operating_dates
|
||||
`, campsiteType)
|
||||
f := &DateFields{
|
||||
ArrivalDate: &bookingDateInput{
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
-- Revert camper:campsite_type__operating_dates from pg
|
||||
|
||||
begin;
|
||||
|
||||
alter table camper.campsite_type
|
||||
drop column if exists operating_dates
|
||||
;
|
||||
|
||||
commit;
|
|
@ -333,3 +333,4 @@ booking_invoice [roles schema_camper booking invoice] 2024-04-28T19:45:05Z jordi
|
|||
marshal_payment [roles schema_camper payment payment_customer payment_option payment__acsi_card payment_customer__-acsi_card] 2024-04-29T17:11:59Z jordi fita mas <jordi@tandem.blog> # Add function to marshal a payment
|
||||
unmarshal_booking [roles schema_camper booking booking_option extension_pg_libphonenumber] 2024-04-29T17:20:38Z jordi fita mas <jordi@tandem.blog> # Add function to unmarshal a booking
|
||||
cancel_booking [roles schema_camper booking booking_campsite] 2024-05-03T14:27:31Z jordi fita mas <jordi@tandem.blog> # Add function to cancel a booking
|
||||
campsite_type__operating_dates [campsite_type] 2024-07-15T21:27:19Z jordi fita mas <jordi@tandem.blog> # Add operating_dates field to campsite_type
|
||||
|
|
|
@ -5,7 +5,7 @@ reset client_min_messages;
|
|||
|
||||
begin;
|
||||
|
||||
select plan(108);
|
||||
select plan(113);
|
||||
|
||||
set search_path to camper, public;
|
||||
|
||||
|
@ -118,6 +118,12 @@ select col_not_null('campsite_type', 'active');
|
|||
select col_has_default('campsite_type', 'active');
|
||||
select col_default_is('campsite_type', 'active', 'true');
|
||||
|
||||
select has_column('campsite_type', 'operating_dates');
|
||||
select col_type_is('campsite_type', 'operating_dates', 'daterange');
|
||||
select col_not_null('campsite_type', 'operating_dates');
|
||||
select col_has_default('campsite_type', 'operating_dates');
|
||||
select col_default_is('campsite_type', 'operating_dates', 'empty');
|
||||
|
||||
select has_column('campsite_type', 'position');
|
||||
select col_type_is('campsite_type', 'position', 'integer');
|
||||
select col_not_null('campsite_type', 'position');
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
-- Verify camper:campsite_type__operating_dates on pg
|
||||
|
||||
begin;
|
||||
|
||||
select operating_dates
|
||||
from camper.campsite_type
|
||||
where false
|
||||
;
|
||||
|
||||
rollback;
|
Loading…
Reference in New Issue