Merged PR 3431: Adds Invoicing metrics

# Description

Same old story: includes all metrics coming from Xero.
Adds a daily model, monthly, mtd + monthly agg and mtd agg
A test to compare values new vs. old
AND fixes the issue I mentioned with the timestamp - an issue in the old KPIs.

# 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.
- [NA] 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: #23565
This commit is contained in:
Oriol Roqué Paniagua 2024-11-05 16:57:23 +00:00
parent 4076f016bd
commit f5311fa954
9 changed files with 947 additions and 13 deletions

View file

@ -0,0 +1,33 @@
{% set dimensions = get_kpi_dimensions_per_model("INVOICED_REVENUE") %}
{{
config(
materialized="table", unique_key=["end_date", "dimension", "dimension_value"]
)
}}
{% for dimension in dimensions %}
select
-- Unique Key --
start_date,
end_date,
{{ dimension.dimension }} as dimension,
{{ dimension.dimension_value }} as dimension_value,
-- Metrics --
sum(xero_booking_net_fees_in_gbp) as xero_booking_net_fees_in_gbp,
sum(xero_listing_net_fees_in_gbp) as xero_listing_net_fees_in_gbp,
sum(xero_verification_net_fees_in_gbp) as xero_verification_net_fees_in_gbp,
sum(xero_operator_net_fees_in_gbp) as xero_operator_net_fees_in_gbp,
sum(
xero_waiver_paid_back_to_host_in_gbp
) as xero_waiver_paid_back_to_host_in_gbp,
sum(xero_e_deposit_net_fees_in_gbp) as xero_e_deposit_net_fees_in_gbp,
sum(xero_guesty_net_fees_in_gbp) as xero_guesty_net_fees_in_gbp,
sum(xero_apis_net_fees_in_gbp) as xero_apis_net_fees_in_gbp
from {{ ref("int_kpis__metric_monthly_invoiced_revenue") }}
group by 1, 2, 3, 4
{% if not loop.last %}
union all
{% endif %}
{% endfor %}