Merged PR 2429: Business KPIs - Revenue details

Exposes the following metrics:
1. Invoiced Booking Fees
1. Invoiced Listing Fees
1. Invoiced Verification Fees
1. Invoiced Guesty Fees
1. Invoiced E-Deposit Fees
1. Deposit Fees
1. Waiver Amount Paid by Guests
1. Waiver Amount Paid back to Hosts
1. Check-In Hero Amount Paid by Guests

This PR is only for Global metrics, the one by deal id will follow separately.
Keep in mind that merging this PR will make the data appear in the report.

Related work items: #18914
This commit is contained in:
Oriol Roqué Paniagua 2024-07-29 13:16:19 +00:00
parent 7e9b3733c8
commit 756d1c54d5
6 changed files with 130 additions and 26 deletions

View file

@ -65,7 +65,6 @@ select
invoicing.xero_listing_net_fees_in_gbp,
invoicing.xero_verification_net_fees_in_gbp,
invoicing.xero_operator_net_fees_in_gbp,
invoicing.xero_waiver_net_fees_in_gbp,
-- APIs REVENUE --
invoicing.xero_apis_net_fees_in_gbp,
@ -79,19 +78,25 @@ select
-- GUEST REVENUE AND PAYMENTS --
guest_payments.deposit_fees_in_gbp,
guest_payments.waiver_payments_in_gbp,
invoicing.xero_waiver_paid_back_to_host_in_gbp,
nullif(
coalesce(guest_payments.waiver_payments_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) as waiver_net_fees_in_gbp,
guest_payments.checkin_cover_fees_in_gbp,
guest_payments.total_guest_payments_in_gbp,
guest_payments.total_guest_income_in_gbp,
nullif(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) as total_guest_revenue_in_gbp,
-- TOTAL REVENUE --
nullif(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0),
0
@ -106,14 +111,14 @@ select
) as guest_payments_per_paid_guest_journey,
nullif(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) / nullif(
guest_journeys.completed_guest_journeys, 0
) as guest_revenue_per_completed_guest_journey,
nullif(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) / nullif(
guest_journeys.paid_guest_journeys, 0
@ -122,14 +127,14 @@ select
-- TOTAL REVENUE WEIGHTED METRICS --
(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
)
/ nullif(bookings.created_bookings, 0) as total_revenue_per_created_booking,
(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
@ -137,7 +142,7 @@ select
) as total_revenue_per_created_guest_journey,
(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(

View file

@ -199,7 +199,7 @@
"relative_increment": "relative_increment_total_revenue_in_gbp",
"number_format": "currency_gbp",
},
{
{
"order_by": 201,
"metric": "Total Revenue per Booking Created",
"value": "total_revenue_per_created_booking",
@ -239,6 +239,30 @@
"relative_increment": "relative_increment_xero_operator_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 225,
"metric": "Invoiced Booking Fees",
"value": "xero_booking_net_fees_in_gbp",
"previous_year_value": "previous_year_xero_booking_net_fees_in_gbp",
"relative_increment": "relative_increment_xero_booking_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 226,
"metric": "Invoiced Listing Fees",
"value": "xero_listing_net_fees_in_gbp",
"previous_year_value": "previous_year_xero_listing_net_fees_in_gbp",
"relative_increment": "relative_increment_xero_listing_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 227,
"metric": "Invoiced Verification Fees",
"value": "xero_verification_net_fees_in_gbp",
"previous_year_value": "previous_year_xero_verification_net_fees_in_gbp",
"relative_increment": "relative_increment_xero_verification_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 230,
"metric": "Invoiced APIs Revenue",
@ -247,6 +271,22 @@
"relative_increment": "relative_increment_xero_apis_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 235,
"metric": "Invoiced Guesty Fees",
"value": "xero_guesty_net_fees_in_gbp",
"previous_year_value": "previous_year_xero_guesty_net_fees_in_gbp",
"relative_increment": "relative_increment_xero_guesty_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 236,
"metric": "Invoiced E-Deposit Fees",
"value": "xero_e_deposit_net_fees_in_gbp",
"previous_year_value": "previous_year_xero_e_deposit_net_fees_in_gbp",
"relative_increment": "relative_increment_xero_e_deposit_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 250,
"metric": "Guest Revenue",
@ -271,6 +311,46 @@
"relative_increment": "relative_increment_guest_revenue_per_paid_guest_journey",
"number_format": "currency_gbp",
},
{
"order_by": 260,
"metric": "Deposit Fees",
"value": "deposit_fees_in_gbp",
"previous_year_value": "previous_year_deposit_fees_in_gbp",
"relative_increment": "relative_increment_deposit_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 262,
"metric": "Waiver Amount Paid by Guests",
"value": "waiver_payments_in_gbp",
"previous_year_value": "previous_year_waiver_payments_in_gbp",
"relative_increment": "relative_increment_waiver_payments_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 263,
"metric": "Waiver Amount Paid back to Hosts",
"value": "xero_waiver_paid_back_to_host_in_gbp",
"previous_year_value": "previous_year_xero_waiver_paid_back_to_host_in_gbp",
"relative_increment": "relative_increment_xero_waiver_paid_back_to_host_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 264,
"metric": "Waiver Net Fees",
"value": "waiver_net_fees_in_gbp",
"previous_year_value": "previous_year_waiver_net_fees_in_gbp",
"relative_increment": "relative_increment_waiver_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 265,
"metric": "Check-In Hero Amount Paid by Guests",
"value": "checkin_cover_fees_in_gbp",
"previous_year_value": "previous_year_checkin_cover_fees_in_gbp",
"relative_increment": "relative_increment_checkin_cover_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 270,
"metric": "Host Resolutions Amount Paid",

View file

@ -80,7 +80,6 @@ with
invoicing.xero_listing_net_fees_in_gbp,
invoicing.xero_verification_net_fees_in_gbp,
invoicing.xero_operator_net_fees_in_gbp,
invoicing.xero_waiver_net_fees_in_gbp,
-- APIs REVENUE --
invoicing.xero_apis_net_fees_in_gbp,
@ -94,19 +93,25 @@ with
-- GUEST REVENUE AND PAYMENTS --
guest_payments.deposit_fees_in_gbp,
guest_payments.waiver_payments_in_gbp,
invoicing.xero_waiver_paid_back_to_host_in_gbp,
nullif(
coalesce(guest_payments.waiver_payments_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) as waiver_net_fees_in_gbp,
guest_payments.checkin_cover_fees_in_gbp,
guest_payments.total_guest_payments_in_gbp,
guest_payments.total_guest_income_in_gbp,
nullif(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) as total_guest_revenue_in_gbp,
-- TOTAL REVENUE --
nullif(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0),
0
@ -121,14 +126,14 @@ with
) as guest_payments_per_paid_guest_journey,
nullif(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) / nullif(
guest_journeys.completed_guest_journeys, 0
) as guest_revenue_per_completed_guest_journey,
nullif(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) / nullif(
guest_journeys.paid_guest_journeys, 0
@ -137,14 +142,14 @@ with
-- TOTAL REVENUE WEIGHTED METRICS --
(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
)
/ nullif(bookings.created_bookings, 0) as total_revenue_per_created_booking,
(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
@ -152,7 +157,7 @@ with
) as total_revenue_per_created_guest_journey,
(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
@ -160,7 +165,7 @@ with
) as total_revenue_per_deals_booked_in_month,
(
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
@ -235,7 +240,6 @@ select
{{ calculate_safe_relative_increment("xero_listing_net_fees_in_gbp") }},
{{ calculate_safe_relative_increment("xero_verification_net_fees_in_gbp") }},
{{ calculate_safe_relative_increment("xero_operator_net_fees_in_gbp") }},
{{ calculate_safe_relative_increment("xero_waiver_net_fees_in_gbp") }},
-- APIs REVENUE --
{{ calculate_safe_relative_increment("xero_apis_net_fees_in_gbp") }},
@ -249,6 +253,8 @@ select
-- GUEST REVENUE AND PAYMENTS --
{{ calculate_safe_relative_increment("deposit_fees_in_gbp") }},
{{ calculate_safe_relative_increment("waiver_payments_in_gbp") }},
{{ calculate_safe_relative_increment("xero_waiver_paid_back_to_host_in_gbp") }},
{{ calculate_safe_relative_increment("waiver_net_fees_in_gbp") }},
{{ calculate_safe_relative_increment("checkin_cover_fees_in_gbp") }},
{{ calculate_safe_relative_increment("total_guest_payments_in_gbp") }},
{{ calculate_safe_relative_increment("total_guest_income_in_gbp") }},

View file

@ -101,7 +101,7 @@ with
then sdm.line_amount_wo_taxes_in_gbp
else 0
end
) as xero_waiver_net_fees_in_gbp
) as xero_waiver_paid_back_to_host_in_gbp
from int_xero__sales_denom_mart sdm
where
upper(sdm.document_status) in {{ relevant_document_statuses }}
@ -140,7 +140,7 @@ select
0
) as xero_apis_net_fees_in_gbp,
-- WAIVERS PAID BACK TO HOST --
hnf.xero_waiver_net_fees_in_gbp,
hnf.xero_waiver_paid_back_to_host_in_gbp,
-- HOST RESOLUTIONS --
rhp.xero_host_resolution_amount_paid_in_gbp,
rhp.xero_host_resolution_payment_count

View file

@ -104,7 +104,7 @@ with
then sdm.line_amount_wo_taxes_in_gbp
else 0
end
) as xero_waiver_net_fees_in_gbp
) as xero_waiver_paid_back_to_host_in_gbp
from int_dates_mtd d
inner join
int_xero__sales_denom_mart sdm
@ -148,7 +148,7 @@ select
0
) as xero_apis_net_fees_in_gbp,
-- WAIVERS PAID BACK TO HOST --
hnf.xero_waiver_net_fees_in_gbp,
hnf.xero_waiver_paid_back_to_host_in_gbp,
-- HOST RESOLUTIONS --
rhp.xero_host_resolution_amount_paid_in_gbp,
rhp.xero_host_resolution_payment_count

View file

@ -37,9 +37,22 @@ from int_mtd_aggregated_metrics
*/
where
(
-- Not show current + previous month if revenue metric or resolution
(lower(metric) like '%revenue%' or lower(metric) like '%resolutions%')
-- Not show current + previous month if the metric depends on invoicing cycle
(
lower(metric) like '%revenue%'
or lower(metric) like '%resolutions%'
or lower(metric) like '%invoiced%'
or lower(metric) like '%back to host%'
or lower(metric) like '%waiver net fees%'
)
and {{ is_date_before_previous_month("date") }}
)
-- Keep all history for the rest of metrics
or not (lower(metric) like '%revenue%' or lower(metric) like '%resolutions%')
or not
(
lower(metric) like '%revenue%'
or lower(metric) like '%resolutions%'
or lower(metric) like '%invoiced%'
or lower(metric) like '%back to host%'
or lower(metric) like '%waiver net fees%'
)