added new metrics for not cancelled bookings

This commit is contained in:
Joaquin Ossa 2024-11-06 12:34:33 +01:00
parent f5addc7f4c
commit b9968c7a72
2 changed files with 80 additions and 4 deletions

View file

@ -10,7 +10,7 @@ select
icvp.payment_paid_date_utc as date,
coalesce(icuh.id_deal, 'UNSET') as id_deal,
case
when v.id_verification is null then 'W/O Id Check' else 'With Id Check'
when icv.id_verification is null then 'W/O Id Check' else 'With Id Check'
end as has_id_check,
-- Dimensions --
coalesce(
@ -29,6 +29,17 @@ select
else null
end
) as deposit_fees_in_gbp,
sum(
case
when
upper(icvp.verification_payment_type)
in {{ deposit_fees_verification_payment_type_items }}
and upper(icb.booking_state) <> {{ var("cancelled_booking_state") }}
and icb.id_booking is not null
then icvp.amount_without_taxes_in_gbp
else null
end
) as deposit_fees_not_cancelled_bookings_in_gbp,
sum(
case
when
@ -38,6 +49,17 @@ select
else null
end
) as waiver_payments_in_gbp,
sum(
case
when
upper(icvp.verification_payment_type)
in {{ waiver_fees_verification_payment_type_items }}
and upper(icb.booking_state) <> {{ var("cancelled_booking_state") }}
and icb.id_booking is not null
then icvp.amount_without_taxes_in_gbp
else null
end
) as waiver_payments_not_cancelled_bookings_in_gbp,
sum(
case
when
@ -47,6 +69,17 @@ select
else null
end
) as checkin_cover_fees_in_gbp,
sum(
case
when
upper(icvp.verification_payment_type)
in {{ checkin_cover_fees_verification_payment_type_items }}
and upper(icb.booking_state) <> {{ var("cancelled_booking_state") }}
and icb.id_booking is not null
then icvp.amount_without_taxes_in_gbp
else null
end
) as checkin_cover_fees_not_cancelled_bookings_in_gbp,
sum(
case
when
@ -59,7 +92,24 @@ select
then icvp.amount_without_taxes_in_gbp
else null
end
) as total_guest_payments_in_gbp
) as total_guest_payments_in_gbp,
sum(
case
when
(
upper(icvp.verification_payment_type)
in {{ checkin_cover_fees_verification_payment_type_items }}
or upper(icvp.verification_payment_type)
in {{ waiver_fees_verification_payment_type_items }}
or upper(icvp.verification_payment_type)
in {{ deposit_fees_verification_payment_type_items }}
)
and upper(icb.booking_state) <> {{ var("cancelled_booking_state") }}
and icb.id_booking is not null
then icvp.amount_without_taxes_in_gbp
else null
end
) as total_guest_payments_not_cancelled_in_gbp
from {{ ref("int_core__verification_payments", version=2) }} as icvp
left join
{{ ref("int_core__verification_requests") }} as icvr
@ -79,4 +129,4 @@ left join
on icuh.id_deal = icmas.id_deal
and icvp.payment_paid_date_utc = icmas.date
where upper(icvp.payment_status) = {{ var("paid_payment_state") }}
group by 1, 2, 3, 4
group by 1, 2, 3, 4, 5