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.
This commit is contained in:
jordi fita mas 2024-03-14 22:08:01 +01:00
parent cc1b334639
commit 0412ffca05
52 changed files with 1648 additions and 748 deletions

View File

@ -10,8 +10,8 @@ values ('demo@camper', 'Demo User', 'demo', 'ca')
;
alter table company alter column company_id restart with 52;
insert into company (slug, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code, rtc_number, tourist_tax, currency_code, default_lang_tag, legal_disclaimer)
values ('09184122-b276-4be2-9553-e4bbcbafe40d', 'El pont de Llierca, S.L.', 'ESB17377656', 'Càmping Montagut', parse_packed_phone_number('661 673 057', 'ES'), 'info@campingmontagut.com', 'https://campingmontagut.com/', 'Ctra. de Sadernes, Km 2', 'Montagut i Oix', 'Girona', '17855', 'ES', 'KG-000133', 60, 'EUR', 'ca', 'El pont de Llierca, S.L. és responsable del tractament de les seves dades dacord amb el RGPD i la LOPDGDD, i les tracta per a mantenir una relació mercantil/comercial amb vostè. Les conservarà mentre es mantingui aquesta relació i no es comunicaran a tercers. Pot exercir els drets daccés, rectificació, portabilitat, supressió, limitació i oposició a El pont de Llierca, S.L., amb domicili Ctra. de Sadernes, Km 2, 17855 Montagut i Oix o enviant un correu electrònic a info@campingmontagut.com. Per a qualsevol reclamació pot acudir a agpd.es. Per a més informació pot consultar la nostra política de privacitat a campingmontagut.com.');
insert into company (slug, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code, rtc_number, tourist_tax, tourist_tax_max_days, currency_code, default_lang_tag, legal_disclaimer)
values ('09184122-b276-4be2-9553-e4bbcbafe40d', 'El pont de Llierca, S.L.', 'ESB17377656', 'Càmping Montagut', parse_packed_phone_number('661 673 057', 'ES'), 'info@campingmontagut.com', 'https://campingmontagut.com/', 'Ctra. de Sadernes, Km 2', 'Montagut i Oix', 'Girona', '17855', 'ES', 'KG-000133', 60, 7, 'EUR', 'ca', 'El pont de Llierca, S.L. és responsable del tractament de les seves dades dacord amb el RGPD i la LOPDGDD, i les tracta per a mantenir una relació mercantil/comercial amb vostè. Les conservarà mentre es mantingui aquesta relació i no es comunicaran a tercers. Pot exercir els drets daccés, rectificació, portabilitat, supressió, limitació i oposició a El pont de Llierca, S.L., amb domicili Ctra. de Sadernes, Km 2, 17855 Montagut i Oix o enviant un correu electrònic a info@campingmontagut.com. Per a qualsevol reclamació pot acudir a agpd.es. Per a més informació pot consultar la nostra política de privacitat a campingmontagut.com.');
insert into company_host (company_id, host)
values (52, 'localhost:8080')
@ -1413,6 +1413,22 @@ values (72, 77, 'en', 'Legend')
, (76, 103, 'es', 'Leyenda')
;
insert into acsi (campsite_type_id, number_adults, number_teenagers, number_children, number_dogs, cost_per_night)
values (72, 2, 0, 0, 1, 2300);
insert into acsi_calendar (campsite_type_id, acsi_range)
values (72, daterange(make_date(extract(year from current_date)::int, 2, 4), make_date(extract(year from current_date)::int, 6, 20)))
, (72, daterange(make_date(extract(year from current_date)::int, 9, 1), make_date(extract(year from current_date)::int, 10, 13)))
;
insert into acsi_option (campsite_type_id, campsite_type_option_id, units)
values (72, 102, 1)
, (72, 103, 1)
, (72, 104, 1)
, (72, 107, 1)
, (72, 109, 1)
;
alter table surroundings_highlight alter column surroundings_highlight_id restart with 112;
select add_surroundings_highlight(52, 62, 'El Pont del Llierca', '<p>Pont destil romànic i bany natural a 400 m del càmping.</p>');

23
deploy/acsi.sql Normal file
View File

@ -0,0 +1,23 @@
-- Deploy camper:acsi to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite_type
begin;
set search_path to camper, public;
create table acsi (
campsite_type_id integer primary key references campsite_type,
number_adults positive_integer not null,
number_teenagers nonnegative_integer not null,
number_children nonnegative_integer not null,
number_dogs nonnegative_integer not null,
cost_per_night nonnegative_integer not null
);
grant select on table acsi to guest;
grant select on table acsi to employee;
grant select, insert, update, delete on table acsi to admin;
commit;

21
deploy/acsi_calendar.sql Normal file
View File

@ -0,0 +1,21 @@
-- Deploy camper:acsi_calendar to pg
-- requires: roles
-- requires: schema_camper
-- requires: acsi
begin;
set search_path to camper, public;
create table acsi_calendar (
campsite_type_id integer not null references acsi,
acsi_range daterange not null,
primary key (campsite_type_id, acsi_range),
constraint disallow_acsi_overlap exclude using gist (campsite_type_id with =, acsi_range with &&)
);
grant select on table acsi_calendar to guest;
grant select on table acsi_calendar to employee;
grant select, insert, update, delete on table acsi_calendar to admin;
commit;

22
deploy/acsi_option.sql Normal file
View File

@ -0,0 +1,22 @@
-- Deploy camper:acsi_option to pg
-- requires: roles
-- requires: schema_camper
-- requires: acsi
-- requires: campsite_type_option
begin;
set search_path to camper, public;
create table acsi_option (
campsite_type_id integer not null references acsi,
campsite_type_option_id integer not null references campsite_type_option,
units positive_integer not null,
primary key (campsite_type_id, campsite_type_option_id)
);
grant select on table acsi_option to guest;
grant select on table acsi_option to employee;
grant select, insert, update, delete on table acsi_option to admin;
commit;

View File

@ -11,12 +11,17 @@
-- requires: payment
-- requires: payment_option
-- requires: company__tourist_tax_max_days
-- requires: acsi
-- requires: acsi_calendar
-- requires: acsi_options
begin;
set search_path to camper, public;
create or replace function draft_payment(payment_slug uuid, arrival_date date, departure_date date, campsite_type_slug uuid, num_adults integer, num_teenagers integer, num_children integer, num_dogs integer, zone_preferences text, options option_units[]) returns payment as
drop function if exists draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]);
create or replace function draft_payment(payment_slug uuid, arrival_date date, departure_date date, campsite_type_slug uuid, num_adults integer, num_teenagers integer, num_children integer, num_dogs integer, zone_preferences text, acsi_card boolean, options option_units[]) returns payment as
$$
declare
p payment;
@ -44,26 +49,28 @@ begin
, currency_code
, down_payment_percent
, zone_preferences
, acsi_card
)
select coalesce(payment_slug, gen_random_uuid())
, company_id
, campsite_type_id
, campsite_type.campsite_type_id
, arrival_date
, departure_date
, sum(cost.cost_per_night * ceiling((num_adults::numeric + num_teenagers::numeric + num_children::numeric) / max_campers::numeric)::integer)::integer
, sum(coalesce(acsi.cost_per_night, 0) + cost.cost_per_night * (ceiling((num_adults::numeric + num_teenagers::numeric + num_children::numeric) / max_campers::numeric)::integer - case when acsi.cost_per_night is null then 0 else 1 end))::integer
, num_adults
, sum(cost_per_adult * num_adults)::integer
, sum(cost_per_adult * greatest(0, num_adults - coalesce(acsi.number_adults, 0)))::integer
, num_teenagers
, sum(cost_per_teenager * num_teenagers)::integer
, sum(cost_per_teenager * greatest(0, num_teenagers - coalesce(acsi.number_teenagers, 0)))::integer
, num_children
, sum(cost_per_child * num_children)::integer
, sum(cost_per_child * greatest(0, num_children - coalesce(acsi.number_children, 0)))::integer
, num_dogs
, sum(case when num_dogs > 0 then coalesce(pet.cost_per_night, 0) else 0 end)::integer
, sum(case when (num_dogs - coalesce(acsi.number_dogs, 0)) > 0 then coalesce(pet.cost_per_night, 0) else 0 end)::integer
, sum(case when day_num <= tourist_tax_max_days then tourist_tax * num_adults else 0 end)::integer
, 0
, currency_code
, case when arrival_date - current_date >= 7 then 0.3 else 1.0 end
, coalesce(zone_preferences, '')
, acsi_card
from generate_series(arrival_date, departure_date - 1, interval '1 day') with ordinality as date(day, day_num)
left join season_calendar on season_range @> date.day::date
left join season using (season_id)
@ -71,9 +78,13 @@ begin
left join campsite_type_pet_cost as pet using (campsite_type_id)
left join campsite_type_cost as cost using (campsite_type_id, season_id)
left join company using (company_id)
left join (acsi join acsi_calendar using (campsite_type_id)) as acsi
on acsi_card
and acsi.campsite_type_id = campsite_type.campsite_type_id
and date.day::date <@ acsi_range
where campsite_type.slug = campsite_type_slug
group by company_id
, campsite_type_id
, campsite_type.campsite_type_id
, currency_code
on conflict (slug) do update
set company_id = excluded.company_id
@ -94,6 +105,7 @@ begin
, currency_code = excluded.currency_code
, down_payment_percent = excluded.down_payment_percent
, zone_preferences = excluded.zone_preferences
, acsi_card = excluded.acsi_card
, updated_at = current_timestamp
returning *
into p
@ -115,16 +127,18 @@ begin
, subtotal
)
select p.payment_id
, campsite_type_option_id
, units
, case when per_night then sum(cost * units)::integer else max(cost * units)::integer end
, campsite_type_option.campsite_type_option_id
, option.units
, case when per_night then sum(cost * greatest(0, option.units - coalesce(acsi_option.units, 0)))::integer else max(cost * greatest(0, option.units - coalesce(acsi_option.units, 0)))::integer end
from generate_series(arrival_date, departure_date - 1, interval '1 day') as date(day)
join season_calendar on season_range @> date.day::date
join campsite_type_option_cost using (season_id)
join campsite_type_option using (campsite_type_option_id)
join unnest(options) as option(campsite_type_option_id, units) using (campsite_type_option_id)
group by campsite_type_option_id
, units
left join acsi_calendar on acsi_card and day::date <@ acsi_range
left join acsi_option on acsi_option.campsite_type_id = acsi_calendar.campsite_type_id and acsi_option.campsite_type_option_id = campsite_type_option.campsite_type_option_id
group by campsite_type_option.campsite_type_option_id
, option.units
, per_night
on conflict (payment_id, campsite_type_option_id) do update
set units = excluded.units
@ -161,9 +175,9 @@ $$
language plpgsql
;
revoke execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) from public;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to guest;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to employee;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to admin;
revoke execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, boolean, option_units[]) from public;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, boolean, option_units[]) to guest;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, boolean, option_units[]) to employee;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, boolean, option_units[]) to admin;
commit;

169
deploy/draft_payment@v5.sql Normal file
View File

@ -0,0 +1,169 @@
-- Deploy camper:draft_payment to pg
-- requires: roles
-- requires: schema_camper
-- requires: season_calendar
-- requires: season
-- requires: campsite_type
-- requires: campsite_type_pet_cost
-- requires: campsite_type_cost
-- requires: campsite_type_option_cost
-- requires: campsite_type_option
-- requires: payment
-- requires: payment_option
-- requires: company__tourist_tax_max_days
begin;
set search_path to camper, public;
create or replace function draft_payment(payment_slug uuid, arrival_date date, departure_date date, campsite_type_slug uuid, num_adults integer, num_teenagers integer, num_children integer, num_dogs integer, zone_preferences text, options option_units[]) returns payment as
$$
declare
p payment;
begin
if exists(select 1 from payment where slug = payment_slug and payment_status <> 'draft') then
payment_slug = null;
end if;
insert into payment (
slug
, company_id
, campsite_type_id
, arrival_date
, departure_date
, subtotal_nights
, number_adults
, subtotal_adults
, number_teenagers
, subtotal_teenagers
, number_children
, subtotal_children
, number_dogs
, subtotal_dogs
, subtotal_tourist_tax
, total
, currency_code
, down_payment_percent
, zone_preferences
)
select coalesce(payment_slug, gen_random_uuid())
, company_id
, campsite_type_id
, arrival_date
, departure_date
, sum(cost.cost_per_night * ceiling((num_adults::numeric + num_teenagers::numeric + num_children::numeric) / max_campers::numeric)::integer)::integer
, num_adults
, sum(cost_per_adult * num_adults)::integer
, num_teenagers
, sum(cost_per_teenager * num_teenagers)::integer
, num_children
, sum(cost_per_child * num_children)::integer
, num_dogs
, sum(case when num_dogs > 0 then coalesce(pet.cost_per_night, 0) else 0 end)::integer
, sum(case when day_num <= tourist_tax_max_days then tourist_tax * num_adults else 0 end)::integer
, 0
, currency_code
, case when arrival_date - current_date >= 7 then 0.3 else 1.0 end
, coalesce(zone_preferences, '')
from generate_series(arrival_date, departure_date - 1, interval '1 day') with ordinality as date(day, day_num)
left join season_calendar on season_range @> date.day::date
left join season using (season_id)
left join campsite_type using (company_id)
left join campsite_type_pet_cost as pet using (campsite_type_id)
left join campsite_type_cost as cost using (campsite_type_id, season_id)
left join company using (company_id)
where campsite_type.slug = campsite_type_slug
group by company_id
, campsite_type_id
, currency_code
on conflict (slug) do update
set company_id = excluded.company_id
, campsite_type_id = excluded.campsite_type_id
, arrival_date = excluded.arrival_date
, departure_date = excluded.departure_date
, subtotal_nights = excluded.subtotal_nights
, number_adults = excluded.number_adults
, subtotal_adults = excluded.subtotal_adults
, number_teenagers = excluded.number_teenagers
, subtotal_teenagers = excluded.subtotal_teenagers
, number_children = excluded.number_children
, subtotal_children = excluded.subtotal_children
, number_dogs = excluded.number_dogs
, subtotal_dogs = excluded.subtotal_dogs
, subtotal_tourist_tax = excluded.subtotal_tourist_tax
, total = excluded.total
, currency_code = excluded.currency_code
, down_payment_percent = excluded.down_payment_percent
, zone_preferences = excluded.zone_preferences
, updated_at = current_timestamp
returning *
into p
;
if array_length(coalesce(options, array[]::option_units[]), 1) > 0 then
delete
from payment_option
where payment_id = p.payment_id
and campsite_type_option_id not in (
select campsite_type_option_id
from unnest(options) as option(campsite_type_option_id, units)
);
insert into payment_option (
payment_id
, campsite_type_option_id
, units
, subtotal
)
select p.payment_id
, campsite_type_option_id
, units
, case when per_night then sum(cost * units)::integer else max(cost * units)::integer end
from generate_series(arrival_date, departure_date - 1, interval '1 day') as date(day)
join season_calendar on season_range @> date.day::date
join campsite_type_option_cost using (season_id)
join campsite_type_option using (campsite_type_option_id)
join unnest(options) as option(campsite_type_option_id, units) using (campsite_type_option_id)
group by campsite_type_option_id
, units
, per_night
on conflict (payment_id, campsite_type_option_id) do update
set units = excluded.units
, subtotal = excluded.subtotal
;
with option as (
select sum(subtotal)::integer as subtotal
from payment_option
where payment_id = p.payment_id
)
update payment
set total = subtotal_nights + subtotal_adults + subtotal_teenagers + subtotal_children + subtotal_dogs + subtotal_tourist_tax + coalesce(option.subtotal, 0)
from option
where payment_id = p.payment_id
returning total into p.total
;
else
delete
from payment_option
where payment_id = p.payment_id;
update payment
set total = subtotal_nights + subtotal_adults + subtotal_teenagers + subtotal_children + subtotal_dogs + subtotal_tourist_tax
where payment_id = p.payment_id
returning total into p.total
;
end if;
return p;
end;
$$
language plpgsql
;
revoke execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) from public;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to guest;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to employee;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to admin;
commit;

View File

@ -0,0 +1,22 @@
-- Deploy camper:payment__acsi_card to pg
-- requires: payment
begin;
set search_path to camper, public;
alter table payment
add column acsi_card boolean not null default false
;
update payment
set acsi_card = payment_customer.acsi_card
from payment_customer
where payment_customer.payment_id = payment.payment_id
;
alter table payment
alter column acsi_card drop default
;
commit;

View File

@ -0,0 +1,10 @@
-- Deploy camper:payment_customer__-acsi_card to pg
-- requires: payment__acsi_card
begin;
alter table camper.payment_customer
drop column if exists acsi_card
;
commit;

View File

@ -6,12 +6,16 @@
-- requires: country_code
-- requires: email
-- requires: extension_pg_libphonenumber
-- requires: payment__acsi_card
-- requires: payment_customer__-acsi_card
begin;
set search_path to camper, public;
create or replace function ready_payment(payment_slug uuid, customer_name text, customer_address text, customer_post_code text, customer_city text, customer_country_code country_code, customer_email email, customer_phone text, customer_lang_tag text, customer_acsi_card boolean) returns integer as
drop function if exists ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean);
create or replace function ready_payment(payment_slug uuid, customer_name text, customer_address text, customer_post_code text, customer_city text, customer_country_code country_code, customer_email email, customer_phone text, customer_lang_tag text) returns integer as
$$
declare
pid integer;
@ -28,8 +32,8 @@ begin
raise check_violation using message = 'insert or update on table "payment" violates check constraint "payment_is_draft"';
end if;
insert into payment_customer (payment_id, full_name, address, postal_code, city, country_code, email, phone, acsi_card, lang_tag)
values (pid, customer_name, customer_address, customer_post_code, customer_city, customer_country_code, customer_email, parse_packed_phone_number(customer_phone, customer_country_code), customer_acsi_card, customer_lang_tag)
insert into payment_customer (payment_id, full_name, address, postal_code, city, country_code, email, phone, lang_tag)
values (pid, customer_name, customer_address, customer_post_code, customer_city, customer_country_code, customer_email, parse_packed_phone_number(customer_phone, customer_country_code), customer_lang_tag)
on conflict (payment_id) do update
set full_name = excluded.full_name
, address = excluded.address
@ -38,7 +42,6 @@ begin
, country_code = excluded.country_code
, email = excluded.email
, phone = excluded.phone
, acsi_card = excluded.acsi_card
, lang_tag = excluded.lang_tag
;
@ -48,9 +51,9 @@ $$
language plpgsql
;
revoke execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) from public;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to guest;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to employee;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to admin;
revoke execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text) from public;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text) to guest;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text) to employee;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text) to admin;
commit;

View File

@ -0,0 +1,56 @@
-- Deploy camper:ready_payment to pg
-- requires: roles
-- requires: schema_camper
-- requires: payment
-- requires: payment_customer
-- requires: country_code
-- requires: email
-- requires: extension_pg_libphonenumber
begin;
set search_path to camper, public;
create or replace function ready_payment(payment_slug uuid, customer_name text, customer_address text, customer_post_code text, customer_city text, customer_country_code country_code, customer_email email, customer_phone text, customer_lang_tag text, customer_acsi_card boolean) returns integer as
$$
declare
pid integer;
begin
update payment
set payment_status = 'pending'
, updated_at = current_timestamp
where slug = payment_slug
and payment_status = 'draft'
returning payment_id into pid
;
if pid is null then
raise check_violation using message = 'insert or update on table "payment" violates check constraint "payment_is_draft"';
end if;
insert into payment_customer (payment_id, full_name, address, postal_code, city, country_code, email, phone, acsi_card, lang_tag)
values (pid, customer_name, customer_address, customer_post_code, customer_city, customer_country_code, customer_email, parse_packed_phone_number(customer_phone, customer_country_code), customer_acsi_card, customer_lang_tag)
on conflict (payment_id) do update
set full_name = excluded.full_name
, address = excluded.address
, postal_code = excluded.postal_code
, city = excluded.city
, country_code = excluded.country_code
, email = excluded.email
, phone = excluded.phone
, acsi_card = excluded.acsi_card
, lang_tag = excluded.lang_tag
;
return pid;
end;
$$
language plpgsql
;
revoke execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) from public;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to guest;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to employee;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to admin;
commit;

View File

@ -66,6 +66,11 @@ func newBookingCart(ctx context.Context, conn *database.Conn, f *bookingForm, ca
zonePreferences = f.Options.ZonePreferences.Val
}
var ACSICard bool
if f.Guests.ACSICard != nil {
ACSICard = f.Guests.ACSICard.Checked
}
optionMap := make(map[int]*campsiteTypeOption)
var typeOptions []*campsiteTypeOption
if f.Options != nil {
@ -97,7 +102,7 @@ func newBookingCart(ctx context.Context, conn *database.Conn, f *bookingForm, ca
, to_price(total, decimal_digits)
, to_price(payment.down_payment, decimal_digits)
, (payment.down_payment_percent * 100)::int
from draft_payment($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) as payment
from draft_payment($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) as payment
join currency using (currency_code)
`,
database.ZeroNullUUID(f.PaymentSlug.Val),
@ -109,6 +114,7 @@ func newBookingCart(ctx context.Context, conn *database.Conn, f *bookingForm, ca
numChildren,
numDogs,
zonePreferences,
ACSICard,
database.OptionUnitsArray(optionUnits),
)
var paymentID int

View File

@ -43,7 +43,6 @@ func requestPayment(w http.ResponseWriter, r *http.Request, user *auth.User, com
f.Customer.Email.Val,
f.Customer.Phone.Val,
user.Locale.Language,
f.Customer.ACSICard.Checked,
)
if err != nil {
panic(err)

View File

@ -119,6 +119,7 @@ type bookingGuestFields struct {
NumberTeenagers *form.Input
NumberChildren *form.Input
NumberDogs *form.Input
ACSICard *form.Checkbox
Error error
}
@ -144,7 +145,6 @@ type bookingCustomerFields struct {
Country *form.Select
Email *form.Input
Phone *form.Input
ACSICard *form.Checkbox
Agreement *form.Checkbox
}
@ -183,7 +183,7 @@ func newBookingForm(r *http.Request, company *auth.Company, conn *database.Conn,
return f, nil
}
f.Guests, err = newBookingGuestFields(r.Context(), conn, campsiteType)
f.Guests, err = newBookingGuestFields(r.Context(), conn, campsiteType, f.Dates.ArrivalDate.Val, f.Dates.DepartureDate.Val)
if err != nil {
return nil, err
}
@ -317,7 +317,7 @@ func (f *DateFields) Valid(v *form.Validator, l *locale.Locale) {
}
}
func newBookingGuestFields(ctx context.Context, conn *database.Conn, campsiteType string) (*bookingGuestFields, error) {
func newBookingGuestFields(ctx context.Context, conn *database.Conn, campsiteType string, arrivalDate string, departureDate string) (*bookingGuestFields, error) {
f := &bookingGuestFields{
NumberAdults: &form.Input{Name: "number_adults"},
NumberTeenagers: &form.Input{Name: "number_teenagers"},
@ -327,17 +327,26 @@ func newBookingGuestFields(ctx context.Context, conn *database.Conn, campsiteTyp
select max_campers
, overflow_allowed
, pet.cost_per_night is not null as dogs_allowed
, exists (
select 1 from acsi_calendar
where acsi_calendar.campsite_type_id = campsite_type.campsite_type_id
and acsi_range && daterange($2::date, $3::date)
) as acsi_allowed
from campsite_type
left join campsite_type_pet_cost as pet using (campsite_type_id)
where slug = $1
`, campsiteType)
`, campsiteType, arrivalDate, departureDate)
var dogsAllowed bool
if err := row.Scan(&f.MaxGuests, &f.OverflowAllowed, &dogsAllowed); err != nil {
var ACSIAllowed bool
if err := row.Scan(&f.MaxGuests, &f.OverflowAllowed, &dogsAllowed, &ACSIAllowed); err != nil {
return nil, err
}
if dogsAllowed {
f.NumberDogs = &form.Input{Name: "number_dogs"}
}
if ACSIAllowed {
f.ACSICard = &form.Checkbox{Name: "acsi_card"}
}
return f, nil
}
@ -349,6 +358,9 @@ func (f *bookingGuestFields) FillValues(r *http.Request, l *locale.Locale) {
if f.NumberDogs != nil {
fillNumericField(f.NumberDogs, r, 0)
}
if f.ACSICard != nil {
f.ACSICard.FillValue(r)
}
if numGuests > f.MaxGuests {
if f.OverflowAllowed {
f.Overflow = true
@ -495,9 +507,6 @@ func newBookingCustomerFields(ctx context.Context, conn *database.Conn, l *local
Phone: &form.Input{
Name: "phone",
},
ACSICard: &form.Checkbox{
Name: "acsi_card",
},
Agreement: &form.Checkbox{
Name: "agreement",
},
@ -512,7 +521,6 @@ func (f *bookingCustomerFields) FillValues(r *http.Request) {
f.Country.FillValue(r)
f.Email.FillValue(r)
f.Phone.FillValue(r)
f.ACSICard.FillValue(r)
f.Agreement.FillValue(r)
}

View File

@ -348,6 +348,6 @@ func (tx *Tx) TranslateHome(ctx context.Context, companyID int, langTag language
return err
}
func (c *Conn) ReadyPayment(ctx context.Context, paymentSlug string, customerName string, customerAddress string, customerPostCode string, customerCity string, customerCountryCode string, customerEmail string, customerPhone string, customerLangTag language.Tag, acsiCard bool) (int, error) {
return c.GetInt(ctx, "select ready_payment($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", paymentSlug, customerName, customerAddress, customerPostCode, customerCity, customerCountryCode, customerEmail, customerPhone, customerLangTag, acsiCard)
func (c *Conn) ReadyPayment(ctx context.Context, paymentSlug string, customerName string, customerAddress string, customerPostCode string, customerCity string, customerCountryCode string, customerEmail string, customerPhone string, customerLangTag language.Tag) (int, error) {
return c.GetInt(ctx, "select ready_payment($1, $2, $3, $4, $5, $6, $7, $8, $9)", paymentSlug, customerName, customerAddress, customerPostCode, customerCity, customerCountryCode, customerEmail, customerPhone, customerLangTag)
}

View File

@ -178,6 +178,7 @@ type paymentDetails struct {
DownPaymentPercent int
DownPayment string
ZonePreferences string
ACSICard bool
Status string
StatusLabel string
CreatedAt time.Time
@ -200,7 +201,6 @@ type paymentCustomer struct {
Email string
Phone string
Language string
ACSICard bool
}
func fetchPaymentDetails(ctx context.Context, conn *database.Conn, slug string, locale *locale.Locale) (*paymentDetails, error) {
@ -220,6 +220,7 @@ func fetchPaymentDetails(ctx context.Context, conn *database.Conn, slug string,
, (down_payment_percent * 100)::integer
, to_price(payment.down_payment, decimal_digits)
, zone_preferences
, acsi_card
, payment.payment_status
, coalesce(payment_status_i18n.name, payment_status.name)
, created_at
@ -251,6 +252,7 @@ func fetchPaymentDetails(ctx context.Context, conn *database.Conn, slug string,
&details.DownPaymentPercent,
&details.DownPayment,
&details.ZonePreferences,
&details.ACSICard,
&details.Status,
&details.StatusLabel,
&details.CreatedAt,
@ -309,7 +311,6 @@ func fetchPaymentCustomer(ctx context.Context, conn *database.Conn, paymentID in
, email
, phone::text
, language.endonym
, acsi_card
from payment_customer
join country using (country_code)
left join country_i18n on country.country_code = country_i18n.country_code
@ -327,7 +328,6 @@ func fetchPaymentCustomer(ctx context.Context, conn *database.Conn, paymentID in
&customer.Email,
&customer.Phone,
&customer.Language,
&customer.ACSICard,
); err != nil {
return nil, err
}

386
po/ca.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-02-29 16:55+0100\n"
"POT-Creation-Date: 2024-03-14 22:05+0100\n"
"PO-Revision-Date: 2024-02-06 10:04+0100\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\n"
@ -127,160 +127,13 @@ msgid "Area preferences"
msgstr "Preferències dàrea"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:52
msgctxt "input"
msgid "Arrival date"
msgstr "Data darribada"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:56
msgctxt "input"
msgid "Departure date"
msgstr "Data de sortida"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/admin/payment/details.gohtml:60
msgctxt "cart"
msgid "Nights"
msgstr "Nits"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:64
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adults de 17 anys o més"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:68
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescents dentre 11 i 16 anys"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:72
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Nens dentre 2 i 10 anys"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:76
msgctxt "input"
msgid "Dogs"
msgstr "Gossos"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/admin/payment/details.gohtml:80 pkg/booking/cart.go:191
msgctxt "cart"
msgid "Tourist tax"
msgstr "Impost turístic"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/public/booking/fields.gohtml:242
msgctxt "cart"
msgid "Total"
msgstr "Total"
#: web/templates/mail/payment/details.gotxt:27
#: web/templates/public/booking/fields.gohtml:247
#: web/templates/admin/payment/details.gohtml:84
msgctxt "cart"
msgid "Down payment"
msgstr "A compte"
#: web/templates/mail/payment/details.gotxt:30
#: web/templates/admin/payment/details.gohtml:92
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
msgctxt "title"
msgid "Campsite Type Options"
msgstr "Opcions del tipus dallotjament"
#: web/templates/mail/payment/details.gotxt:38
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:106
msgctxt "title"
msgid "Customer Details"
msgstr "Detalls del client"
#: web/templates/mail/payment/details.gotxt:40
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:109
msgctxt "input"
msgid "Full name"
msgstr "Nom i cognoms"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:113
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
msgstr "Adreça"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Codi postal"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
msgstr "Població"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
msgstr "País"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
msgid "Email"
msgstr "Correu-e"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Telèfon"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
msgstr "Idioma"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
msgctxt "input"
msgid "ACSI card?"
msgstr "Targeta ACSI?"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:142
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -289,8 +142,8 @@ msgstr "Targeta ACSI?"
msgid "Yes"
msgstr "Sí"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:142
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -299,6 +152,153 @@ msgstr "Sí"
msgid "No"
msgstr "No"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:56
msgctxt "input"
msgid "Arrival date"
msgstr "Data darribada"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:60
msgctxt "input"
msgid "Departure date"
msgstr "Data de sortida"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/admin/payment/details.gohtml:64
msgctxt "cart"
msgid "Nights"
msgstr "Nits"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:68
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adults de 17 anys o més"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:72
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescents dentre 11 i 16 anys"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:76
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Nens dentre 2 i 10 anys"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:80
msgctxt "input"
msgid "Dogs"
msgstr "Gossos"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/admin/payment/details.gohtml:84 pkg/booking/cart.go:197
msgctxt "cart"
msgid "Tourist tax"
msgstr "Impost turístic"
#: web/templates/mail/payment/details.gotxt:27
#: web/templates/public/booking/fields.gohtml:225
msgctxt "cart"
msgid "Total"
msgstr "Total"
#: web/templates/mail/payment/details.gotxt:28
#: web/templates/public/booking/fields.gohtml:230
#: web/templates/admin/payment/details.gohtml:88
msgctxt "cart"
msgid "Down payment"
msgstr "A compte"
#: web/templates/mail/payment/details.gotxt:31
#: web/templates/admin/payment/details.gohtml:96
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
msgctxt "title"
msgid "Campsite Type Options"
msgstr "Opcions del tipus dallotjament"
#: web/templates/mail/payment/details.gotxt:39
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:110
msgctxt "title"
msgid "Customer Details"
msgstr "Detalls del client"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:113
msgctxt "input"
msgid "Full name"
msgstr "Nom i cognoms"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
msgstr "Adreça"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Codi postal"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
msgstr "Població"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
msgstr "País"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
msgid "Email"
msgstr "Correu-e"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Telèfon"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
msgstr "Idioma"
#: web/templates/mail/payment/details.gotxt:54
msgid "Best regards,"
msgstr "Salutacions,"
@ -490,7 +490,7 @@ msgid "Discover"
msgstr "Descobreix"
#: web/templates/public/campsite/type.gohtml:49
#: web/templates/public/booking/fields.gohtml:269
#: web/templates/public/booking/fields.gohtml:273
msgctxt "action"
msgid "Book"
msgstr "Reserva"
@ -917,25 +917,25 @@ msgstr "Població"
msgid "Choose a country"
msgstr "Esculli un país"
#: web/templates/public/booking/fields.gohtml:216
#: web/templates/public/booking/fields.gohtml:242
msgctxt "input"
msgid "ACSI card? (optional)"
msgstr "Targeta ACSI? (opcional)"
#: web/templates/public/booking/fields.gohtml:224
#: web/templates/public/booking/fields.gohtml:250
msgctxt "input"
msgid "I have read and I accept %[1]sthe reservation conditions%[2]s"
msgstr "He llegit i accepto %[1]sles condicions de reserves%[2]s"
#: web/templates/public/booking/fields.gohtml:261
#: web/templates/public/booking/fields.gohtml:258
msgid "By down paying the %d %% of the total, you are pre-booking your preferences. We will respond within 24 hours and this percentage will be charged if accepted."
msgstr "En tramitar el %d %% del total esteu realitzant la prereserva de les vostres preferències. Us respondrem en un termini de 24 hores i us cobrarem aquest percentatge en cas que sigui acceptada."
#: web/templates/public/booking/fields.gohtml:263
#: web/templates/public/booking/fields.gohtml:260
msgid "By paying the total you are pre-booking your preferences. We will respond within 24 hours and this amount will be charged if accepted."
msgstr "En tramitar el pagament del total esteu realitzant la prereserva de les vostres preferències. Us respondrem en un termini de 24 hores i us cobrarem aquesta quantitat en cas que sigui acceptada."
#: web/templates/public/booking/fields.gohtml:267
#: web/templates/public/booking/fields.gohtml:264
msgid "See <%s>our conditions</%s> for more information."
msgstr "Consulteu <%s>les nostres condicions</%s> per a més informació."
@ -2270,7 +2270,7 @@ msgctxt "order product name"
msgid "Campsite Booking"
msgstr "Reserva de càmping"
#: pkg/payment/public.go:372
#: pkg/payment/public.go:369
msgctxt "subject"
msgid "Booking payment successfully received"
msgstr "Rebut amb èxit el pagament de la reserva"
@ -2314,12 +2314,12 @@ msgid "Slide image must be an image media type."
msgstr "La imatge de la diapositiva ha de ser un mèdia de tipus imatge."
#: pkg/app/login.go:56 pkg/app/user.go:246 pkg/company/admin.go:224
#: pkg/booking/public.go:536
#: pkg/booking/public.go:544
msgid "Email can not be empty."
msgstr "No podeu deixar el correu-e en blanc."
#: pkg/app/login.go:57 pkg/app/user.go:247 pkg/company/admin.go:225
#: pkg/booking/public.go:537
#: pkg/booking/public.go:545
msgid "This email is not valid. It should be like name@domain.com."
msgstr "Aquest correu-e no és vàlid. Hauria de ser similar a nom@domini.com."
@ -2687,7 +2687,7 @@ msgstr "No podeu deixar ladreça de lenllaç en blanc."
msgid "This web address is not valid. It should be like https://domain.com/."
msgstr "Aquesta adreça web no és vàlida. Hauria de ser similar a https://domini.com/."
#: pkg/company/admin.go:207 pkg/booking/public.go:521
#: pkg/company/admin.go:207 pkg/booking/public.go:529
msgid "Selected country is not valid."
msgstr "El país escollit no és vàlid."
@ -2707,15 +2707,15 @@ msgstr "No podeu deixar el NIF en blanc."
msgid "This VAT number is not valid."
msgstr "Aquest NIF no és vàlid."
#: pkg/company/admin.go:219 pkg/booking/public.go:539
#: pkg/company/admin.go:219 pkg/booking/public.go:547
msgid "Phone can not be empty."
msgstr "No podeu deixar el telèfon en blanc."
#: pkg/company/admin.go:220 pkg/booking/public.go:540
#: pkg/company/admin.go:220 pkg/booking/public.go:548
msgid "This phone number is not valid."
msgstr "Aquest número de telèfon no és vàlid."
#: pkg/company/admin.go:230 pkg/booking/public.go:529
#: pkg/company/admin.go:230 pkg/booking/public.go:537
msgid "Address can not be empty."
msgstr "No podeu deixar ladreça en blanc."
@ -2727,11 +2727,11 @@ msgstr "No podeu deixar la població en blanc."
msgid "Province can not be empty."
msgstr "No podeu deixar la província en blanc."
#: pkg/company/admin.go:233 pkg/booking/public.go:531
#: pkg/company/admin.go:233 pkg/booking/public.go:539
msgid "Postcode can not be empty."
msgstr "No podeu deixar el codi postal en blanc."
#: pkg/company/admin.go:234 pkg/booking/public.go:532
#: pkg/company/admin.go:234 pkg/booking/public.go:540
msgid "This postcode is not valid."
msgstr "Aquest codi postal no és vàlid."
@ -2783,27 +2783,27 @@ msgstr "No podeu deixar el fitxer del mèdia en blanc."
msgid "Filename can not be empty."
msgstr "No podeu deixar el nom del fitxer en blanc."
#: pkg/booking/cart.go:153
#: pkg/booking/cart.go:159
msgctxt "cart"
msgid "Night"
msgstr "Nit"
#: pkg/booking/cart.go:154
#: pkg/booking/cart.go:160
msgctxt "cart"
msgid "Adult"
msgstr "Adult"
#: pkg/booking/cart.go:155
#: pkg/booking/cart.go:161
msgctxt "cart"
msgid "Teenager"
msgstr "Adolescent"
#: pkg/booking/cart.go:156
#: pkg/booking/cart.go:162
msgctxt "cart"
msgid "Child"
msgstr "Nen"
#: pkg/booking/cart.go:157
#: pkg/booking/cart.go:163
msgctxt "cart"
msgid "Dog"
msgstr "Gos"
@ -2849,92 +2849,92 @@ msgstr "La data de sortida ha de ser igual o posterior a %s."
msgid "Departure date must be %s or before."
msgstr "La data de sortida ha de ser anterior o igual a %s."
#: pkg/booking/public.go:356
#: pkg/booking/public.go:368
#, c-format
msgid "There can be at most %d guests in this accommodation."
msgstr "Hi poden haver com a màxim %d convidats a aquest allotjament."
#: pkg/booking/public.go:376
#: pkg/booking/public.go:388
msgid "Number of adults can not be empty"
msgstr "No podeu deixar el número dadults en blanc."
#: pkg/booking/public.go:377
#: pkg/booking/public.go:389
msgid "Number of adults must be an integer."
msgstr "El número dadults ha de ser enter."
#: pkg/booking/public.go:378
#: pkg/booking/public.go:390
msgid "There must be at least one adult."
msgstr "Hi ha dhaver com a mínim un adult."
#: pkg/booking/public.go:381
#: pkg/booking/public.go:393
msgid "Number of teenagers can not be empty"
msgstr "No podeu deixar el número dadolescents en blanc."
#: pkg/booking/public.go:382
#: pkg/booking/public.go:394
msgid "Number of teenagers must be an integer."
msgstr "El número dadolescents ha de ser enter."
#: pkg/booking/public.go:383
#: pkg/booking/public.go:395
msgid "Number of teenagers can not be negative."
msgstr "El número dadolescents no pot ser negatiu."
#: pkg/booking/public.go:386
#: pkg/booking/public.go:398
msgid "Number of children can not be empty"
msgstr "No podeu deixar el número de nens en blanc."
#: pkg/booking/public.go:387
#: pkg/booking/public.go:399
msgid "Number of children must be an integer."
msgstr "El número de nens ha de ser enter."
#: pkg/booking/public.go:388
#: pkg/booking/public.go:400
msgid "Number of children can not be negative."
msgstr "El número de nens no pot ser negatiu."
#: pkg/booking/public.go:391
#: pkg/booking/public.go:403
msgid "Number of dogs can not be empty"
msgstr "No podeu deixar el número de gossos en blanc."
#: pkg/booking/public.go:392
#: pkg/booking/public.go:404
msgid "Number of dogs must be an integer."
msgstr "El número de gossos ha de ser enter."
#: pkg/booking/public.go:393
#: pkg/booking/public.go:405
msgid "Number of dogs can not be negative."
msgstr "El número de gossos no pot ser negatiu."
#: pkg/booking/public.go:464
#: pkg/booking/public.go:476
#, c-format
msgid "%s can not be empty"
msgstr "No podeu deixar %s en blanc."
#: pkg/booking/public.go:465
#: pkg/booking/public.go:477
#, c-format
msgid "%s must be an integer."
msgstr "%s ha de ser un número enter."
#: pkg/booking/public.go:466
#: pkg/booking/public.go:478
#, c-format
msgid "%s must be %d or greater."
msgstr "El valor de %s ha de ser com a mínim %d."
#: pkg/booking/public.go:467
#: pkg/booking/public.go:479
#, c-format
msgid "%s must be at most %d."
msgstr "El valor de %s ha de ser com a màxim %d."
#: pkg/booking/public.go:525
#: pkg/booking/public.go:533
msgid "Full name can not be empty."
msgstr "No podeu deixar el nom i els cognoms en blanc."
#: pkg/booking/public.go:526
#: pkg/booking/public.go:534
msgid "Full name must have at least one letter."
msgstr "El nom i els cognoms han de tenir com a mínim una lletra."
#: pkg/booking/public.go:530
#: pkg/booking/public.go:538
msgid "Town or village can not be empty."
msgstr "No podeu deixar la població en blanc."
#: pkg/booking/public.go:545
#: pkg/booking/public.go:553
msgid "It is mandatory to agree to the reservation conditions."
msgstr "És obligatori acceptar les condicions de reserves."

386
po/es.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-02-29 16:55+0100\n"
"POT-Creation-Date: 2024-03-14 22:05+0100\n"
"PO-Revision-Date: 2024-02-06 10:04+0100\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\n"
@ -127,160 +127,13 @@ msgid "Area preferences"
msgstr "Preferencias de área"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:52
msgctxt "input"
msgid "Arrival date"
msgstr "Fecha de llegada"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:56
msgctxt "input"
msgid "Departure date"
msgstr "Fecha de salida"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/admin/payment/details.gohtml:60
msgctxt "cart"
msgid "Nights"
msgstr "Noches"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:64
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adultos de 17 años o más"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:68
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescentes de 11 a 16 años"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:72
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Niños de 2 a 10 años"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:76
msgctxt "input"
msgid "Dogs"
msgstr "Perros"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/admin/payment/details.gohtml:80 pkg/booking/cart.go:191
msgctxt "cart"
msgid "Tourist tax"
msgstr "Impuesto turístico"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/public/booking/fields.gohtml:242
msgctxt "cart"
msgid "Total"
msgstr "Total"
#: web/templates/mail/payment/details.gotxt:27
#: web/templates/public/booking/fields.gohtml:247
#: web/templates/admin/payment/details.gohtml:84
msgctxt "cart"
msgid "Down payment"
msgstr "A cuenta"
#: web/templates/mail/payment/details.gotxt:30
#: web/templates/admin/payment/details.gohtml:92
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
msgctxt "title"
msgid "Campsite Type Options"
msgstr "Opciones del tipo de alojamiento"
#: web/templates/mail/payment/details.gotxt:38
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:106
msgctxt "title"
msgid "Customer Details"
msgstr "Detalles del cliente"
#: web/templates/mail/payment/details.gotxt:40
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:109
msgctxt "input"
msgid "Full name"
msgstr "Nombre y apellidos"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:113
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
msgstr "Dirección"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Código postal"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
msgstr "Población"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
msgstr "País"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
msgid "Email"
msgstr "Correo-e"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Teléfono"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
msgstr "Idioma"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
msgctxt "input"
msgid "ACSI card?"
msgstr "¿Tarjeta ACSI?"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:142
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -289,8 +142,8 @@ msgstr "¿Tarjeta ACSI?"
msgid "Yes"
msgstr "Sí"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:142
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -299,6 +152,153 @@ msgstr "Sí"
msgid "No"
msgstr "No"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:56
msgctxt "input"
msgid "Arrival date"
msgstr "Fecha de llegada"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:60
msgctxt "input"
msgid "Departure date"
msgstr "Fecha de salida"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/admin/payment/details.gohtml:64
msgctxt "cart"
msgid "Nights"
msgstr "Noches"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:68
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adultos de 17 años o más"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:72
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescentes de 11 a 16 años"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:76
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Niños de 2 a 10 años"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:80
msgctxt "input"
msgid "Dogs"
msgstr "Perros"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/admin/payment/details.gohtml:84 pkg/booking/cart.go:197
msgctxt "cart"
msgid "Tourist tax"
msgstr "Impuesto turístico"
#: web/templates/mail/payment/details.gotxt:27
#: web/templates/public/booking/fields.gohtml:225
msgctxt "cart"
msgid "Total"
msgstr "Total"
#: web/templates/mail/payment/details.gotxt:28
#: web/templates/public/booking/fields.gohtml:230
#: web/templates/admin/payment/details.gohtml:88
msgctxt "cart"
msgid "Down payment"
msgstr "A cuenta"
#: web/templates/mail/payment/details.gotxt:31
#: web/templates/admin/payment/details.gohtml:96
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
msgctxt "title"
msgid "Campsite Type Options"
msgstr "Opciones del tipo de alojamiento"
#: web/templates/mail/payment/details.gotxt:39
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:110
msgctxt "title"
msgid "Customer Details"
msgstr "Detalles del cliente"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:113
msgctxt "input"
msgid "Full name"
msgstr "Nombre y apellidos"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
msgstr "Dirección"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Código postal"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
msgstr "Población"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
msgstr "País"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
msgid "Email"
msgstr "Correo-e"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Teléfono"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
msgstr "Idioma"
#: web/templates/mail/payment/details.gotxt:54
msgid "Best regards,"
msgstr "Saludos,"
@ -490,7 +490,7 @@ msgid "Discover"
msgstr "Descubre"
#: web/templates/public/campsite/type.gohtml:49
#: web/templates/public/booking/fields.gohtml:269
#: web/templates/public/booking/fields.gohtml:273
msgctxt "action"
msgid "Book"
msgstr "Reservar"
@ -917,25 +917,25 @@ msgstr "Población"
msgid "Choose a country"
msgstr "Escoja un país"
#: web/templates/public/booking/fields.gohtml:216
#: web/templates/public/booking/fields.gohtml:242
msgctxt "input"
msgid "ACSI card? (optional)"
msgstr "¿Tarjeta ACSI? (opcional)"
#: web/templates/public/booking/fields.gohtml:224
#: web/templates/public/booking/fields.gohtml:250
msgctxt "input"
msgid "I have read and I accept %[1]sthe reservation conditions%[2]s"
msgstr "He leído y acepto %[1]slas condiciones de reserva%[2]s"
#: web/templates/public/booking/fields.gohtml:261
#: web/templates/public/booking/fields.gohtml:258
msgid "By down paying the %d %% of the total, you are pre-booking your preferences. We will respond within 24 hours and this percentage will be charged if accepted."
msgstr "En tramitar el %d %% del total estáis realizando la prerreserva de vuestras preferencias. Os responderemos en un término de 24 horas y os cobraremos este porcentaje en caso que sea aceptada."
#: web/templates/public/booking/fields.gohtml:263
#: web/templates/public/booking/fields.gohtml:260
msgid "By paying the total you are pre-booking your preferences. We will respond within 24 hours and this amount will be charged if accepted."
msgstr "En tramitar el pago del total estáis realizando la prerreserva de vuestras preferencias. Os responderemos en un término de 24 horas y os cobraremos esta cantidad en caso que sea aceptada."
#: web/templates/public/booking/fields.gohtml:267
#: web/templates/public/booking/fields.gohtml:264
msgid "See <%s>our conditions</%s> for more information."
msgstr "Consultad <%s>nuestras condiciones</%s> para más información."
@ -2270,7 +2270,7 @@ msgctxt "order product name"
msgid "Campsite Booking"
msgstr "Reserva de camping"
#: pkg/payment/public.go:372
#: pkg/payment/public.go:369
msgctxt "subject"
msgid "Booking payment successfully received"
msgstr "Se ha recibido correctamente el pago de la reserva"
@ -2314,12 +2314,12 @@ msgid "Slide image must be an image media type."
msgstr "La imagen de la diapositiva tiene que ser un medio de tipo imagen."
#: pkg/app/login.go:56 pkg/app/user.go:246 pkg/company/admin.go:224
#: pkg/booking/public.go:536
#: pkg/booking/public.go:544
msgid "Email can not be empty."
msgstr "No podéis dejar el correo-e en blanco."
#: pkg/app/login.go:57 pkg/app/user.go:247 pkg/company/admin.go:225
#: pkg/booking/public.go:537
#: pkg/booking/public.go:545
msgid "This email is not valid. It should be like name@domain.com."
msgstr "Este correo-e no es válido. Tiene que ser parecido a nombre@dominio.com."
@ -2687,7 +2687,7 @@ msgstr "No podéis dejar la dirección del enlace en blanco."
msgid "This web address is not valid. It should be like https://domain.com/."
msgstr "Esta dirección web no es válida. Tiene que ser parecido a https://dominio.com/."
#: pkg/company/admin.go:207 pkg/booking/public.go:521
#: pkg/company/admin.go:207 pkg/booking/public.go:529
msgid "Selected country is not valid."
msgstr "El país escogido no es válido."
@ -2707,15 +2707,15 @@ msgstr "No podéis dejar el NIF en blanco."
msgid "This VAT number is not valid."
msgstr "Este NIF no es válido."
#: pkg/company/admin.go:219 pkg/booking/public.go:539
#: pkg/company/admin.go:219 pkg/booking/public.go:547
msgid "Phone can not be empty."
msgstr "No podéis dejar el teléfono en blanco."
#: pkg/company/admin.go:220 pkg/booking/public.go:540
#: pkg/company/admin.go:220 pkg/booking/public.go:548
msgid "This phone number is not valid."
msgstr "Este teléfono no es válido."
#: pkg/company/admin.go:230 pkg/booking/public.go:529
#: pkg/company/admin.go:230 pkg/booking/public.go:537
msgid "Address can not be empty."
msgstr "No podéis dejar la dirección en blanco."
@ -2727,11 +2727,11 @@ msgstr "No podéis dejar la población en blanco."
msgid "Province can not be empty."
msgstr "No podéis dejar la provincia en blanco."
#: pkg/company/admin.go:233 pkg/booking/public.go:531
#: pkg/company/admin.go:233 pkg/booking/public.go:539
msgid "Postcode can not be empty."
msgstr "No podéis dejar el código postal en blanco."
#: pkg/company/admin.go:234 pkg/booking/public.go:532
#: pkg/company/admin.go:234 pkg/booking/public.go:540
msgid "This postcode is not valid."
msgstr "Este código postal no es válido."
@ -2783,27 +2783,27 @@ msgstr "No podéis dejar el archivo del medio en blanco."
msgid "Filename can not be empty."
msgstr "No podéis dejar el nombre del archivo en blanco."
#: pkg/booking/cart.go:153
#: pkg/booking/cart.go:159
msgctxt "cart"
msgid "Night"
msgstr "Noche"
#: pkg/booking/cart.go:154
#: pkg/booking/cart.go:160
msgctxt "cart"
msgid "Adult"
msgstr "Adulto"
#: pkg/booking/cart.go:155
#: pkg/booking/cart.go:161
msgctxt "cart"
msgid "Teenager"
msgstr "Adolescente"
#: pkg/booking/cart.go:156
#: pkg/booking/cart.go:162
msgctxt "cart"
msgid "Child"
msgstr "Niño"
#: pkg/booking/cart.go:157
#: pkg/booking/cart.go:163
msgctxt "cart"
msgid "Dog"
msgstr "Perro"
@ -2849,92 +2849,92 @@ msgstr "La fecha de partida tiene que igual o posterior a %s."
msgid "Departure date must be %s or before."
msgstr "La fecha de partida tiene que ser anterior o igual a %s."
#: pkg/booking/public.go:356
#: pkg/booking/public.go:368
#, c-format
msgid "There can be at most %d guests in this accommodation."
msgstr "Solo puede haber como máximo %d invitados en este alojamiento."
#: pkg/booking/public.go:376
#: pkg/booking/public.go:388
msgid "Number of adults can not be empty"
msgstr "No podéis dejar el número de adultos blanco."
#: pkg/booking/public.go:377
#: pkg/booking/public.go:389
msgid "Number of adults must be an integer."
msgstr "El número de adultos tiene que ser entero."
#: pkg/booking/public.go:378
#: pkg/booking/public.go:390
msgid "There must be at least one adult."
msgstr "Tiene que haber como mínimo un adulto."
#: pkg/booking/public.go:381
#: pkg/booking/public.go:393
msgid "Number of teenagers can not be empty"
msgstr "No podéis dejar el número de adolescentes en blanco."
#: pkg/booking/public.go:382
#: pkg/booking/public.go:394
msgid "Number of teenagers must be an integer."
msgstr "El número de adolescentes tiene que ser entero."
#: pkg/booking/public.go:383
#: pkg/booking/public.go:395
msgid "Number of teenagers can not be negative."
msgstr "El número de adolescentes no puede ser negativo."
#: pkg/booking/public.go:386
#: pkg/booking/public.go:398
msgid "Number of children can not be empty"
msgstr "No podéis dejar el número de niños en blanco."
#: pkg/booking/public.go:387
#: pkg/booking/public.go:399
msgid "Number of children must be an integer."
msgstr "El número de niños tiene que ser entero."
#: pkg/booking/public.go:388
#: pkg/booking/public.go:400
msgid "Number of children can not be negative."
msgstr "El número de niños no puede ser negativo."
#: pkg/booking/public.go:391
#: pkg/booking/public.go:403
msgid "Number of dogs can not be empty"
msgstr "No podéis dejar el número de perros en blanco."
#: pkg/booking/public.go:392
#: pkg/booking/public.go:404
msgid "Number of dogs must be an integer."
msgstr "El número de perros tiene que ser entero."
#: pkg/booking/public.go:393
#: pkg/booking/public.go:405
msgid "Number of dogs can not be negative."
msgstr "El número de perros no puede ser negativo."
#: pkg/booking/public.go:464
#: pkg/booking/public.go:476
#, c-format
msgid "%s can not be empty"
msgstr "No podéis dejar %s en blanco."
#: pkg/booking/public.go:465
#: pkg/booking/public.go:477
#, c-format
msgid "%s must be an integer."
msgstr "%s tiene que ser un número entero."
#: pkg/booking/public.go:466
#: pkg/booking/public.go:478
#, c-format
msgid "%s must be %d or greater."
msgstr "%s tiene que ser como mínimo %d."
#: pkg/booking/public.go:467
#: pkg/booking/public.go:479
#, c-format
msgid "%s must be at most %d."
msgstr "%s tiene que ser como máximo %d"
#: pkg/booking/public.go:525
#: pkg/booking/public.go:533
msgid "Full name can not be empty."
msgstr "No podéis dejar el nombre y los apellidos en blanco."
#: pkg/booking/public.go:526
#: pkg/booking/public.go:534
msgid "Full name must have at least one letter."
msgstr "El nombre y los apellidos tienen que tener como mínimo una letra."
#: pkg/booking/public.go:530
#: pkg/booking/public.go:538
msgid "Town or village can not be empty."
msgstr "No podéis dejar la población en blanco."
#: pkg/booking/public.go:545
#: pkg/booking/public.go:553
msgid "It is mandatory to agree to the reservation conditions."
msgstr "Es obligatorio aceptar las condiciones de reserva."

386
po/fr.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-02-29 16:55+0100\n"
"POT-Creation-Date: 2024-03-14 22:05+0100\n"
"PO-Revision-Date: 2024-02-06 10:05+0100\n"
"Last-Translator: Oriol Carbonell <info@oriolcarbonell.cat>\n"
"Language-Team: French <traduc@traduc.org>\n"
@ -127,160 +127,13 @@ msgid "Area preferences"
msgstr "Préférences de zone"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:52
msgctxt "input"
msgid "Arrival date"
msgstr "Date darrivée"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:56
msgctxt "input"
msgid "Departure date"
msgstr "Date de depart"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/admin/payment/details.gohtml:60
msgctxt "cart"
msgid "Nights"
msgstr "Nuits"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:64
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adultes âgés 17 ans ou plus"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:68
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescents de 11 à 16 ans"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:72
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Enfants de 2 à 10 ans"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:76
msgctxt "input"
msgid "Dogs"
msgstr "Chiens"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/admin/payment/details.gohtml:80 pkg/booking/cart.go:191
msgctxt "cart"
msgid "Tourist tax"
msgstr "Taxe touristique"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/public/booking/fields.gohtml:242
msgctxt "cart"
msgid "Total"
msgstr "Totale"
#: web/templates/mail/payment/details.gotxt:27
#: web/templates/public/booking/fields.gohtml:247
#: web/templates/admin/payment/details.gohtml:84
msgctxt "cart"
msgid "Down payment"
msgstr "Acompte"
#: web/templates/mail/payment/details.gotxt:30
#: web/templates/admin/payment/details.gohtml:92
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
msgctxt "title"
msgid "Campsite Type Options"
msgstr "Options de type demplacement de camping"
#: web/templates/mail/payment/details.gotxt:38
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:106
msgctxt "title"
msgid "Customer Details"
msgstr "Détails du client"
#: web/templates/mail/payment/details.gotxt:40
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:109
msgctxt "input"
msgid "Full name"
msgstr "Nom et prénom"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:113
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
msgstr "Adresse"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Code postal"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
msgstr "Ville"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
msgstr "Pays"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
msgid "Email"
msgstr "E-mail"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Téléphone"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
msgstr "Langue"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
msgctxt "input"
msgid "ACSI card?"
msgstr "Carte ACSI ?"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:142
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -289,8 +142,8 @@ msgstr "Carte ACSI ?"
msgid "Yes"
msgstr "Oui"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:142
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -299,6 +152,153 @@ msgstr "Oui"
msgid "No"
msgstr "Non"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:56
msgctxt "input"
msgid "Arrival date"
msgstr "Date darrivée"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:60
msgctxt "input"
msgid "Departure date"
msgstr "Date de depart"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/admin/payment/details.gohtml:64
msgctxt "cart"
msgid "Nights"
msgstr "Nuits"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:68
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adultes âgés 17 ans ou plus"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:72
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescents de 11 à 16 ans"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:76
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Enfants de 2 à 10 ans"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:80
msgctxt "input"
msgid "Dogs"
msgstr "Chiens"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/admin/payment/details.gohtml:84 pkg/booking/cart.go:197
msgctxt "cart"
msgid "Tourist tax"
msgstr "Taxe touristique"
#: web/templates/mail/payment/details.gotxt:27
#: web/templates/public/booking/fields.gohtml:225
msgctxt "cart"
msgid "Total"
msgstr "Totale"
#: web/templates/mail/payment/details.gotxt:28
#: web/templates/public/booking/fields.gohtml:230
#: web/templates/admin/payment/details.gohtml:88
msgctxt "cart"
msgid "Down payment"
msgstr "Acompte"
#: web/templates/mail/payment/details.gotxt:31
#: web/templates/admin/payment/details.gohtml:96
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
msgctxt "title"
msgid "Campsite Type Options"
msgstr "Options de type demplacement de camping"
#: web/templates/mail/payment/details.gotxt:39
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:110
msgctxt "title"
msgid "Customer Details"
msgstr "Détails du client"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:113
msgctxt "input"
msgid "Full name"
msgstr "Nom et prénom"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
msgstr "Adresse"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Code postal"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
msgstr "Ville"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
msgstr "Pays"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
msgid "Email"
msgstr "E-mail"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Téléphone"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
msgstr "Langue"
#: web/templates/mail/payment/details.gotxt:54
msgid "Best regards,"
msgstr "Cordialement,"
@ -490,7 +490,7 @@ msgid "Discover"
msgstr "Découvrir"
#: web/templates/public/campsite/type.gohtml:49
#: web/templates/public/booking/fields.gohtml:269
#: web/templates/public/booking/fields.gohtml:273
msgctxt "action"
msgid "Book"
msgstr "Réserver"
@ -917,25 +917,25 @@ msgstr "Ville"
msgid "Choose a country"
msgstr "Choisissez un pays"
#: web/templates/public/booking/fields.gohtml:216
#: web/templates/public/booking/fields.gohtml:242
msgctxt "input"
msgid "ACSI card? (optional)"
msgstr "Carte ACSI ? (Facultatif)"
#: web/templates/public/booking/fields.gohtml:224
#: web/templates/public/booking/fields.gohtml:250
msgctxt "input"
msgid "I have read and I accept %[1]sthe reservation conditions%[2]s"
msgstr "Jai lu et jaccepte %[1]sles conditions de réservation%[2]s"
#: web/templates/public/booking/fields.gohtml:261
#: web/templates/public/booking/fields.gohtml:258
msgid "By down paying the %d %% of the total, you are pre-booking your preferences. We will respond within 24 hours and this percentage will be charged if accepted."
msgstr "En En effectuant le paiement de %d %% du total vous pré-réservez vos préférences. Nous vous répondrons dans les 24 heures et ce pourcentage sera facturé en cas dacceptation."
#: web/templates/public/booking/fields.gohtml:263
#: web/templates/public/booking/fields.gohtml:260
msgid "By paying the total you are pre-booking your preferences. We will respond within 24 hours and this amount will be charged if accepted."
msgstr "En procédant au paiement du montant total vous pré-réservez vos préférences. Nous vous répondrons dans les 24 heures et ce montant sera facturé en cas dacceptation."
#: web/templates/public/booking/fields.gohtml:267
#: web/templates/public/booking/fields.gohtml:264
msgid "See <%s>our conditions</%s> for more information."
msgstr "Consultez <%s>nos conditions</%s> pour plus dinformations."
@ -2270,7 +2270,7 @@ msgctxt "order product name"
msgid "Campsite Booking"
msgstr "Réservation camping"
#: pkg/payment/public.go:372
#: pkg/payment/public.go:369
msgctxt "subject"
msgid "Booking payment successfully received"
msgstr "Paiement de réservation reçu avec succès"
@ -2314,12 +2314,12 @@ msgid "Slide image must be an image media type."
msgstr "Limage de la diapositive doit être de type média dimage."
#: pkg/app/login.go:56 pkg/app/user.go:246 pkg/company/admin.go:224
#: pkg/booking/public.go:536
#: pkg/booking/public.go:544
msgid "Email can not be empty."
msgstr "Le-mail ne peut pas être vide."
#: pkg/app/login.go:57 pkg/app/user.go:247 pkg/company/admin.go:225
#: pkg/booking/public.go:537
#: pkg/booking/public.go:545
msgid "This email is not valid. It should be like name@domain.com."
msgstr "Cette adresse e-mail nest pas valide. Il devrait en être name@domain.com."
@ -2687,7 +2687,7 @@ msgstr "Laddresse du lien ne peut pas être vide."
msgid "This web address is not valid. It should be like https://domain.com/."
msgstr "Cette adresse web nest pas valide. Il devrait en être https://domain.com/."
#: pkg/company/admin.go:207 pkg/booking/public.go:521
#: pkg/company/admin.go:207 pkg/booking/public.go:529
msgid "Selected country is not valid."
msgstr "Le pays sélectionné nest pas valide."
@ -2707,15 +2707,15 @@ msgstr "Le numéro de TVA ne peut pas être vide."
msgid "This VAT number is not valid."
msgstr "Ce numéro de TVA nest pas valide."
#: pkg/company/admin.go:219 pkg/booking/public.go:539
#: pkg/company/admin.go:219 pkg/booking/public.go:547
msgid "Phone can not be empty."
msgstr "Le téléphone ne peut pas être vide."
#: pkg/company/admin.go:220 pkg/booking/public.go:540
#: pkg/company/admin.go:220 pkg/booking/public.go:548
msgid "This phone number is not valid."
msgstr "Ce numéro de téléphone nest pas valide."
#: pkg/company/admin.go:230 pkg/booking/public.go:529
#: pkg/company/admin.go:230 pkg/booking/public.go:537
msgid "Address can not be empty."
msgstr "Ladresse ne peut pas être vide."
@ -2727,11 +2727,11 @@ msgstr "La ville ne peut pas être vide."
msgid "Province can not be empty."
msgstr "La province ne peut pas être vide."
#: pkg/company/admin.go:233 pkg/booking/public.go:531
#: pkg/company/admin.go:233 pkg/booking/public.go:539
msgid "Postcode can not be empty."
msgstr "Le code postal ne peut pas être vide."
#: pkg/company/admin.go:234 pkg/booking/public.go:532
#: pkg/company/admin.go:234 pkg/booking/public.go:540
msgid "This postcode is not valid."
msgstr "Ce code postal nest pas valide."
@ -2783,27 +2783,27 @@ msgstr "Le fichier téléchargé ne peut pas être vide."
msgid "Filename can not be empty."
msgstr "Le nom de fichier ne peut pas être vide."
#: pkg/booking/cart.go:153
#: pkg/booking/cart.go:159
msgctxt "cart"
msgid "Night"
msgstr "Nuit"
#: pkg/booking/cart.go:154
#: pkg/booking/cart.go:160
msgctxt "cart"
msgid "Adult"
msgstr "Adulte"
#: pkg/booking/cart.go:155
#: pkg/booking/cart.go:161
msgctxt "cart"
msgid "Teenager"
msgstr "Adolescent"
#: pkg/booking/cart.go:156
#: pkg/booking/cart.go:162
msgctxt "cart"
msgid "Child"
msgstr "Enfant"
#: pkg/booking/cart.go:157
#: pkg/booking/cart.go:163
msgctxt "cart"
msgid "Dog"
msgstr "Chien"
@ -2849,92 +2849,92 @@ msgstr "La date de départ doit être égale ou postérieure à %s."
msgid "Departure date must be %s or before."
msgstr "La date de départ doit être antérieure ou égale à %s."
#: pkg/booking/public.go:356
#: pkg/booking/public.go:368
#, c-format
msgid "There can be at most %d guests in this accommodation."
msgstr "Il peut y avoir au plus %d invités dans cet hébergement."
#: pkg/booking/public.go:376
#: pkg/booking/public.go:388
msgid "Number of adults can not be empty"
msgstr "Le nombre dadultes ne peut pas être vide."
#: pkg/booking/public.go:377
#: pkg/booking/public.go:389
msgid "Number of adults must be an integer."
msgstr "Le nombre dadultes doit être un entier."
#: pkg/booking/public.go:378
#: pkg/booking/public.go:390
msgid "There must be at least one adult."
msgstr "Il doit y avoir au moins un adulte."
#: pkg/booking/public.go:381
#: pkg/booking/public.go:393
msgid "Number of teenagers can not be empty"
msgstr "Le nombre dadolescents ne peut pas être vide."
#: pkg/booking/public.go:382
#: pkg/booking/public.go:394
msgid "Number of teenagers must be an integer."
msgstr "Le nombre dadolescents doit être un entier."
#: pkg/booking/public.go:383
#: pkg/booking/public.go:395
msgid "Number of teenagers can not be negative."
msgstr "Le nombre dadolescents ne peut pas être négatif."
#: pkg/booking/public.go:386
#: pkg/booking/public.go:398
msgid "Number of children can not be empty"
msgstr "Le nombre denfants ne peut pas être vide."
#: pkg/booking/public.go:387
#: pkg/booking/public.go:399
msgid "Number of children must be an integer."
msgstr "Le nombre denfants doit être un entier."
#: pkg/booking/public.go:388
#: pkg/booking/public.go:400
msgid "Number of children can not be negative."
msgstr "Le nombre denfants ne peut pas être négatif."
#: pkg/booking/public.go:391
#: pkg/booking/public.go:403
msgid "Number of dogs can not be empty"
msgstr "Le nombre de chiens ne peut pas être vide."
#: pkg/booking/public.go:392
#: pkg/booking/public.go:404
msgid "Number of dogs must be an integer."
msgstr "Le nombre de chiens nuits être un entier."
#: pkg/booking/public.go:393
#: pkg/booking/public.go:405
msgid "Number of dogs can not be negative."
msgstr "Le nombre de chiens ne peut pas être négatif."
#: pkg/booking/public.go:464
#: pkg/booking/public.go:476
#, c-format
msgid "%s can not be empty"
msgstr "%s ne peut pas être vide"
#: pkg/booking/public.go:465
#: pkg/booking/public.go:477
#, c-format
msgid "%s must be an integer."
msgstr "%s doit être un entier."
#: pkg/booking/public.go:466
#: pkg/booking/public.go:478
#, c-format
msgid "%s must be %d or greater."
msgstr "%s doit être %d ou plus."
#: pkg/booking/public.go:467
#: pkg/booking/public.go:479
#, c-format
msgid "%s must be at most %d."
msgstr "%s doit être tout au plus %d."
#: pkg/booking/public.go:525
#: pkg/booking/public.go:533
msgid "Full name can not be empty."
msgstr "Le nom complet ne peut pas être vide."
#: pkg/booking/public.go:526
#: pkg/booking/public.go:534
msgid "Full name must have at least one letter."
msgstr "Le nom complet doit comporter au moins une lettre."
#: pkg/booking/public.go:530
#: pkg/booking/public.go:538
msgid "Town or village can not be empty."
msgstr "La ville ne peut pas être vide."
#: pkg/booking/public.go:545
#: pkg/booking/public.go:553
msgid "It is mandatory to agree to the reservation conditions."
msgstr "Il est obligatoire daccepter les conditions de réservation."

7
revert/acsi.sql Normal file
View File

@ -0,0 +1,7 @@
-- Revert camper:acsi from pg
begin;
drop table if exists camper.acsi;
commit;

7
revert/acsi_calendar.sql Normal file
View File

@ -0,0 +1,7 @@
-- Revert camper:acsi_calendar from pg
begin;
drop table if exists camper.acsi_calendar;
commit;

7
revert/acsi_option.sql Normal file
View File

@ -0,0 +1,7 @@
-- Revert camper:acsi_option from pg
begin;
drop table if exists camper.acsi_option;
commit;

View File

@ -10,11 +10,14 @@
-- requires: campsite_type_option
-- requires: payment
-- requires: payment_option
-- requires: company__tourist_tax_max_days
begin;
set search_path to camper, public;
drop function if exists draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, boolean, option_units[]);
create or replace function draft_payment(payment_slug uuid, arrival_date date, departure_date date, campsite_type_slug uuid, num_adults integer, num_teenagers integer, num_children integer, num_dogs integer, zone_preferences text, options option_units[]) returns payment as
$$
declare
@ -58,12 +61,12 @@ begin
, sum(cost_per_child * num_children)::integer
, num_dogs
, sum(case when num_dogs > 0 then coalesce(pet.cost_per_night, 0) else 0 end)::integer
, sum(tourist_tax * num_adults)::integer
, sum(case when day_num <= tourist_tax_max_days then tourist_tax * num_adults else 0 end)::integer
, 0
, currency_code
, case when arrival_date - current_date >= 7 then 0.3 else 1.0 end
, coalesce(zone_preferences, '')
from generate_series(arrival_date, departure_date - 1, interval '1 day') as date(day)
from generate_series(arrival_date, departure_date - 1, interval '1 day') with ordinality as date(day, day_num)
left join season_calendar on season_range @> date.day::date
left join season using (season_id)
left join campsite_type using (company_id)

168
revert/draft_payment@v5.sql Normal file
View File

@ -0,0 +1,168 @@
-- Deploy camper:draft_payment to pg
-- requires: roles
-- requires: schema_camper
-- requires: season_calendar
-- requires: season
-- requires: campsite_type
-- requires: campsite_type_pet_cost
-- requires: campsite_type_cost
-- requires: campsite_type_option_cost
-- requires: campsite_type_option
-- requires: payment
-- requires: payment_option
begin;
set search_path to camper, public;
create or replace function draft_payment(payment_slug uuid, arrival_date date, departure_date date, campsite_type_slug uuid, num_adults integer, num_teenagers integer, num_children integer, num_dogs integer, zone_preferences text, options option_units[]) returns payment as
$$
declare
p payment;
begin
if exists(select 1 from payment where slug = payment_slug and payment_status <> 'draft') then
payment_slug = null;
end if;
insert into payment (
slug
, company_id
, campsite_type_id
, arrival_date
, departure_date
, subtotal_nights
, number_adults
, subtotal_adults
, number_teenagers
, subtotal_teenagers
, number_children
, subtotal_children
, number_dogs
, subtotal_dogs
, subtotal_tourist_tax
, total
, currency_code
, down_payment_percent
, zone_preferences
)
select coalesce(payment_slug, gen_random_uuid())
, company_id
, campsite_type_id
, arrival_date
, departure_date
, sum(cost.cost_per_night * ceiling((num_adults::numeric + num_teenagers::numeric + num_children::numeric) / max_campers::numeric)::integer)::integer
, num_adults
, sum(cost_per_adult * num_adults)::integer
, num_teenagers
, sum(cost_per_teenager * num_teenagers)::integer
, num_children
, sum(cost_per_child * num_children)::integer
, num_dogs
, sum(case when num_dogs > 0 then coalesce(pet.cost_per_night, 0) else 0 end)::integer
, sum(tourist_tax * num_adults)::integer
, 0
, currency_code
, case when arrival_date - current_date >= 7 then 0.3 else 1.0 end
, coalesce(zone_preferences, '')
from generate_series(arrival_date, departure_date - 1, interval '1 day') as date(day)
left join season_calendar on season_range @> date.day::date
left join season using (season_id)
left join campsite_type using (company_id)
left join campsite_type_pet_cost as pet using (campsite_type_id)
left join campsite_type_cost as cost using (campsite_type_id, season_id)
left join company using (company_id)
where campsite_type.slug = campsite_type_slug
group by company_id
, campsite_type_id
, currency_code
on conflict (slug) do update
set company_id = excluded.company_id
, campsite_type_id = excluded.campsite_type_id
, arrival_date = excluded.arrival_date
, departure_date = excluded.departure_date
, subtotal_nights = excluded.subtotal_nights
, number_adults = excluded.number_adults
, subtotal_adults = excluded.subtotal_adults
, number_teenagers = excluded.number_teenagers
, subtotal_teenagers = excluded.subtotal_teenagers
, number_children = excluded.number_children
, subtotal_children = excluded.subtotal_children
, number_dogs = excluded.number_dogs
, subtotal_dogs = excluded.subtotal_dogs
, subtotal_tourist_tax = excluded.subtotal_tourist_tax
, total = excluded.total
, currency_code = excluded.currency_code
, down_payment_percent = excluded.down_payment_percent
, zone_preferences = excluded.zone_preferences
, updated_at = current_timestamp
returning *
into p
;
if array_length(coalesce(options, array[]::option_units[]), 1) > 0 then
delete
from payment_option
where payment_id = p.payment_id
and campsite_type_option_id not in (
select campsite_type_option_id
from unnest(options) as option(campsite_type_option_id, units)
);
insert into payment_option (
payment_id
, campsite_type_option_id
, units
, subtotal
)
select p.payment_id
, campsite_type_option_id
, units
, case when per_night then sum(cost * units)::integer else max(cost * units)::integer end
from generate_series(arrival_date, departure_date - 1, interval '1 day') as date(day)
join season_calendar on season_range @> date.day::date
join campsite_type_option_cost using (season_id)
join campsite_type_option using (campsite_type_option_id)
join unnest(options) as option(campsite_type_option_id, units) using (campsite_type_option_id)
group by campsite_type_option_id
, units
, per_night
on conflict (payment_id, campsite_type_option_id) do update
set units = excluded.units
, subtotal = excluded.subtotal
;
with option as (
select sum(subtotal)::integer as subtotal
from payment_option
where payment_id = p.payment_id
)
update payment
set total = subtotal_nights + subtotal_adults + subtotal_teenagers + subtotal_children + subtotal_dogs + subtotal_tourist_tax + coalesce(option.subtotal, 0)
from option
where payment_id = p.payment_id
returning total into p.total
;
else
delete
from payment_option
where payment_id = p.payment_id;
update payment
set total = subtotal_nights + subtotal_adults + subtotal_teenagers + subtotal_children + subtotal_dogs + subtotal_tourist_tax
where payment_id = p.payment_id
returning total into p.total
;
end if;
return p;
end;
$$
language plpgsql
;
revoke execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) from public;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to guest;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to employee;
grant execute on function draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, option_units[]) to admin;
commit;

View File

@ -0,0 +1,9 @@
-- Revert camper:payment__acsi_card from pg
begin;
alter table camper.payment
drop column if exists acsi_card
;
commit;

View File

@ -0,0 +1,21 @@
-- Revert camper:payment_customer__-acsi_card from pg
begin;
set search_path to camper, public;
alter table payment_customer
add column if not exists acsi_card boolean not null default false
;
update payment_customer
set acsi_card = payment.acsi_card
from payment
where payment.payment_id = payment_customer.payment_id
;
alter table payment_customer
alter column acsi_card drop default
;
commit;

View File

@ -1,7 +1,58 @@
-- Revert camper:ready_payment from pg
-- Deploy camper:ready_payment to pg
-- requires: roles
-- requires: schema_camper
-- requires: payment
-- requires: payment_customer
-- requires: country_code
-- requires: email
-- requires: extension_pg_libphonenumber
begin;
drop function if exists camper.ready_payment(uuid, text, text, text, text, camper.country_code, camper.email, text, text, boolean);
set search_path to camper, public;
drop function if exists ready_payment(uuid, text, text, text, text, country_code, email, text, text);
create or replace function ready_payment(payment_slug uuid, customer_name text, customer_address text, customer_post_code text, customer_city text, customer_country_code country_code, customer_email email, customer_phone text, customer_lang_tag text, customer_acsi_card boolean) returns integer as
$$
declare
pid integer;
begin
update payment
set payment_status = 'pending'
, updated_at = current_timestamp
where slug = payment_slug
and payment_status = 'draft'
returning payment_id into pid
;
if pid is null then
raise check_violation using message = 'insert or update on table "payment" violates check constraint "payment_is_draft"';
end if;
insert into payment_customer (payment_id, full_name, address, postal_code, city, country_code, email, phone, acsi_card, lang_tag)
values (pid, customer_name, customer_address, customer_post_code, customer_city, customer_country_code, customer_email, parse_packed_phone_number(customer_phone, customer_country_code), customer_acsi_card, customer_lang_tag)
on conflict (payment_id) do update
set full_name = excluded.full_name
, address = excluded.address
, postal_code = excluded.postal_code
, city = excluded.city
, country_code = excluded.country_code
, email = excluded.email
, phone = excluded.phone
, acsi_card = excluded.acsi_card
, lang_tag = excluded.lang_tag
;
return pid;
end;
$$
language plpgsql
;
revoke execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) from public;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to guest;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to employee;
grant execute on function ready_payment(uuid, text, text, text, text, country_code, email, text, text, boolean) to admin;
commit;

View File

@ -0,0 +1,7 @@
-- Revert camper:ready_payment from pg
begin;
drop function if exists camper.ready_payment(uuid, text, text, text, text, camper.country_code, camper.email, text, text, boolean);
commit;

View File

@ -267,3 +267,10 @@ flush_payments [roles schema_camper payment payment_option payment_redsys_respon
@v5 2024-03-13T19:55:03Z jordi fita mas <jordi@tandem.blog> # Tag v5
season_calendar_season_id_fkey [season season_calendar] 2024-03-14T17:04:30Z jordi fita mas <jordi@tandem.blog> # Add foreign constraint between season_calendar and season
acsi [roles schema_camper campsite_type] 2024-03-14T16:54:11Z jordi fita mas <jordi@tandem.blog> # Add relation of ACSI options
acsi_calendar [roles schema_camper acsi] 2024-03-14T16:59:43Z jordi fita mas <jordi@tandem.blog> # Add relation of dates for ACSI
acsi_option [roles schema_camper acsi campsite_type_option] 2024-03-14T17:56:59Z jordi fita mas <jordi@tandem.blog> # Add relation of acsi options
payment__acsi_card [payment] 2024-03-14T18:24:44Z jordi fita mas <jordi@tandem.blog> # Add acsi_card to payment
ready_payment [ready_payment@v5 payment__acsi_card] 2024-03-14T18:31:26Z jordi fita mas <jordi@tandem.blog> # Remove the acsi_card parameter from ready_payment
payment_customer__-acsi_card [payment__acsi_card] 2024-03-14T18:43:31Z jordi fita mas <jordi@tandem.blog> # Remove the acsi_card field from payment_customer
draft_payment [draft_payment@v5 acsi acsi_calendar acsi_option payment__acsi_card payment_customer__-acsi_card] 2024-03-14T18:05:25Z jordi fita mas <jordi@tandem.blog> # Include ACSI in payment drafting computation

57
test/acsi.sql Normal file
View File

@ -0,0 +1,57 @@
-- Test acsi
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(33);
set search_path to camper, public;
select has_table('acsi');
select has_pk('acsi');
select table_privs_are('acsi', 'guest', array['SELECT']);
select table_privs_are('acsi', 'employee', array['SELECT']);
select table_privs_are('acsi', 'admin', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('acsi', 'authenticator', array[]::text[]);
select has_column('acsi', 'campsite_type_id');
select col_is_pk('acsi', 'campsite_type_id');
select col_is_fk('acsi', 'campsite_type_id');
select fk_ok('acsi', 'campsite_type_id', 'campsite_type', 'campsite_type_id');
select col_type_is('acsi', 'campsite_type_id', 'integer');
select col_not_null('acsi', 'campsite_type_id');
select col_hasnt_default('acsi', 'campsite_type_id');
select has_column('acsi', 'number_adults');
select col_type_is('acsi', 'number_adults', 'positive_integer');
select col_not_null('acsi', 'number_adults');
select col_hasnt_default('acsi', 'number_adults');
select has_column('acsi', 'number_teenagers');
select col_type_is('acsi', 'number_teenagers', 'nonnegative_integer');
select col_not_null('acsi', 'number_teenagers');
select col_hasnt_default('acsi', 'number_teenagers');
select has_column('acsi', 'number_children');
select col_type_is('acsi', 'number_children', 'nonnegative_integer');
select col_not_null('acsi', 'number_children');
select col_hasnt_default('acsi', 'number_children');
select has_column('acsi', 'number_dogs');
select col_type_is('acsi', 'number_dogs', 'nonnegative_integer');
select col_not_null('acsi', 'number_dogs');
select col_hasnt_default('acsi', 'number_dogs');
select has_column('acsi', 'cost_per_night');
select col_type_is('acsi', 'cost_per_night', 'nonnegative_integer');
select col_not_null('acsi', 'cost_per_night');
select col_hasnt_default('acsi', 'cost_per_night');
select *
from finish();
rollback;

37
test/acsi_calendar.sql Normal file
View File

@ -0,0 +1,37 @@
-- Test acsi_calendar
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(17);
set search_path to camper, public;
select has_table('acsi_calendar');
select has_pk('acsi_calendar');
select col_is_pk('acsi_calendar', array['campsite_type_id', 'acsi_range']);
select table_privs_are('acsi_calendar', 'guest', array['SELECT']);
select table_privs_are('acsi_calendar', 'employee', array['SELECT']);
select table_privs_are('acsi_calendar', 'admin', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('acsi_calendar', 'authenticator', array[]::text[]);
select has_column('acsi_calendar', 'campsite_type_id');
select col_is_fk('acsi_calendar', 'campsite_type_id');
select fk_ok('acsi_calendar', 'campsite_type_id', 'acsi', 'campsite_type_id');
select col_type_is('acsi_calendar', 'campsite_type_id', 'integer');
select col_not_null('acsi_calendar', 'campsite_type_id');
select col_hasnt_default('acsi_calendar', 'campsite_type_id');
select has_column('acsi_calendar', 'acsi_range');
select col_type_is('acsi_calendar', 'acsi_range', 'daterange');
select col_not_null('acsi_calendar', 'acsi_range');
select col_hasnt_default('acsi_calendar', 'acsi_range');
select *
from finish();
rollback;

44
test/acsi_option.sql Normal file
View File

@ -0,0 +1,44 @@
-- Test acsi_option
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(23);
set search_path to camper, public;
select has_table('acsi_option');
select has_pk('acsi_option');
select col_is_pk('acsi_option', array['campsite_type_id', 'campsite_type_option_id']);
select table_privs_are('acsi_option', 'guest', array['SELECT']);
select table_privs_are('acsi_option', 'employee', array['SELECT']);
select table_privs_are('acsi_option', 'admin', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('acsi_option', 'authenticator', array[]::text[]);
select has_column('acsi_option', 'campsite_type_id');
select col_is_fk('acsi_option', 'campsite_type_id');
select fk_ok('acsi_option', 'campsite_type_id', 'acsi', 'campsite_type_id');
select col_type_is('acsi_option', 'campsite_type_id', 'integer');
select col_not_null('acsi_option', 'campsite_type_id');
select col_hasnt_default('acsi_option', 'campsite_type_id');
select has_column('acsi_option', 'campsite_type_option_id');
select col_is_fk('acsi_option', 'campsite_type_option_id');
select fk_ok('acsi_option', 'campsite_type_option_id', 'campsite_type_option', 'campsite_type_option_id');
select col_type_is('acsi_option', 'campsite_type_option_id', 'integer');
select col_not_null('acsi_option', 'campsite_type_option_id');
select col_hasnt_default('acsi_option', 'campsite_type_option_id');
select has_column('acsi_option', 'units');
select col_type_is('acsi_option', 'units', 'positive_integer');
select col_not_null('acsi_option', 'units');
select col_hasnt_default('acsi_option', 'units');
select *
from finish();
rollback;

View File

@ -46,14 +46,14 @@ insert into campsite_type (campsite_type_id, slug, company_id, name, media_id, m
values (12, 'c1b6f4fc-32c1-4cd5-b796-0c5059152a52', 2, 'Plots', 10, 6, '[1, 7]', true)
;
insert into payment (payment_id, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, down_payment_percent, zone_preferences)
values (22, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', 1.0, '')
, (23, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', 0.5, '')
, (24, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2500, 'EUR', 0.75, '')
, (25, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1234, 'EUR', 0.99, '')
, (26, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'EUR', 0.5, '')
, (27, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 987654, 'EUR', 0.33, '')
, (28, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 987654, 'EUR', 0.19, '')
insert into payment (payment_id, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, down_payment_percent, zone_preferences, acsi_card)
values (22, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', 1.0, '', false)
, (23, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', 0.5, '', false)
, (24, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2500, 'EUR', 0.75, '', false)
, (25, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1234, 'EUR', 0.99, '', false)
, (26, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'EUR', 0.5, '', false)
, (27, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 987654, 'EUR', 0.33, '', false)
, (28, 2, 12, '2024-08-28', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 987654, 'EUR', 0.19, '', false)
;
select bag_eq(

View File

@ -5,22 +5,25 @@ reset client_min_messages;
begin;
select plan(16);
select plan(17);
set search_path to camper, public;
select has_function('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]']);
select function_lang_is('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]'], 'plpgsql');
select function_returns('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]'], 'payment');
select isnt_definer('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]']);
select volatility_is('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]'], 'volatile');
select function_privs_are('camper', 'draft_payment', array ['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]'], 'guest', array['EXECUTE']);
select function_privs_are('camper', 'draft_payment', array ['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]'], 'employee', array['EXECUTE']);
select function_privs_are('camper', 'draft_payment', array ['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'draft_payment', array ['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'option_units[]'], 'authenticator', array[]::text[]);
select has_function('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]']);
select function_lang_is('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]'], 'plpgsql');
select function_returns('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]'], 'payment');
select isnt_definer('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]']);
select volatility_is('camper', 'draft_payment', array['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]'], 'volatile');
select function_privs_are('camper', 'draft_payment', array ['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]'], 'guest', array['EXECUTE']);
select function_privs_are('camper', 'draft_payment', array ['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]'], 'employee', array['EXECUTE']);
select function_privs_are('camper', 'draft_payment', array ['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'draft_payment', array ['uuid', 'date', 'date', 'uuid', 'integer', 'integer', 'integer', 'integer', 'text', 'boolean', 'option_units[]'], 'authenticator', array[]::text[]);
set client_min_messages to warning;
truncate acsi_option cascade;
truncate acsi_calendar cascade;
truncate acsi cascade;
truncate payment_option cascade;
truncate payment cascade;
truncate campsite_type_option_cost cascade;
@ -95,9 +98,9 @@ values (16, 4, 800)
, (20, 8, 590)
;
insert into payment (payment_id, slug, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, payment_status, created_at, updated_at)
values (22, '7cccfe16-695e-486d-a6a5-1162fb85cafb', 2, 12, current_date + 60, current_date + 62, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'USD', '', 'draft', '2024-01-01 01:01:01', '2024-01-01 01:01:01')
, (24, '6eeae04c-2fea-4d67-97dc-a4b8a83df99f', 2, 12, current_date + 61, current_date + 62, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'USD', '', 'pending', '2024-01-01 02:02:02', '2024-01-01 02:02:02')
insert into payment (payment_id, slug, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, acsi_card, payment_status, created_at, updated_at)
values (22, '7cccfe16-695e-486d-a6a5-1162fb85cafb', 2, 12, current_date + 60, current_date + 62, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'USD', '', false, 'draft', '2024-01-01 01:01:01', '2024-01-01 01:01:01')
, (24, '6eeae04c-2fea-4d67-97dc-a4b8a83df99f', 2, 12, current_date + 61, current_date + 62, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'USD', '', false, 'pending', '2024-01-01 02:02:02', '2024-01-01 02:02:02')
;
insert into payment_option (payment_id, campsite_type_option_id, units, subtotal)
@ -106,31 +109,50 @@ values (22, 16, 1, 0)
, (24, 16, 2, 0)
;
insert into acsi (campsite_type_id, number_adults, number_teenagers, number_children, number_dogs, cost_per_night)
values (12, 2, 0, 0, 1, 2300);
insert into acsi_calendar (campsite_type_id, acsi_range)
values (12, daterange(current_date + 60, current_date + 61))
, (12, daterange(current_date + 64, current_date + 65))
;
insert into acsi_option (campsite_type_id, campsite_type_option_id, units)
values (12, 16, 1)
, (12, 18, 1)
;
select lives_ok(
$$ select draft_payment(null, current_date + 59, current_date + 64, 'b065f4e3-2cc8-491d-a413-d015d7d00183', 1, 2, 3, 0, null, null) $$,
$$ select draft_payment(null, current_date + 59, current_date + 64, 'b065f4e3-2cc8-491d-a413-d015d7d00183', 1, 2, 3, 0, null, true, null) $$,
'Should be able to create a new draft for Bungalows'
);
select lives_ok(
$$ select draft_payment(null, current_date + 6, current_date + 11, 'b065f4e3-2cc8-491d-a413-d015d7d00183', 1, 2, 3, 0, null, null) $$,
$$ select draft_payment(null, current_date + 6, current_date + 11, 'b065f4e3-2cc8-491d-a413-d015d7d00183', 1, 2, 3, 0, null, true, null) $$,
'A payment for a reservation in less than a week has a 100 % of downpayment'
);
select lives_ok(
$$ select draft_payment(null, current_date + 10, current_date + 58, 'b065f4e3-2cc8-491d-a413-d015d7d00183', 2, 3, 4, 0, null, null) $$,
$$ select draft_payment(null, current_date + 10, current_date + 58, 'b065f4e3-2cc8-491d-a413-d015d7d00183', 2, 3, 4, 0, null, true, null) $$,
'All reservations incur a tourist tax for the first tourist_tax_max_days days'
);
select lives_ok(
$$ select draft_payment('7cccfe16-695e-486d-a6a5-1162fb85cafb', current_date + 58, current_date + 65, 'c1b6f4fc-32c1-4cd5-b796-0c5059152a52', 2, 4, 6, 3, 'pref I before E', array[(16, 2), (20, 3)]::option_units[]) $$,
$$ select draft_payment('7cccfe16-695e-486d-a6a5-1162fb85cafb', current_date + 58, current_date + 65, 'c1b6f4fc-32c1-4cd5-b796-0c5059152a52', 2, 4, 6, 3, 'pref I before E', false, array[(16, 2), (20, 3)]::option_units[]) $$,
'Should be able to update the draft for Plots'
);
select results_ne(
$$ select slug::text from draft_payment('6eeae04c-2fea-4d67-97dc-a4b8a83df99f', current_date + 31, current_date + 36, 'b065f4e3-2cc8-491d-a413-d015d7d00183', 2, 1, 1, 1, 'under a tree', array[(16, 1), (18, 1)]::option_units[]) $$,
$$ select slug::text from draft_payment('6eeae04c-2fea-4d67-97dc-a4b8a83df99f', current_date + 31, current_date + 36, 'b065f4e3-2cc8-491d-a413-d015d7d00183', 2, 1, 1, 1, 'under a tree', true, array[(16, 1), (18, 1)]::option_units[]) $$,
$$ values ('6eeae04c-2fea-4d67-97dc-a4b8a83df99f') $$,
'When trying to draft a payment already pending, completed, failed, or refunded, create a new instead'
);
select lives_ok(
$$ select draft_payment(null, current_date + 58, current_date + 65, 'c1b6f4fc-32c1-4cd5-b796-0c5059152a52', 3, 1, 1, 1, '', true, array[(16, 2), (18, 3), (20, 4)]::option_units[]) $$,
'Should be able to draft a payment for plots with ACSI discount during the days that is valid'
);
select bag_eq(
$$ select company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, down_payment_percent, zone_preferences, payment_status, created_at, updated_at from payment $$,
$$ values (2, 12, current_date + 58, current_date + 65, 3200, 2, 10420, 4, 20840, 6, 25080, 3, 2450, 4900, 79160, 'EUR', 0.3, 'pref I before E', 'draft', '2024-01-01 01:01:01', current_timestamp)
@ -139,6 +161,7 @@ select bag_eq(
, (2, 14, current_date + 6, current_date + 11, 85000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 86750, 'EUR', 1.0, '', 'draft', current_timestamp, current_timestamp)
, (2, 12, current_date + 61, current_date + 62, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'USD', 1.0, '', 'pending', '2024-01-01 02:02:02', '2024-01-01 02:02:02')
, (2, 14, current_date + 31, current_date + 36, 85000, 2, 0, 1, 0, 1, 0, 1, 0, 3500, 96000, 'EUR', 0.3, 'under a tree', 'draft', current_timestamp, current_timestamp)
, (2, 12, current_date + 58, current_date + 65, 6000, 3, 12830, 1, 5210, 1, 4180, 1, 1750, 7350, 61130, 'EUR', 0.3, '', 'draft', current_timestamp, current_timestamp)
$$,
'Should have added and updated payments'
);
@ -146,10 +169,13 @@ select bag_eq(
select bag_eq(
$$ select case payment_id when 22 then 'a' when 24 then 'b' else 'c' end, campsite_type_option_id, units, subtotal from payment_option $$,
$$ values ('a', 16, 2, 10200)
, ('a', 20, 3, 2070)
, ('b', 16, 2, 0)
, ('c', 16, 1, 4000)
, ('c', 18, 1, 3500)
, ('a', 20, 3, 2070)
, ('b', 16, 2, 0)
, ('c', 16, 1, 4000)
, ('c', 18, 1, 3500)
, ('c', 16, 2, 8860)
, ('c', 18, 3, 12190)
, ('c', 20, 4, 2760)
$$,
'Should have added, updated, and removed payment options'
);

View File

@ -51,16 +51,16 @@ insert into campsite_type_option (campsite_type_option_id, campsite_type_id, nam
values (16, 12, 'Big tent', '[0, 4)', true)
;
insert into payment (payment_id, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, payment_status, created_at, updated_at)
values (22, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'draft', '2024-01-01 01:01:01', current_timestamp - interval '1 day, -1 second')
, (24, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'draft', '2024-01-01 01:01:01', current_timestamp - interval '1 day, 1 second')
, (26, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'pending', '2024-01-02 02:02:02', current_timestamp - interval '1 hour, -1 second')
, (28, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'pending', '2024-01-03 03:03:03', current_timestamp - interval '1 hour, 1 second')
, (30, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'preauth', '2024-01-04 04:04:04', current_timestamp - interval '2 days')
, (32, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'failed', '2024-01-05 05:05:05', current_timestamp - interval '2 days')
, (34, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'completed', '2024-01-05 05:05:05', current_timestamp - interval '2 days')
, (36, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'refunded', '2024-01-05 05:05:05', current_timestamp - interval '2 days')
, (38, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'voided', '2024-01-05 05:05:05', current_timestamp - interval '2 days')
insert into payment (payment_id, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, acsi_card, payment_status, created_at, updated_at)
values (22, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'draft', '2024-01-01 01:01:01', current_timestamp - interval '1 day, -1 second')
, (24, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'draft', '2024-01-01 01:01:01', current_timestamp - interval '1 day, 1 second')
, (26, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'pending', '2024-01-02 02:02:02', current_timestamp - interval '1 hour, -1 second')
, (28, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'pending', '2024-01-03 03:03:03', current_timestamp - interval '1 hour, 1 second')
, (30, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'preauth', '2024-01-04 04:04:04', current_timestamp - interval '2 days')
, (32, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'failed', '2024-01-05 05:05:05', current_timestamp - interval '2 days')
, (34, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'completed', '2024-01-05 05:05:05', current_timestamp - interval '2 days')
, (36, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'refunded', '2024-01-05 05:05:05', current_timestamp - interval '2 days')
, (38, 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'voided', '2024-01-05 05:05:05', current_timestamp - interval '2 days')
;
insert into payment_option (payment_id, campsite_type_option_id, units, subtotal)

View File

@ -5,7 +5,7 @@ reset client_min_messages;
begin;
select plan(114);
select plan(118);
set search_path to camper, public;
@ -126,6 +126,11 @@ select col_type_is('payment', 'zone_preferences', 'text');
select col_not_null('payment', 'zone_preferences');
select col_hasnt_default('payment', 'zone_preferences');
select has_column('payment', 'acsi_card');
select col_type_is('payment', 'acsi_card', 'boolean');
select col_not_null('payment', 'acsi_card');
select col_hasnt_default('payment', 'acsi_card');
select has_column('payment', 'payment_status');
select col_is_fk('payment', 'payment_status');
select fk_ok('payment', 'payment_status', 'payment_status', 'payment_status');
@ -173,7 +178,7 @@ values (10, 1, 2, 'Type A', '<p>A</p>', 5, '[1, 7]', true)
;
select throws_ok(
$$ insert into payment (company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences) values (1, 10, '2024-07-07', '2024-07-07', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '') $$,
$$ insert into payment (company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, acsi_card) values (1, 10, '2024-07-07', '2024-07-07', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '', false) $$,
'23514', 'new row for relation "payment" violates check constraint "departure_after_arrival"',
'Should not be able to insert a payment with a departure date equal or before the arrival date (i.e., at least one night)'
);

View File

@ -5,7 +5,7 @@ reset client_min_messages;
begin;
select plan(53);
select plan(49);
set search_path to camper, public;
@ -61,11 +61,6 @@ select col_type_is('payment_customer', 'phone', 'packed_phone_number');
select col_not_null('payment_customer', 'phone');
select col_hasnt_default('payment_customer', 'phone');
select has_column('payment_customer', 'acsi_card');
select col_type_is('payment_customer', 'acsi_card', 'boolean');
select col_not_null('payment_customer', 'acsi_card');
select col_hasnt_default('payment_customer', 'acsi_card');
select has_column('payment_customer', 'lang_tag');
select col_is_fk('payment_customer', 'lang_tag');
select fk_ok('payment_customer', 'lang_tag', 'language', 'lang_tag');

View File

@ -44,14 +44,14 @@ insert into campsite_type (campsite_type_id, slug, company_id, name, media_id, m
values (12, 'c1b6f4fc-32c1-4cd5-b796-0c5059152a52', 2, 'Plots', 10, 6, '[1, 7]', true)
;
insert into payment (payment_id, slug, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences)
values (22, '4ef35e2f-ef98-42d6-a724-913bd761ca8c', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '')
, (23, '6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '')
, (24, '8d38a482-8a25-4d85-9929-e5f425fcac04', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '')
, (25, 'b770f8b7-f148-4ab4-a786-aa070af598e5', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '')
, (26, '31910d73-d343-44b7-8a29-f7e075b64933', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '')
, (27, 'c9488490-ac09-4402-90cd-f6f0546f04c0', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '')
, (28, '5819823e-c0ac-4baa-a3ae-515fbb70e909', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '')
insert into payment (payment_id, slug, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, acsi_card)
values (22, '4ef35e2f-ef98-42d6-a724-913bd761ca8c', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '', false)
, (23, '6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '', false)
, (24, '8d38a482-8a25-4d85-9929-e5f425fcac04', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '', false)
, (25, 'b770f8b7-f148-4ab4-a786-aa070af598e5', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '', false)
, (26, '31910d73-d343-44b7-8a29-f7e075b64933', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '', false)
, (27, 'c9488490-ac09-4402-90cd-f6f0546f04c0', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '', false)
, (28, '5819823e-c0ac-4baa-a3ae-515fbb70e909', 2, 12, '2024-08-29', '2024-09-03', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'EUR', '', false)
;
select bag_eq(

View File

@ -44,17 +44,17 @@ insert into campsite_type (campsite_type_id, slug, company_id, name, media_id, m
values (12, 'c1b6f4fc-32c1-4cd5-b796-0c5059152a52', 2, 'Plots', 10, 6, '[1, 7]', true)
;
insert into payment (payment_id, slug, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, payment_status, created_at, updated_at)
values (22, '4ef35e2f-ef98-42d6-a724-913bd761ca8c', 2, 12, '2024-08-28', '2024-09-04', 3200, 2, 10420, 4, 20840, 6, 25080, 3, 2450, 4900, 79160, 'EUR', 'pref I before E', 'draft', '2024-01-01 01:01:01', '2024-01-01 01:01:01')
, (24, '6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'pending', '2024-01-02 02:02:02', '2024-01-02 02:02:02')
, (26, '8d38a482-8a25-4d85-9929-e5f425fcac04', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'completed', '2024-01-03 03:03:03', '2024-01-03 03:03:03')
, (28, 'b770f8b7-f148-4ab4-a786-aa070af598e5', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'failed', '2024-01-04 04:04:04', '2024-01-04 04:04:04')
, (30, '31910d73-d343-44b7-8a29-f7e075b64933', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'refunded', '2024-01-05 05:05:05', '2024-01-05 05:05:05')
, (32, 'c9488490-ac09-4402-90cd-f6f0546f04c0', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'pending', '2024-01-05 05:05:05', '2024-01-05 05:05:05')
, (34, '5819823e-c0ac-4baa-a3ae-515fbb70e909', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'pending', '2024-01-05 05:05:05', '2024-01-06 06:06:06')
, (36, 'f2871c2d-e11a-41e8-b264-0a8605c77dc1', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'pending', '2024-01-05 05:05:05', '2024-01-06 06:06:06')
, (38, '01505d14-6f4d-48a2-9a98-3a2099ab7eef', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'preauth', '2024-01-05 05:05:05', '2024-01-06 06:06:06')
, (40, '7cae7d1c-d626-41e0-b1c5-48359e515579', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'preauth', '2024-01-05 05:05:05', '2024-01-06 06:06:06')
insert into payment (payment_id, slug, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, acsi_card, payment_status, created_at, updated_at)
values (22, '4ef35e2f-ef98-42d6-a724-913bd761ca8c', 2, 12, '2024-08-28', '2024-09-04', 3200, 2, 10420, 4, 20840, 6, 25080, 3, 2450, 4900, 79160, 'EUR', 'pref I before E', false, 'draft', '2024-01-01 01:01:01', '2024-01-01 01:01:01')
, (24, '6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'pending', '2024-01-02 02:02:02', '2024-01-02 02:02:02')
, (26, '8d38a482-8a25-4d85-9929-e5f425fcac04', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'completed', '2024-01-03 03:03:03', '2024-01-03 03:03:03')
, (28, 'b770f8b7-f148-4ab4-a786-aa070af598e5', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'failed', '2024-01-04 04:04:04', '2024-01-04 04:04:04')
, (30, '31910d73-d343-44b7-8a29-f7e075b64933', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'refunded', '2024-01-05 05:05:05', '2024-01-05 05:05:05')
, (32, 'c9488490-ac09-4402-90cd-f6f0546f04c0', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'pending', '2024-01-05 05:05:05', '2024-01-05 05:05:05')
, (34, '5819823e-c0ac-4baa-a3ae-515fbb70e909', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'pending', '2024-01-05 05:05:05', '2024-01-06 06:06:06')
, (36, 'f2871c2d-e11a-41e8-b264-0a8605c77dc1', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'pending', '2024-01-05 05:05:05', '2024-01-06 06:06:06')
, (38, '01505d14-6f4d-48a2-9a98-3a2099ab7eef', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'preauth', '2024-01-05 05:05:05', '2024-01-06 06:06:06')
, (40, '7cae7d1c-d626-41e0-b1c5-48359e515579', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'preauth', '2024-01-05 05:05:05', '2024-01-06 06:06:06')
;
insert into payment_redsys_response (payment_id, response_code, date_time, secure_payment, transaction_type, amount, currency_code, order_number, authorization_code, merchant_code, terminal_number, error_code)

View File

@ -9,15 +9,15 @@ select plan(15);
set search_path to camper, public;
select has_function('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean']);
select function_lang_is('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean'], 'plpgsql');
select function_returns('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean'], 'integer');
select isnt_definer('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean']);
select volatility_is('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean'], 'volatile');
select function_privs_are('camper', 'ready_payment', array ['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean'], 'guest', array['EXECUTE']);
select function_privs_are('camper', 'ready_payment', array ['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean'], 'employee', array['EXECUTE']);
select function_privs_are('camper', 'ready_payment', array ['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'ready_payment', array ['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text', 'boolean'], 'authenticator', array[]::text[]);
select has_function('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text']);
select function_lang_is('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text'], 'plpgsql');
select function_returns('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text'], 'integer');
select isnt_definer('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text']);
select volatility_is('camper', 'ready_payment', array['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text'], 'volatile');
select function_privs_are('camper', 'ready_payment', array ['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text'], 'guest', array['EXECUTE']);
select function_privs_are('camper', 'ready_payment', array ['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text'], 'employee', array['EXECUTE']);
select function_privs_are('camper', 'ready_payment', array ['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'ready_payment', array ['uuid', 'text', 'text', 'text', 'text', 'country_code', 'email', 'text', 'text'], 'authenticator', array[]::text[]);
set client_min_messages to warning;
@ -45,51 +45,51 @@ insert into campsite_type (campsite_type_id, slug, company_id, name, media_id, m
values (12, 'c1b6f4fc-32c1-4cd5-b796-0c5059152a52', 2, 'Plots', 10, 6, '[1, 7]', true)
;
insert into payment (payment_id, slug, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, payment_status, created_at, updated_at)
values (22, '4ef35e2f-ef98-42d6-a724-913bd761ca8c', 2, 12, '2024-08-28', '2024-09-04', 3200, 2, 10420, 4, 20840, 6, 25080, 3, 2450, 4900, 79160, 'EUR', 'pref I before E', 'draft', '2024-01-01 01:01:01', '2024-01-01')
, (24, '6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', 'draft', current_timestamp, current_timestamp)
insert into payment (payment_id, slug, company_id, campsite_type_id, arrival_date, departure_date, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, currency_code, zone_preferences, acsi_card, payment_status, created_at, updated_at)
values (22, '4ef35e2f-ef98-42d6-a724-913bd761ca8c', 2, 12, '2024-08-28', '2024-09-04', 3200, 2, 10420, 4, 20840, 6, 25080, 3, 2450, 4900, 79160, 'EUR', 'pref I before E', true, 'draft', '2024-01-01 01:01:01', '2024-01-01')
, (24, '6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, 'EUR', '', false, 'draft', current_timestamp, current_timestamp)
;
insert into payment_customer (payment_id, full_name, address, postal_code, city, country_code, email, phone, acsi_card, lang_tag)
values (24, '', '', '', '', 'FR', 'a@a.com', '555-555-555', true, 'es')
insert into payment_customer (payment_id, full_name, address, postal_code, city, country_code, email, phone, lang_tag)
values (24, '', '', '', '', 'FR', 'a@a.com', '555-555-555', 'es')
;
select is(
ready_payment('4ef35e2f-ef98-42d6-a724-913bd761ca8c', 'Juli Verd', 'C/ Fals, 123', '17486', 'Castelló dEmpúries', 'ES', 'juli@verd.cat', '972486 160', 'ca', true),
ready_payment('4ef35e2f-ef98-42d6-a724-913bd761ca8c', 'Juli Verd', 'C/ Fals, 123', '17486', 'Castelló dEmpúries', 'ES', 'juli@verd.cat', '972486 160', 'ca'),
22,
'Should be able to ready the first draft payment'
);
select is(
ready_payment('6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 'Pere Gil', 'Gutenbergstr. 9-13', '82178', 'Puchheim', 'DE', 'pere@gil.de', '8980902-0', 'en', false),
ready_payment('6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 'Pere Gil', 'Gutenbergstr. 9-13', '82178', 'Puchheim', 'DE', 'pere@gil.de', '8980902-0', 'en'),
24,
'Should be able to ready the second draft payment, and update customer details'
);
select throws_ok(
$$ select ready_payment('7ba7f0a5-d73d-4d6e-a9c4-3b88f2b2a357', 'Juli Verd', 'C/ Fals, 123', '17486', 'Castelló dEmpúries', 'ES', 'juli@verd.cat', '972 486 160', 'ca', true) $$,
$$ select ready_payment('7ba7f0a5-d73d-4d6e-a9c4-3b88f2b2a357', 'Juli Verd', 'C/ Fals, 123', '17486', 'Castelló dEmpúries', 'ES', 'juli@verd.cat', '972 486 160', 'ca') $$,
'23514', 'insert or update on table "payment" violates check constraint "payment_is_draft"',
'Should not be able to ready an inexistent payment'
);
select throws_ok(
$$ select ready_payment('4ef35e2f-ef98-42d6-a724-913bd761ca8c', 'Juli Verd', 'C/ Fals, 123', '17486', 'Castelló dEmpúries', 'ES', 'juli@verd.cat', '972 486 160', 'ca', true) $$,
$$ select ready_payment('4ef35e2f-ef98-42d6-a724-913bd761ca8c', 'Juli Verd', 'C/ Fals, 123', '17486', 'Castelló dEmpúries', 'ES', 'juli@verd.cat', '972 486 160', 'ca') $$,
'23514', 'insert or update on table "payment" violates check constraint "payment_is_draft"',
'Should not be able to ready an already processed payment'
);
select bag_eq(
$$ select payment_id, slug::text, company_id, campsite_type_id, arrival_date::text, departure_date::text, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, zone_preferences, payment_status, created_at, updated_at from payment $$,
$$ values (22, '4ef35e2f-ef98-42d6-a724-913bd761ca8c', 2, 12, '2024-08-28', '2024-09-04', 3200, 2, 10420, 4, 20840, 6, 25080, 3, 2450, 4900, 79160, 'pref I before E', 'pending', '2024-01-01 01:01:01', current_timestamp)
, (24, '6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, '', 'pending', current_timestamp, current_timestamp)
$$ select payment_id, slug::text, company_id, campsite_type_id, arrival_date::text, departure_date::text, subtotal_nights, number_adults, subtotal_adults, number_teenagers, subtotal_teenagers, number_children, subtotal_children, number_dogs, subtotal_dogs, subtotal_tourist_tax, total, zone_preferences, acsi_card, payment_status, created_at, updated_at from payment $$,
$$ values (22, '4ef35e2f-ef98-42d6-a724-913bd761ca8c', 2, 12, '2024-08-28', '2024-09-04', 3200, 2, 10420, 4, 20840, 6, 25080, 3, 2450, 4900, 79160, 'pref I before E', true, 'pending', '2024-01-01 01:01:01', current_timestamp)
, (24, '6d1b8e4c-c3c6-4fe4-92c1-2cbf94526693', 2, 12, '2024-08-29', '2024-09-03', 71000, 1, 0, 2, 0, 3, 0, 0, 0, 1750, 72750, '', false, 'pending', current_timestamp, current_timestamp)
$$,
'Should have updated payments'
);
select bag_eq(
$$ select payment_id, full_name, address, postal_code, city, country_code::text, email::text, phone::text, acsi_card, lang_tag from payment_customer $$,
$$ values (22, 'Juli Verd', 'C/ Fals, 123', '17486', 'Castelló dEmpúries', 'ES', 'juli@verd.cat', '+34 972 48 61 60', true, 'ca')
, (24, 'Pere Gil', 'Gutenbergstr. 9-13', '82178', 'Puchheim', 'DE', 'pere@gil.de', '+49 89 809020', false, 'en')
$$ select payment_id, full_name, address, postal_code, city, country_code::text, email::text, phone::text, lang_tag from payment_customer $$,
$$ values (22, 'Juli Verd', 'C/ Fals, 123', '17486', 'Castelló dEmpúries', 'ES', 'juli@verd.cat', '+34 972 48 61 60', 'ca')
, (24, 'Pere Gil', 'Gutenbergstr. 9-13', '82178', 'Puchheim', 'DE', 'pere@gil.de', '+49 89 809020', 'en')
$$,
'Should have added and updated customer details'
);

14
verify/acsi.sql Normal file
View File

@ -0,0 +1,14 @@
-- Verify camper:acsi on pg
begin;
select campsite_type_id
, number_adults
, number_teenagers
, number_children
, number_dogs
, cost_per_night
from camper.acsi
where false;
rollback;

10
verify/acsi_calendar.sql Normal file
View File

@ -0,0 +1,10 @@
-- Verify camper:acsi_calendar on pg
begin;
select campsite_type_id
, acsi_range
from camper.acsi_calendar
where false;
rollback;

11
verify/acsi_option.sql Normal file
View File

@ -0,0 +1,11 @@
-- Verify camper:acsi_option on pg
begin;
select campsite_type_id
, campsite_type_option_id
, units
from camper.acsi_option
where false;
rollback;

View File

@ -2,6 +2,6 @@
begin;
select has_function_privilege('camper.draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, camper.option_units[])', 'execute');
select has_function_privilege('camper.draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, boolean, camper.option_units[])', 'execute');
rollback;

View File

@ -0,0 +1,7 @@
-- Verify camper:draft_payment on pg
begin;
select has_function_privilege('camper.draft_payment(uuid, date, date, uuid, integer, integer, integer, integer, text, camper.option_units[])', 'execute');
rollback;

View File

@ -0,0 +1,10 @@
-- Verify camper:payment__acsi_card on pg
begin;
select acsi_card
from camper.payment
where false
;
rollback;

View File

@ -0,0 +1,11 @@
-- Verify camper:payment_customer__-acsi_card on pg
begin;
select 1 / (1 - count(*))
from pg_attribute
where attrelid = 'camper.payment_customer'::regclass
and attname = 'acsi_card'
;
rollback;

View File

@ -2,6 +2,6 @@
begin;
select has_function_privilege('camper.ready_payment(uuid, text, text, text, text, camper.country_code, camper.email, text, text, boolean)', 'execute');
select has_function_privilege('camper.ready_payment(uuid, text, text, text, text, camper.country_code, camper.email, text, text)', 'execute');
rollback;

View File

@ -0,0 +1,7 @@
-- Verify camper:ready_payment on pg
begin;
select has_function_privilege('camper.ready_payment(uuid, text, text, text, text, camper.country_code, camper.email, text, text, boolean)', 'execute');
rollback;

View File

@ -1399,6 +1399,12 @@ input[type="checkbox"]:focus {
top: 13rem;
}
#booking > footer fieldset {
flex-direction: column;
gap: 1em;
margin: 1em 0;
}
#booking br {
display: none;
}

View File

@ -48,6 +48,10 @@
<th scope="row">{{( pgettext "Area preferences" "header" )}}</th>
<td>{{ .ZonePreferences }}</td>
</tr>
<tr>
<th scope="row">{{( pgettext "ACSI card?" "input" )}}</th>
<td>{{if .ACSICard}}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }}</td>
</tr>
<tr>
<th scope="row">{{( pgettext "Arrival date" "input" )}}</th>
<td>{{ .ArrivalDate | formatDate }}</td>
@ -137,10 +141,6 @@
<th scope="row">{{( pgettext "Language" "input" )}}</th>
<td>{{ .Language }}</td>
</tr>
<tr>
<th scope="row">{{( pgettext "ACSI card?" "input" )}}</th>
<td>{{if .ACSICard}}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }}</td>
</tr>
</tbody>
</table>
{{- end }}

View File

@ -15,6 +15,7 @@
* {{( pgettext "Accommodation" "title" )}}: {{ .CampsiteType }}
* {{( pgettext "Area preferences" "header" )}}: {{ .ZonePreferences }}
* {{( pgettext "ACSI card?" "input" )}}: {{if .ACSICard}}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }}
* {{( pgettext "Arrival date" "input" )}}: {{ .ArrivalDate.Format "02/01/2006" }}
* {{( pgettext "Departure date" "input" )}}: {{ .DepartureDate.Format "02/01/2006" }}
* {{( pgettext "Nights" "cart" )}}: {{ .NumNights }}
@ -45,7 +46,6 @@
* {{( pgettext "Email" "input" )}}: {{ .Email }}
* {{( pgettext "Phone" "input" )}}: {{ .Phone }}
* {{( pgettext "Language" "input" )}}: {{ .Language }}
* {{( pgettext "ACSI card?" "input" )}}: {{if .ACSICard}}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }}
{{- end }}

File diff suppressed because one or more lines are too long