Merged PR 2284: KPIs: computing invoicing metrics from Xero
This PR creates 2 new models on intermediate, xero:
- int_xero__mtd_invoicing_metrics (global view)
- int_xero__monthly_invoicing_history_by_deal (by deal view)
This allows for the computation of host metrics (operators), as well as host resolution payments. This will enable in the future to compute total revenue and weighted revenue metrics.
The data displayed from the previous months in the mtd_invoicing_metrics is consistent with 1) revenue figures displayed in business overview for Host tab, as well as Guest tab for Waiver Payments; and 2) host payment figures displayed in the accounting reports.
**Note 1**: the variables at this stage are reused in these models, as well as many other Xero models. We still need to handle the refactor ticket on Xero related reports. This is not under the scope of this PR.
**Note 2**: we noticed that the strategy for mtd models to do a double year, month extraction join is badly performant. Actually, resolution payments subquery was not performing at all with this logic. So it has been changed to a date_trunc('month', related_date)::date = d.first_day_month strategy which works much faster. I'll add a standalone PR to refactor the remaining mtd models separately later
Related work items: #18108, #18110
This commit is contained in:
parent
725dadd0a3
commit
2130226939
3 changed files with 262 additions and 2 deletions
|
|
@ -248,5 +248,41 @@ models:
|
|||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
|
||||
|
||||
- name: int_xero__monthly_invoicing_history_by_deal
|
||||
description: |
|
||||
This model contains the historic information regarding invoicing metrics 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 invoicing 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_xero__mtd_invoicing_metrics
|
||||
description: |
|
||||
This model contains the historic information regarding the invoiced and credited metrics
|
||||
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 invoicing-related metrics.
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue