# Description Adds Billing Country dimension in KPIs, but does not expose them to reporting yet. Silly thing, based on the macros I built, I cannot make incremental changes unless changing all models. This will need to be adapted, happy to hear your thoughts on how we do it. Additionally, I have lack of performance of the model `mtd_guest_payments_metrics`. It takes around 5 min to execute, but technically the end-to-end runs in one shoot without breaking. It's a complex PR because it changes many files, but you will see that: * It mostly changes the join conditions for the dimensions or the schema tests, * I tried to be very careful and add things step-by-step in the commits. Goal is NOT to complete the PR yet until we see how we can improve performance. I can say though that data end-to-end looks ok to me, but would benefit from checking with production data for the new dimension Update 30th Aug * Added a new commit that includes `id_user_host` in `int_core__verification_payments`. Happy to discuss if it makes sense or not. But it changes the execution from ~600 sec to ~6 sec because it avoids a massive repeated join with `verification_requests`. # 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. - [ ] I've picked the right materialization for the affected models. **To check because of performance issues** # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #19082
322 lines
8.4 KiB
YAML
322 lines
8.4 KiB
YAML
version: 2
|
|
|
|
models:
|
|
- name: int_xero__invoices
|
|
columns:
|
|
- name: id_invoice
|
|
tests:
|
|
- not_null
|
|
- unique
|
|
- name: int_xero__credit_notes
|
|
columns:
|
|
- name: id_credit_note
|
|
tests:
|
|
- not_null
|
|
- unique
|
|
- name: int_xero__invoice_line_items
|
|
columns:
|
|
- name: id_line_item
|
|
tests:
|
|
- not_null
|
|
- unique
|
|
- name: int_xero__credit_note_line_items
|
|
columns:
|
|
- name: id_line_item
|
|
tests:
|
|
- not_null
|
|
- unique
|
|
- name: int_xero__bank_transactions
|
|
columns:
|
|
- name: id_bank_transaction
|
|
tests:
|
|
- not_null
|
|
- unique
|
|
|
|
- name: int_xero__sales_denom_mart
|
|
description: |
|
|
This table is a denormalized mix of all invoices and credit notes data.
|
|
|
|
It is built by creating a snowflake schema for the invoicing area and
|
|
another one for the crediting area. In both cases, the cardinality is
|
|
*:1 between line items and documents, and *:1 between documents and
|
|
contacts. Then, the invoice and credit note side get unioned to be stored
|
|
in a single structure. The only transformation that happens differently
|
|
across both is that credit note amounts get their sign reversed (* -1) so
|
|
that aggregations happen naturally (credit amounts subtract from invoice
|
|
amounts). The final granularity of the table is on the line item level.
|
|
Invoice and credit note records can be told apart through the
|
|
document_class field.
|
|
|
|
The word _document_ in the context of this table encompasses both invoices
|
|
and credit notes.
|
|
|
|
The source of amounts is identifiable by their prefix. `line_` amount
|
|
fields come from the line items data, while `header_` fields come from the
|
|
document level data. Aggregating line fields can be done without worries.
|
|
Document level data can't be summed or averaged since it's duplicated per
|
|
line item, so be careful with it.
|
|
|
|
Fields are not documented here: you can find more details in upstream
|
|
models.
|
|
|
|
columns:
|
|
- name: id_line_item
|
|
data_type: text
|
|
description: ""
|
|
tests:
|
|
- not_null
|
|
- unique
|
|
|
|
- name: id_item
|
|
data_type: text
|
|
description: ""
|
|
|
|
- name: document_class
|
|
data_type: text
|
|
description: |
|
|
Indicates whether the record belongs in an invoice or a credit note.
|
|
tests:
|
|
- not_null
|
|
- accepted_values:
|
|
values:
|
|
- 'invoice'
|
|
- 'credit note'
|
|
|
|
- name: id_account
|
|
data_type: text
|
|
description: ""
|
|
|
|
- name: account_code
|
|
data_type: text
|
|
description: ""
|
|
|
|
- name: account_name
|
|
data_type: text
|
|
description: ""
|
|
|
|
- name: item_code
|
|
data_type: text
|
|
description: ""
|
|
|
|
- name: quantity
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: unit_amount
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: line_amount_local_curr
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: line_amount_in_gbp
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: line_amount_wo_taxes_local_curr
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: line_amount_wo_taxes_in_gbp
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: tax_amount_local_curr
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: tax_amount_in_gbp
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: tax_type
|
|
data_type: text
|
|
description: ""
|
|
|
|
- name: document_currency_iso_4217
|
|
data_type: character varying
|
|
description: ""
|
|
tests:
|
|
- not_null
|
|
- length_between:
|
|
min_length: 3
|
|
max_length: 3
|
|
|
|
- name: line_description
|
|
data_type: text
|
|
description: ""
|
|
|
|
- name: id_document
|
|
data_type: character varying
|
|
description: ""
|
|
tests:
|
|
- not_null
|
|
|
|
- name: reference
|
|
data_type: character varying
|
|
description: ""
|
|
|
|
- name: document_number
|
|
data_type: character varying
|
|
description: ""
|
|
|
|
- name: document_issued_at_utc
|
|
data_type: timestamp with time zone
|
|
description: ""
|
|
|
|
- name: document_issued_date_utc
|
|
data_type: date
|
|
description: ""
|
|
|
|
- name: document_type
|
|
data_type: character varying
|
|
description: ""
|
|
tests:
|
|
- not_null
|
|
- accepted_values:
|
|
values:
|
|
- "ACCREC"
|
|
- "ACCPAY"
|
|
- "ACCRECCREDIT"
|
|
- "ACCPAYCREDIT"
|
|
|
|
- name: document_currency_iso_4217
|
|
data_type: character varying
|
|
description: ""
|
|
|
|
- name: exchange_rate_to_gbp
|
|
data_type: numeric
|
|
description: ""
|
|
tests:
|
|
- not_null
|
|
- not_negative
|
|
|
|
- name: document_status
|
|
data_type: character varying
|
|
description: ""
|
|
tests:
|
|
- not_null
|
|
- accepted_values:
|
|
values:
|
|
- PAID
|
|
- VOIDED
|
|
- DRAFT
|
|
- DELETED
|
|
- AUTHORISED
|
|
- SUBMITTED
|
|
|
|
- name: line_amount_tax_inclusiveness
|
|
data_type: character varying
|
|
description: ""
|
|
tests:
|
|
- accepted_values:
|
|
values:
|
|
- Inclusive
|
|
- Exclusive
|
|
- NoTax
|
|
|
|
- name: header_total_amount_local_curr
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: header_total_amount_in_gbp
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: header_total_amount_wo_tax_local_curr
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: header_total_amount_wo_tax_in_gbp
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: header_total_tax_local_curr
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: header_total_tax_in_gbp
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: header_total_due_local_curr
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: header_total_due_in_gbp
|
|
data_type: numeric
|
|
description: ""
|
|
|
|
- name: id_contact
|
|
data_type: character varying
|
|
description: ""
|
|
|
|
- name: id_deal
|
|
data_type: text
|
|
description: ""
|
|
|
|
- name: contact_name
|
|
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.
|
|
|
|
tests:
|
|
- dbt_utils.unique_combination_of_columns:
|
|
combination_of_columns:
|
|
- date
|
|
- dimension
|
|
- dimension_value
|
|
|
|
columns:
|
|
- name: date
|
|
data_type: date
|
|
description: The date for the month-to-date invoicing-related metrics.
|
|
tests:
|
|
- not_null
|
|
|
|
- name: dimension
|
|
data_type: string
|
|
description: The dimension or granularity of the metrics.
|
|
tests:
|
|
- accepted_values:
|
|
values:
|
|
- global
|
|
- by_number_of_listings
|
|
- by_billing_country
|
|
|
|
- name: dimension_value
|
|
data_type: string
|
|
description: The value or segment available for the selected dimension.
|
|
tests:
|
|
- not_null
|