Merged PR 2422: Ensure that guest payments models follow nomenclature

Small refactor to follow up on last week's PR. We removed from the Guest Revenue models the host-takes-waiver aspect, thus these models are now only depending from Core. We just need to migrate it from cross to core.

One small detail as well, since we do not take into account at these models level the host-takes-waiver, technically, I would not call these models revenue but rather Guest Payments. This is why I also took the opportunity to apply this name.

Changes:
- `int_monthly_guest_revenue_by_deal` is now `int_core__monthly_guest_payments_history_by_deal`, and the location has changed from `intermediate.cross` to `intermediate.core`
- `int_mtd_guest_revenue_metrics` is now `int_core__mtd_guest_payments_metrics`, and the location has changed from `intermediate.cross` to `intermediate.core`
- Schema changes, moving these 2 models' documentation with the new naming from Cross to Core
- Provide continuity in following dependants: `int_mtd_vs_previous_year_metrics` and `int_monthly_aggregated_metrics_history_by_deal` now read from the 2 new models respectively. Additionally, the model alias has changed from `guest_revenue` to `guest_payments` to keep consistency.

This PR does not expose new metrics, but should keep the existing ones unaffected.

Related work items: #18914
This commit is contained in:
Oriol Roqué Paniagua 2024-07-29 09:10:58 +00:00
parent 04eb09c318
commit 1b1b97380a
6 changed files with 75 additions and 75 deletions

View file

@ -272,6 +272,44 @@ models:
- not_null
- unique
- name: int_mtd_guest_payments_metrics
description: |
This model contains the historic information regarding the guest revenue in an aggregated manner.
It's used for the business KPIs. Data is aggregated at the last day of the month and in the
days necessary for the Month-to-Date computation of the current month.
columns:
- name: date
data_type: date
description: The date for the month-to-date guest revenue-related metrics.
tests:
- not_null
- unique
- name: int_monthly_guest_payments_history_by_deal
description: |
This model contains the historic information regarding the guest revenue for each deal id.
It's used for the business KPIs in the view by deal id. Data is aggregated at the last
day of the month, or up to yesterday if it's the current month.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- date
- id_deal
columns:
- name: date
data_type: date
description: The last day of the month or yesterday for historic guest revenue metrics.
tests:
- not_null
- name: id_deal
data_type: character varying
description: Id of the deal associated to the host.
tests:
- not_null
- name: int_core__verification_request_completeness
description: |
The `int_core__verification_request_completeness` model allows to determine if a verification request is

View file

@ -19,8 +19,8 @@ with
int_xero__monthly_invoicing_history_by_deal as (
select * from {{ ref("int_xero__monthly_invoicing_history_by_deal") }}
),
int_monthly_guest_revenue_history_by_deal as (
select * from {{ ref("int_monthly_guest_revenue_history_by_deal") }}
int_core__monthly_guest_payments_history_by_deal as (
select * from {{ ref("int_core__monthly_guest_payments_history_by_deal") }}
)
select
@ -77,20 +77,20 @@ select
invoicing.xero_host_resolution_payment_count,
-- GUEST REVENUE AND PAYMENTS --
guest_revenue.deposit_fees_in_gbp,
guest_revenue.waiver_payments_in_gbp,
guest_revenue.checkin_cover_fees_in_gbp,
guest_revenue.total_guest_payments_in_gbp,
guest_revenue.total_guest_income_in_gbp,
guest_payments.deposit_fees_in_gbp,
guest_payments.waiver_payments_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_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
0
) as total_guest_revenue_in_gbp,
-- TOTAL REVENUE --
nullif(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0),
@ -98,21 +98,21 @@ select
) as total_revenue_in_gbp,
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
guest_revenue.total_guest_payments_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_revenue.total_guest_payments_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_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
0
) / nullif(
guest_journeys.completed_guest_journeys, 0
) as guest_revenue_per_completed_guest_journey,
nullif(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
0
) / nullif(
@ -121,14 +121,14 @@ select
-- TOTAL REVENUE WEIGHTED METRICS --
(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_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_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
@ -136,7 +136,7 @@ select
guest_journeys.created_guest_journeys, 0
) as total_revenue_per_created_guest_journey,
(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
@ -162,9 +162,9 @@ left join
on d.date = accommodations.date
and d.id_deal = accommodations.id_deal
left join
int_monthly_guest_revenue_history_by_deal guest_revenue
on d.date = guest_revenue.date
and d.id_deal = guest_revenue.id_deal
int_core__monthly_guest_payments_history_by_deal guest_payments
on d.date = guest_payments.date
and d.id_deal = guest_payments.id_deal
left join
int_xero__monthly_invoicing_history_by_deal invoicing
on d.date = invoicing.date

View file

@ -16,8 +16,8 @@ with
int_core__mtd_deal_metrics as (
select * from {{ ref("int_core__mtd_deal_metrics") }}
),
int_mtd_guest_revenue_metrics as (
select * from {{ ref("int_mtd_guest_revenue_metrics") }}
int_core__mtd_guest_payments_metrics as (
select * from {{ ref("int_core__mtd_guest_payments_metrics") }}
),
int_xero__mtd_invoicing_metrics as (
select * from {{ ref("int_xero__mtd_invoicing_metrics") }}
@ -92,20 +92,20 @@ with
invoicing.xero_host_resolution_payment_count,
-- GUEST REVENUE AND PAYMENTS --
guest_revenue.deposit_fees_in_gbp,
guest_revenue.waiver_payments_in_gbp,
guest_revenue.checkin_cover_fees_in_gbp,
guest_revenue.total_guest_payments_in_gbp,
guest_revenue.total_guest_income_in_gbp,
guest_payments.deposit_fees_in_gbp,
guest_payments.waiver_payments_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_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
0
) as total_guest_revenue_in_gbp,
-- TOTAL REVENUE --
nullif(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0),
@ -113,21 +113,21 @@ with
) as total_revenue_in_gbp,
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
guest_revenue.total_guest_payments_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_revenue.total_guest_payments_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_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
0
) / nullif(
guest_journeys.completed_guest_journeys, 0
) as guest_revenue_per_completed_guest_journey,
nullif(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0),
0
) / nullif(
@ -136,14 +136,14 @@ with
-- TOTAL REVENUE WEIGHTED METRICS --
(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_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_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
@ -151,7 +151,7 @@ with
guest_journeys.created_guest_journeys, 0
) as total_revenue_per_created_guest_journey,
(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_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
deals.deals_booked_in_month, 0
) as total_revenue_per_deals_booked_in_month,
(
coalesce(guest_revenue.total_guest_income_in_gbp, 0)
coalesce(guest_payments.total_guest_income_in_gbp, 0)
+ coalesce(invoicing.xero_waiver_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
@ -177,7 +177,7 @@ with
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
int_core__mtd_guest_payments_metrics guest_payments on d.date = guest_payments.date
left join int_xero__mtd_invoicing_metrics invoicing on d.date = invoicing.date
)
select

View file

@ -132,20 +132,6 @@ models:
tests:
- not_null
- name: int_mtd_guest_revenue_metrics
description: |
This model contains the historic information regarding the guest revenue in an aggregated manner.
It's used for the business KPIs. Data is aggregated at the last day of the month and in the
days necessary for the Month-to-Date computation of the current month.
columns:
- name: date
data_type: date
description: The date for the month-to-date guest revenue-related metrics.
tests:
- not_null
- unique
- name: int_mtd_vs_previous_year_metrics
description: |
This model is used for global KPIs.
@ -164,30 +150,6 @@ models:
- not_null
- unique
- name: int_monthly_guest_revenue_history_by_deal
description: |
This model contains the historic information regarding the guest revenue for each deal id.
It's used for the business KPIs in the view by deal id. Data is aggregated at the last
day of the month, or up to yesterday if it's the current month.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- date
- id_deal
columns:
- name: date
data_type: date
description: The last day of the month or yesterday for historic guest revenue metrics.
tests:
- not_null
- name: id_deal
data_type: character varying
description: Id of the deal associated to the host.
tests:
- not_null
- name: int_mtd_aggregated_metrics
description: |
The `int_mtd_aggregated_metrics` model aggregates multiple metrics on a year, month, and day basis.