more useful stuff for the dashboard

This commit is contained in:
Pablo Martin 2024-05-02 18:44:11 +02:00
parent a83cb7f100
commit 180c005e3c
3 changed files with 40 additions and 1 deletions

View file

@ -28,6 +28,8 @@ select
b.check_in_date_utc,
b.check_out_at_utc,
b.check_out_date_utc,
b.check_in_at_utc > now() as check_in_sits_in_future,
b.check_out_at_utc > now() as check_out_sits_in_future,
bce.booking_fee_local,
booking_fee_charge_at_utc,
booking_fee_charge_date_utc,

View file

@ -0,0 +1,13 @@
with
stg_core__payment_validation_set_to_currency as (
select * from {{ ref("stg_core__payment_validation_set_to_currency") }}
)
select
pvttoc.local_currency_iso_4217,
pvttoc.checkin_cover_guest_fee_local_curr,
pvttoc.checkin_cover_cover_amount_local_curr
from stg_core__payment_validation_set_to_currency pvttoc
group by
pvttoc.local_currency_iso_4217,
pvttoc.checkin_cover_guest_fee_local_curr,
pvttoc.checkin_cover_cover_amount_local_curr

View file

@ -17,6 +17,9 @@ with
where
verification_payment_type = 'CheckInCover' -- 5 is check-in cover
and payment_status in ('Paid', 'Refunded')
),
int_core__check_in_cover_prices as (
select * from {{ ref("int_core__check_in_cover_prices") }}
)
select
vr.id_verification_request,
@ -26,7 +29,20 @@ select
vr.id_payment_validation_set,
vr.id_user_guest,
vr.id_user_host,
b.id_booking,
b.id_accommodation,
vr.is_verification_request_complete,
(
p.amount_in_txn_currency is not null and not b.check_in_sits_in_future
) as is_past_check_in,
(
p.amount_in_txn_currency is not null
and b.check_in_sits_in_future
and vr.is_verification_request_complete
) as is_awaiting_check_in,
p.amount_in_txn_currency is not null as cover_was_purchased,
p.amount_in_txn_currency is null
and vr.is_verification_request_complete as cover_was_rejected,
vr.verification_url,
vr.callback_url,
vr.redirect_url,
@ -37,6 +53,10 @@ select
vr.guest_phone_number,
vr.telephone_code,
vr.guest_phone_number_2,
b.check_in_at_utc,
b.check_in_date_utc,
b.check_out_at_utc,
b.check_out_date_utc,
vr.verification_start_at_utc,
vr.verification_start_date_utc,
vr.verification_end_at_utc,
@ -64,13 +84,17 @@ select
p.currency,
p.amount_in_gbp,
p.payment_status,
p.payment_paid_date_utc
p.payment_paid_date_utc,
ccp.checkin_cover_cover_amount_local_curr
from int_core__verification_requests vr
left join int_core__booking b on vr.id_verification_request = b.id_verification_request
left join
stg_core__verification_set_to_verification_type vstvt
on vr.id_verification_set = vstvt.id_verification_set
left join
check_in_cover_payments p on vr.id_verification_request = p.id_verification_request
left join
int_core__check_in_cover_prices ccp on p.currency = ccp.local_currency_iso_4217
-- 15 is Check-in cover.
-- Adding this condition results in only keeping guest journeys that offered the
-- check-in cover