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, icvp.payment_paid_date_utc as date,
coalesce(icuh.id_deal, 'UNSET') as id_deal, coalesce(icuh.id_deal, 'UNSET') as id_deal,
case 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, end as has_id_check,
-- Dimensions -- -- Dimensions --
coalesce( coalesce(
@ -29,6 +29,17 @@ select
else null else null
end end
) as deposit_fees_in_gbp, ) 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( sum(
case case
when when
@ -38,6 +49,17 @@ select
else null else null
end end
) as waiver_payments_in_gbp, ) 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( sum(
case case
when when
@ -47,6 +69,17 @@ select
else null else null
end end
) as checkin_cover_fees_in_gbp, ) 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( sum(
case case
when when
@ -59,7 +92,24 @@ select
then icvp.amount_without_taxes_in_gbp then icvp.amount_without_taxes_in_gbp
else null else null
end 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 from {{ ref("int_core__verification_payments", version=2) }} as icvp
left join left join
{{ ref("int_core__verification_requests") }} as icvr {{ ref("int_core__verification_requests") }} as icvr
@ -79,4 +129,4 @@ left join
on icuh.id_deal = icmas.id_deal on icuh.id_deal = icmas.id_deal
and icvp.payment_paid_date_utc = icmas.date and icvp.payment_paid_date_utc = icmas.date
where upper(icvp.payment_status) = {{ var("paid_payment_state") }} where upper(icvp.payment_status) = {{ var("paid_payment_state") }}
group by 1, 2, 3, 4 group by 1, 2, 3, 4, 5

View file

@ -1811,13 +1811,15 @@ models:
The unique key corresponds to the deepest granularity of the model, The unique key corresponds to the deepest granularity of the model,
in this case: in this case:
- date, - date,
- id_deal. - id_deal,
- has_id_check.
tests: tests:
- dbt_utils.unique_combination_of_columns: - dbt_utils.unique_combination_of_columns:
combination_of_columns: combination_of_columns:
- date - date
- id_deal - id_deal
- has_id_check
columns: columns:
- name: date - name: date
@ -1861,24 +1863,48 @@ models:
Sum of deposit fees paid by guests, without taxes, in GBP Sum of deposit fees paid by guests, without taxes, in GBP
in a given date and per specified dimension. in a given date and per specified dimension.
- name: deposit_fees_not_cancelled_bookings_in_gbp
data_type: decimal
description: |
Sum of deposit fees associated to bookings, that are not cancelled, paid by guests,
without taxes, in GBP in a given date and per specified dimension.
- name: waiver_payments_in_gbp - name: waiver_payments_in_gbp
data_type: decimal data_type: decimal
description: | description: |
Sum of waiver payments paid by guests, without taxes, in GBP Sum of waiver payments paid by guests, without taxes, in GBP
in a given date and per specified dimension. in a given date and per specified dimension.
- name: waiver_payments_not_cancelled_bookings_in_gbp
data_type: decimal
description: |
Sum of waiver payments associated to bookings, that are not cancelled, paid by guests,
without taxes, in GBP in a given date and per specified dimension.
- name: checkin_cover_fees_in_gbp - name: checkin_cover_fees_in_gbp
data_type: decimal data_type: decimal
description: | description: |
Sum of checkin cover fees paid by guests, without taxes, in GBP Sum of checkin cover fees paid by guests, without taxes, in GBP
in a given date and per specified dimension. in a given date and per specified dimension.
- name: checkin_cover_fees_not_cancelled_bookings_in_gbp
data_type: decimal
description: |
Sum of checkin cover fees associated to bookings, that are not cancelled, paid by guests,
without taxes, in GBP in a given date and per specified dimension.
- name: total_guest_payments_in_gbp - name: total_guest_payments_in_gbp
data_type: decimal data_type: decimal
description: | description: |
Sum of total payments paid by guests, without taxes, in GBP Sum of total payments paid by guests, without taxes, in GBP
in a given date and per specified dimension. in a given date and per specified dimension.
- name: total_guest_payment_not_cancelled_bookings_in_gbp
data_type: decimal
description: |
Sum of total payments associated to bookings, that are not cancelled, paid by guests,
without taxes, in GBP in a given date and per specified dimension.
- name: int_kpis__metric_monthly_guest_payments - name: int_kpis__metric_monthly_guest_payments
description: | description: |
This model computes the Monthly Guest Payments at the This model computes the Monthly Guest Payments at the