Added ratios to deal models

This commit is contained in:
Joaquin Ossa 2025-01-24 14:47:41 +01:00
parent 720185f235
commit e63a093991
4 changed files with 124 additions and 12 deletions

View file

@ -149,6 +149,18 @@ select
-- HOST RESOLUTIONS --
host_resolutions.xero_host_resolution_amount_paid_in_gbp,
host_resolutions.xero_host_resolution_payment_count,
cast(host_resolutions.xero_host_resolution_amount_paid_in_gbp as decimal)
/ created_bookings.created_bookings
as host_resolution_amount_paid_per_created_booking,
{{
return_capped_value(
"cast(host_resolutions.xero_host_resolution_payment_count as decimal)
/ created_bookings.created_bookings",
-1,
1
)
}}
as host_resolution_payment_per_created_booking_ratio,
-- GUEST REVENUE AND PAYMENTS --
guest_payments.deposit_fees_in_gbp,
@ -208,6 +220,23 @@ select
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) as revenue_retained_in_gbp,
{{
return_capped_value(
"nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) / nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0),
0
)",
-1,
1
)}} as revenue_retained_ratio,
-- REVENUE RETAINED POST RESOLUTIONS--
nullif(
@ -217,7 +246,26 @@ select
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(host_resolutions.xero_host_resolution_amount_paid_in_gbp, 0),
0
) as revenue_retained_post_resolutions_in_gbp
) as revenue_retained_post_resolutions_in_gbp,
{{
return_capped_value(
"nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(host_resolutions.xero_host_resolution_amount_paid_in_gbp, 0),
0
) / nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0),
0
)",
-1,
1
)
}} as revenue_retained_post_resolutions_ratio
from int_kpis__agg_dates_main_kpis d
left join int_kpis__dimension_deals ikdd on d.dimension_value = ikdd.id_deal

View file

@ -387,6 +387,16 @@ with
-1,
1
)}} as revenue_retained_ratio,
-- INCOME RETAINED POST RESOLUTIONS--
nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(host_resolutions.xero_host_resolution_amount_paid_in_gbp, 0),
0
) as revenue_retained_post_resolutions_in_gbp,
{{
return_capped_value(
"nullif(
@ -407,16 +417,6 @@ with
)
}} as revenue_retained_post_resolutions_ratio,
-- INCOME RETAINED POST RESOLUTIONS--
nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(host_resolutions.xero_host_resolution_amount_paid_in_gbp, 0),
0
) as revenue_retained_post_resolutions_in_gbp,
-- ONBOARDING MRR METRIC --
onboarding_mrr.expected_mrr as expected_mrr