more useful stuff for the dashboard
This commit is contained in:
parent
a83cb7f100
commit
180c005e3c
3 changed files with 40 additions and 1 deletions
|
|
@ -28,6 +28,8 @@ select
|
||||||
b.check_in_date_utc,
|
b.check_in_date_utc,
|
||||||
b.check_out_at_utc,
|
b.check_out_at_utc,
|
||||||
b.check_out_date_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,
|
bce.booking_fee_local,
|
||||||
booking_fee_charge_at_utc,
|
booking_fee_charge_at_utc,
|
||||||
booking_fee_charge_date_utc,
|
booking_fee_charge_date_utc,
|
||||||
|
|
|
||||||
13
models/intermediate/core/int_core__check_in_cover_prices.sql
Normal file
13
models/intermediate/core/int_core__check_in_cover_prices.sql
Normal 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
|
||||||
|
|
@ -17,6 +17,9 @@ with
|
||||||
where
|
where
|
||||||
verification_payment_type = 'CheckInCover' -- 5 is check-in cover
|
verification_payment_type = 'CheckInCover' -- 5 is check-in cover
|
||||||
and payment_status in ('Paid', 'Refunded')
|
and payment_status in ('Paid', 'Refunded')
|
||||||
|
),
|
||||||
|
int_core__check_in_cover_prices as (
|
||||||
|
select * from {{ ref("int_core__check_in_cover_prices") }}
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
vr.id_verification_request,
|
vr.id_verification_request,
|
||||||
|
|
@ -26,7 +29,20 @@ select
|
||||||
vr.id_payment_validation_set,
|
vr.id_payment_validation_set,
|
||||||
vr.id_user_guest,
|
vr.id_user_guest,
|
||||||
vr.id_user_host,
|
vr.id_user_host,
|
||||||
|
b.id_booking,
|
||||||
|
b.id_accommodation,
|
||||||
vr.is_verification_request_complete,
|
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.verification_url,
|
||||||
vr.callback_url,
|
vr.callback_url,
|
||||||
vr.redirect_url,
|
vr.redirect_url,
|
||||||
|
|
@ -37,6 +53,10 @@ select
|
||||||
vr.guest_phone_number,
|
vr.guest_phone_number,
|
||||||
vr.telephone_code,
|
vr.telephone_code,
|
||||||
vr.guest_phone_number_2,
|
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_at_utc,
|
||||||
vr.verification_start_date_utc,
|
vr.verification_start_date_utc,
|
||||||
vr.verification_end_at_utc,
|
vr.verification_end_at_utc,
|
||||||
|
|
@ -64,13 +84,17 @@ select
|
||||||
p.currency,
|
p.currency,
|
||||||
p.amount_in_gbp,
|
p.amount_in_gbp,
|
||||||
p.payment_status,
|
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
|
from int_core__verification_requests vr
|
||||||
|
left join int_core__booking b on vr.id_verification_request = b.id_verification_request
|
||||||
left join
|
left join
|
||||||
stg_core__verification_set_to_verification_type vstvt
|
stg_core__verification_set_to_verification_type vstvt
|
||||||
on vr.id_verification_set = vstvt.id_verification_set
|
on vr.id_verification_set = vstvt.id_verification_set
|
||||||
left join
|
left join
|
||||||
check_in_cover_payments p on vr.id_verification_request = p.id_verification_request
|
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.
|
-- 15 is Check-in cover.
|
||||||
-- Adding this condition results in only keeping guest journeys that offered the
|
-- Adding this condition results in only keeping guest journeys that offered the
|
||||||
-- check-in cover
|
-- check-in cover
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue