Simplified it

This commit is contained in:
Joaquin Ossa 2024-09-16 16:20:36 +02:00
parent 54af8af30e
commit 3d8ede273e
3 changed files with 41 additions and 47 deletions

View file

@ -40,7 +40,7 @@ with
then vp.amount_without_taxes_in_gbp
else null
end
) as deposit_fees_without_taxes_in_gbp,
) as deposit_fees_in_gbp,
sum(
case
when
@ -49,7 +49,7 @@ with
then vp.amount_without_taxes_in_gbp
else null
end
) as waiver_payments_without_taxes_in_gbp,
) as waiver_payments_in_gbp,
sum(
case
when
@ -58,7 +58,7 @@ with
then vp.amount_without_taxes_in_gbp
else null
end
) as checkin_cover_fees_without_taxes_in_gbp
) as checkin_cover_fees_in_gbp
from int_dates_mtd d
inner join
int_core__verification_payments vp
@ -94,21 +94,15 @@ select
d.dimension_value,
d.is_end_of_month,
d.is_current_month,
nullif(gpym.deposit_fees_in_gbp, 0) as deposit_fees_in_gbp,
nullif(gpym.waiver_payments_in_gbp, 0) as waiver_payments_in_gbp,
nullif(gpym.checkin_cover_fees_in_gbp, 0) as checkin_cover_fees_in_gbp,
nullif(
gpym.deposit_fees_without_taxes_in_gbp, 0
) as deposit_fees_without_taxes_in_gbp,
nullif(
gpym.waiver_payments_without_taxes_in_gbp, 0
) as waiver_payments_without_taxes_in_gbp,
nullif(
gpym.checkin_cover_fees_without_taxes_in_gbp, 0
) as checkin_cover_fees_without_taxes_in_gbp,
nullif(
coalesce(gpym.deposit_fees_without_taxes_in_gbp, 0)
+ coalesce(gpym.waiver_payments_without_taxes_in_gbp, 0)
+ coalesce(gpym.checkin_cover_fees_without_taxes_in_gbp, 0),
coalesce(gpym.deposit_fees_in_gbp, 0)
+ coalesce(gpym.waiver_payments_in_gbp, 0)
+ coalesce(gpym.checkin_cover_fees_in_gbp, 0),
0
) as total_guest_payments_without_taxes_in_gbp
) as total_guest_payments_in_gbp
from int_dates_mtd_by_dimension d
left join
guest_payments_year_month gpym

View file

@ -362,18 +362,18 @@
{
"order_by": 260,
"metric": "Deposit Fees",
"value": "deposit_fees_without_taxes_in_gbp",
"previous_year_value": "previous_year_deposit_fees_without_taxes_in_gbp",
"relative_increment": "relative_increment_deposit_fees_without_taxes_in_gbp",
"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",
"increment_sign_format": "positive",
},
{
"order_by": 262,
"metric": "Waiver Amount Paid by Guests",
"value": "waiver_payments_without_taxes_in_gbp",
"previous_year_value": "previous_year_waiver_payments_without_taxes_in_gbp",
"relative_increment": "relative_increment_waiver_payments_without_taxes_in_gbp",
"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",
"increment_sign_format": "positive",
},
@ -398,9 +398,9 @@
{
"order_by": 265,
"metric": "Check-In Hero Amount Paid by Guests",
"value": "checkin_cover_fees_without_taxes_in_gbp",
"previous_year_value": "previous_year_checkin_cover_fees_without_taxes_in_gbp",
"relative_increment": "relative_increment_checkin_cover_fees_without_taxes_in_gbp",
"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",
"increment_sign_format": "positive",
},
@ -416,9 +416,9 @@
{
"order_by": 290,
"metric": "Guest Payments",
"value": "total_guest_payments_without_taxes_in_gbp",
"previous_year_value": "previous_year_total_guest_payments_without_taxes_in_gbp",
"relative_increment": "relative_increment_total_guest_payments_without_taxes_in_gbp",
"value": "total_guest_payments_in_gbp",
"previous_year_value": "previous_year_total_guest_payments_in_gbp",
"relative_increment": "relative_increment_total_guest_payments_in_gbp",
"number_format": "currency_gbp",
"increment_sign_format": "positive",
},

View file

@ -95,25 +95,25 @@ with
invoicing.xero_host_resolution_payment_count,
-- GUEST REVENUE AND PAYMENTS --
guest_payments.deposit_fees_without_taxes_in_gbp,
guest_payments.waiver_payments_without_taxes_in_gbp,
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_without_taxes_in_gbp, 0)
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_without_taxes_in_gbp,
guest_payments.total_guest_payments_without_taxes_in_gbp,
guest_payments.checkin_cover_fees_in_gbp,
guest_payments.total_guest_payments_in_gbp,
nullif(
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
coalesce(guest_payments.total_guest_payments_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_payments_without_taxes_in_gbp, 0)
coalesce(guest_payments.total_guest_payments_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),
@ -121,21 +121,21 @@ with
) as total_revenue_in_gbp,
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
guest_payments.total_guest_payments_without_taxes_in_gbp / nullif(
guest_payments.total_guest_payments_in_gbp / nullif(
guest_journeys.completed_guest_journeys, 0
) as guest_payments_per_completed_guest_journey,
guest_payments.total_guest_payments_without_taxes_in_gbp / nullif(
guest_payments.total_guest_payments_in_gbp / nullif(
guest_journeys.paid_guest_journeys, 0
) as guest_payments_per_paid_guest_journey,
nullif(
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
coalesce(guest_payments.total_guest_payments_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_payments_without_taxes_in_gbp, 0)
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
0
) / nullif(
@ -144,14 +144,14 @@ with
-- TOTAL REVENUE WEIGHTED METRICS --
(
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
coalesce(guest_payments.total_guest_payments_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_payments_without_taxes_in_gbp, 0)
coalesce(guest_payments.total_guest_payments_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)
@ -159,7 +159,7 @@ with
guest_journeys.created_guest_journeys, 0
) as total_revenue_per_created_guest_journey,
(
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
coalesce(guest_payments.total_guest_payments_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)
@ -167,7 +167,7 @@ with
deals.deals_booked_in_month, 0
) as total_revenue_per_deals_booked_in_month,
(
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
coalesce(guest_payments.total_guest_payments_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)
@ -275,12 +275,12 @@ select
{{ calculate_safe_relative_increment("xero_host_resolution_payment_count") }},
-- GUEST REVENUE AND PAYMENTS --
{{ calculate_safe_relative_increment("deposit_fees_without_taxes_in_gbp") }},
{{ calculate_safe_relative_increment("waiver_payments_without_taxes_in_gbp") }},
{{ 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_without_taxes_in_gbp") }},
{{ calculate_safe_relative_increment("total_guest_payments_without_taxes_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_revenue_in_gbp") }},
-- TOTAL REVENUE --