data-dwh-dbt-project/models/intermediate/kpis/int_kpis__metric_mtd_invoiced_revenue.sql

72 lines
2.7 KiB
MySQL
Raw Normal View History

{{
config(
materialized="view",
unique_key=[
"end_date",
"id_deal",
"business_scope",
"active_accommodations_per_deal_segmentation",
],
)
}}
select
-- Unique Key --
d.first_day_month as start_date,
d.date as end_date,
ir.id_deal,
ir.business_scope,
ir.active_accommodations_per_deal_segmentation,
-- Dimensions --
ir.main_billing_country_iso_3_per_deal,
-- Metrics --
sum(
ir.xero_basic_protection_net_fees_in_gbp
) as xero_basic_protection_net_fees_in_gbp,
sum(ir.xero_waiver_pro_net_fees_in_gbp) as xero_waiver_pro_net_fees_in_gbp,
sum(
ir.xero_id_verification_net_fees_in_gbp
) as xero_id_verification_net_fees_in_gbp,
sum(
ir.xero_protection_plus_net_fees_in_gbp
) as xero_protection_plus_net_fees_in_gbp,
sum(ir.xero_screening_plus_net_fees_in_gbp) as xero_screening_plus_net_fees_in_gbp,
sum(
ir.xero_sex_offenders_check_net_fees_in_gbp
) as xero_sex_offenders_check_net_fees_in_gbp,
sum(ir.xero_protection_pro_net_fees_in_gbp) as xero_protection_pro_net_fees_in_gbp,
sum(
ir.xero_basic_screening_net_fees_in_gbp
) as xero_basic_screening_net_fees_in_gbp,
Merged PR 4727: Bookings fees are now Old Dashboard Booking Fees in Main KPIs # Description Booking fees is widely used with different meanings, for old dash, for new dash, for both, etc. This is painful. First step to align on a proper naming is ensure that what we report in Main KPIs is clearly stated, which in this case, Booking Fees are now called Old Dashboard Booking Fees. Changes: * Modify `stg_seed__accounting_aggregations` seed to rename Booking Fees to Old Dashboard Booking Fees. This is for us to clarify. This is only applied for KPIs compute. I also added an empty space that I mistakenly forgot in the past for `financial_l3_aggregation`. * Modify KPIs source, i.e., `int_kpis__metric_daily_invoiced_revenue`. Here I forcefully modify the name of the field to `xero_old_dashboard_booking_net_fees_in_gbp`. * Propagate changes of downstream usages of `xero_booking_net_fees_in_gbp` to `xero_old_dashboard_booking_net_fees_in_gbp`. This affects all models, including the reporting model. On this one we still have both names to avoid breaking it. I will need to modify the data glossary in PBI anyway so I'll do this change as well. * Modify displayed metric name from Booking Fees Revenue to Old Dashboard Booking Fees Revenue. * Modify schema so it reflects the proper names, descriptions, and tests. * Ensure outlier and completion tests still work after this change. I confirm the field `xero_booking_net_fees_in_gbp` does not exist anymore in the rest of DWH after these changes, except for the abovementioned comment on the reporting line. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #28560
2025-03-18 14:55:32 +00:00
sum(
ir.xero_old_dashboard_booking_net_fees_in_gbp
) as xero_old_dashboard_booking_net_fees_in_gbp,
sum(ir.xero_booking_net_fees_in_gbp) as xero_booking_net_fees_in_gbp,
sum(ir.xero_listing_net_fees_in_gbp) as xero_listing_net_fees_in_gbp,
sum(ir.xero_verification_net_fees_in_gbp) as xero_verification_net_fees_in_gbp,
sum(ir.xero_operator_net_fees_in_gbp) as xero_operator_net_fees_in_gbp,
sum(
ir.xero_waiver_paid_back_to_host_in_gbp
) as xero_waiver_paid_back_to_host_in_gbp,
sum(ir.xero_e_deposit_net_fees_in_gbp) as xero_e_deposit_net_fees_in_gbp,
sum(ir.xero_athena_net_fees_in_gbp) as xero_athena_net_fees_in_gbp,
2025-04-16 14:27:23 +02:00
sum(
ir.xero_check_in_hero_api_net_fees_in_gbp
) as xero_check_in_hero_api_net_fees_in_gbp,
sum(
2025-04-16 16:18:14 +02:00
ir.xero_screen_and_protect_net_fees_in_gbp
) as xero_screen_and_protect_net_fees_in_gbp,
sum(ir.xero_guesty_net_fees_in_gbp) as xero_guesty_net_fees_in_gbp,
sum(ir.xero_apis_net_fees_in_gbp) as xero_apis_net_fees_in_gbp,
sum(
ir.xero_guesty_resolutions_net_fees_in_gbp
) as xero_guesty_resolutions_net_fees_in_gbp
from {{ ref("int_kpis__dimension_dates") }} d
left join
{{ ref("int_kpis__metric_daily_invoiced_revenue") }} ir
on date_trunc('month', ir.date)::date = d.first_day_month
and extract(day from ir.date) <= d.day
where d.is_month_to_date = true and ir.id_deal is not null
group by 1, 2, 3, 4, 5, 6