Merged PR 2353: Computing and propagating APIs revenue metrics

Computing and propagating APIs revenue metrics.
I retrieved the revenues linked to Guesty and e-deposits. The sum of those are considered the total API revenue at this stage.
These 3 metrics are available in upper layers (not exposed yet to the report), just to fix the total revenue computation, which now includes APIs revenue

Related work items: #18719
This commit is contained in:
Oriol Roqué Paniagua 2024-07-19 07:30:42 +00:00
parent b16cb172b6
commit 361ad31299
4 changed files with 156 additions and 35 deletions

View file

@ -37,7 +37,7 @@ select
bookings.check_out_bookings,
bookings.cancelled_bookings,
bookings.billable_bookings,
-- GUEST JOURNEYS --
guest_journeys.created_guest_journeys,
guest_journeys.started_guest_journeys,
@ -67,13 +67,19 @@ select
invoicing.xero_operator_net_fees_in_gbp,
invoicing.xero_waiver_net_fees_in_gbp,
-- APIs REVENUE --
invoicing.xero_apis_net_fees_in_gbp,
invoicing.xero_e_deposit_net_fees_in_gbp,
invoicing.xero_guesty_net_fees_in_gbp,
-- HOST RESOLUTIONS --
invoicing.xero_host_resolution_amount_paid_in_gbp,
invoicing.xero_host_resolution_payment_count,
-- TOTAL REVENUE --
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp as total_revenue_in_gbp,
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp as total_revenue_in_gbp,
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
guest_revenue.total_guest_payments_in_gbp,
@ -92,17 +98,23 @@ select
) as guest_revenue_per_paid_guest_journey,
-- TOTAL REVENUE WEIGHTED METRICS --
(guest_revenue.total_guest_revenue_in_gbp + invoicing.xero_operator_net_fees_in_gbp)
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
)
/ nullif(bookings.created_bookings, 0) as total_revenue_per_created_booking,
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
) / nullif(
guest_journeys.created_guest_journeys, 0
) as total_revenue_per_created_guest_journey,
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
) / nullif(
accommodations.listings_booked_in_month, 0
) as total_revenue_per_listings_booked_in_month

View file

@ -20,7 +20,7 @@ with
select * from {{ ref("int_mtd_guest_revenue_metrics") }}
),
int_xero__mtd_invoicing_metrics as (
select * from {{ ref("int_xero__mtd_invoicing_metrics") }}
select * from {{ ref("int_xero__mtd_invoicing_metrics") }}
),
int_dates_mtd as (select * from {{ ref("int_dates_mtd") }}),
@ -82,6 +82,11 @@ with
invoicing.xero_operator_net_fees_in_gbp,
invoicing.xero_waiver_net_fees_in_gbp,
-- APIs REVENUE --
invoicing.xero_apis_net_fees_in_gbp,
invoicing.xero_e_deposit_net_fees_in_gbp,
invoicing.xero_guesty_net_fees_in_gbp,
-- HOST RESOLUTIONS --
invoicing.xero_host_resolution_amount_paid_in_gbp,
invoicing.xero_host_resolution_payment_count,
@ -92,8 +97,8 @@ with
-- TOTAL REVENUE --
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
as total_revenue_in_gbp,
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp as total_revenue_in_gbp,
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
guest_revenue.total_guest_payments_in_gbp / nullif(
@ -110,36 +115,46 @@ with
) as guest_revenue_per_paid_guest_journey,
-- TOTAL REVENUE WEIGHTED METRICS --
(guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp) / nullif(
bookings.created_bookings, 0
) as total_revenue_per_created_booking,
(guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp) / nullif(
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
)
/ nullif(bookings.created_bookings, 0) as total_revenue_per_created_booking,
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
) / nullif(
guest_journeys.created_guest_journeys, 0
) as total_revenue_per_created_guest_journey,
(guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp) / nullif(
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
) / nullif(
deals.deals_booked_in_month, 0
) as total_revenue_per_deals_booked_in_month,
(guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp) / nullif(
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
) / nullif(
accommodations.listings_booked_in_month, 0
) as total_revenue_per_listings_booked_in_month
from int_dates_mtd d
left join int_core__mtd_booking_metrics bookings
on d.date = bookings.date
left join int_core__mtd_guest_journey_metrics guest_journeys
left join int_core__mtd_booking_metrics bookings on d.date = bookings.date
left join
int_core__mtd_guest_journey_metrics guest_journeys
on d.date = guest_journeys.date
left join int_core__mtd_accommodation_metrics accommodations
left join
int_core__mtd_accommodation_metrics accommodations
on d.date = accommodations.date
left join int_core__mtd_deal_metrics deals
on d.date = deals.date
left join int_mtd_guest_revenue_metrics guest_revenue
on d.date = guest_revenue.date
left join int_xero__mtd_invoicing_metrics invoicing
on d.date = invoicing.date
left join int_core__mtd_deal_metrics deals on d.date = deals.date
left join
int_mtd_guest_revenue_metrics guest_revenue on d.date = guest_revenue.date
left join int_xero__mtd_invoicing_metrics invoicing on d.date = invoicing.date
)
select
current.year,
@ -198,6 +213,11 @@ select
{{ 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") }},
{{ calculate_safe_relative_increment("xero_e_deposit_net_fees_in_gbp") }},
{{ calculate_safe_relative_increment("xero_guesty_net_fees_in_gbp") }},
-- HOST RESOLUTIONS --
{{ calculate_safe_relative_increment("xero_host_resolution_amount_paid_in_gbp") }},
{{ calculate_safe_relative_increment("xero_host_resolution_payment_count") }},
@ -210,16 +230,24 @@ select
{{ calculate_safe_relative_increment("total_revenue_in_gbp") }},
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
{{ calculate_safe_relative_increment("guest_payments_per_completed_guest_journey")}},
{{
calculate_safe_relative_increment(
"guest_payments_per_completed_guest_journey"
)
}},
{{ calculate_safe_relative_increment("guest_payments_per_paid_guest_journey") }},
{{ calculate_safe_relative_increment("guest_revenue_per_completed_guest_journey") }},
{{ calculate_safe_relative_increment("guest_revenue_per_paid_guest_journey") }},
-- TOTAL REVENUE WEIGHTED METRICS --
{{ calculate_safe_relative_increment("total_revenue_per_created_booking")}},
{{ calculate_safe_relative_increment("total_revenue_per_created_guest_journey")}},
{{ calculate_safe_relative_increment("total_revenue_per_deals_booked_in_month")}},
{{ calculate_safe_relative_increment("total_revenue_per_listings_booked_in_month")}}
{{ calculate_safe_relative_increment("total_revenue_per_created_booking") }},
{{ calculate_safe_relative_increment("total_revenue_per_created_guest_journey") }},
{{ calculate_safe_relative_increment("total_revenue_per_deals_booked_in_month") }},
{{
calculate_safe_relative_increment(
"total_revenue_per_listings_booked_in_month"
)
}}
from plain_kpi_combination current
left join