data-dwh-dbt-project/models/intermediate/xero/schema.yml

416 lines
13 KiB
YAML
Raw Normal View History

2024-06-25 13:37:53 +02:00
version: 2
models:
- name: int_xero__invoices
columns:
- name: id_invoice
2025-01-13 16:00:35 +01:00
data_tests:
- not_null
- unique
- name: is_invoice_posted_in_hyperline
data_type: boolean
description: |
Indicates whether the invoice has been posted in Hyperline.
An invoice is considered posted in Hyperline if it has an
invoice type equal to ACCREC and follows the naming convention
20XX-Y, where 20XX is the posting year and Y is an autoincremental number.
data_tests:
- not_null
2024-06-25 13:37:53 +02:00
- name: int_xero__credit_notes
columns:
- name: id_credit_note
2025-01-13 16:00:35 +01:00
data_tests:
- not_null
- unique
- name: is_credit_note_posted_in_hyperline
data_type: boolean
description: |
Indicates whether the credit note has been posted in Hyperline.
A credit note is considered posted in Hyperline if it has a
credit note type equal to ACCRECCREDIT and follows the naming convention
CN-20XX-Y, where CN refers to Credit Note, 20XX is the posting year and
Y is an autoincremental number.
data_tests:
- not_null
2024-06-25 13:37:53 +02:00
- name: int_xero__invoice_line_items
columns:
- name: id_line_item
2025-01-13 16:00:35 +01:00
data_tests:
- not_null
- unique
2024-06-25 13:37:53 +02:00
- name: int_xero__credit_note_line_items
columns:
- name: id_line_item
2025-01-13 16:00:35 +01:00
data_tests:
- not_null
- unique
2024-06-25 13:37:53 +02:00
- name: int_xero__bank_transactions
columns:
- name: id_bank_transaction
2025-01-13 16:00:35 +01:00
data_tests:
- not_null
- unique
2024-07-08 17:06:23 +02:00
- 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
2024-07-08 17:52:15 +02:00
*:1 between line items and documents, and *:1 between documents and
2024-07-08 17:06:23 +02:00
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.
2024-07-08 17:26:10 +02:00
Invoice and credit note records can be told apart through the
document_class field.
2024-07-08 17:06:23 +02:00
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.
2024-07-08 17:26:10 +02:00
Fields are not documented here: you can find more details in upstream
models.
2024-07-08 17:06:23 +02:00
columns:
- name: id_line_item
data_type: text
description: ""
2025-01-13 16:00:35 +01:00
data_tests:
2024-07-08 17:06:23 +02:00
- not_null
- unique
- name: id_item
data_type: text
description: ""
- name: document_class
data_type: text
2024-07-08 17:26:10 +02:00
description: |
Indicates whether the record belongs in an invoice or a credit note.
2025-01-13 16:00:35 +01:00
data_tests:
2024-07-08 17:26:10 +02:00
- 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: ""
2024-07-08 17:06:23 +02:00
- 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: ""
2024-07-08 17:26:10 +02:00
- name: document_currency_iso_4217
2024-07-08 17:06:23 +02:00
data_type: character varying
description: ""
2025-01-13 16:00:35 +01:00
data_tests:
2024-07-08 17:26:10 +02:00
- not_null
- length_between:
min_length: 3
max_length: 3
2024-07-08 17:06:23 +02:00
- name: line_description
data_type: text
description: ""
- name: id_document
data_type: character varying
description: ""
2025-01-13 16:00:35 +01:00
data_tests:
2024-07-08 17:26:10 +02:00
- not_null
2024-07-08 17:06:23 +02:00
- name: is_document_posted_in_hyperline
data_type: boolean
description: |
Indicates whether the document has been posted in Hyperline.
A document is considered posted in Hyperline if it follows this logic:
- For invoices, if the invoice type equals to ACCREC and the document number
follows the naming convention 20XX-Y, where 20XX is the posting year and Y is
an autoincremental number.
- For credit notes, if the credit note type equal to ACCRECCREDIT and the
document number follows the naming convention CN-20XX-Y, where CN refers to
Credit Note, 20XX is the posting year and Y is an autoincremental number.
data_tests:
- not_null
2024-07-08 17:06:23 +02:00
- 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_is_effective_at_end_of_month_utc
data_type: date
description: |
The last day of the month when the document is effective.
This is used to align the document with the correct invoicing cycle period.
For documents posted in Hyperline, this represents the last day of the previous
month to the issuing date. For documents not posted in Hyperline, this is the
last day of the month when the document was issued.
2024-07-08 17:06:23 +02:00
- name: document_type
data_type: character varying
description: ""
2025-01-13 16:00:35 +01:00
data_tests:
2024-07-08 17:26:10 +02:00
- not_null
- accepted_values:
values:
- "ACCREC"
- "ACCPAY"
- "ACCRECCREDIT"
- "ACCPAYCREDIT"
2024-07-08 17:06:23 +02:00
- name: document_currency_iso_4217
data_type: character varying
description: ""
- name: exchange_rate_to_gbp
data_type: numeric
description: ""
2025-01-13 16:00:35 +01:00
data_tests:
2024-07-08 17:26:10 +02:00
- not_null
- not_negative
2024-07-08 17:06:23 +02:00
- name: document_status
data_type: character varying
description: ""
2025-01-13 16:00:35 +01:00
data_tests:
2024-07-08 17:26:10 +02:00
- not_null
- accepted_values:
values:
- PAID
- VOIDED
- DRAFT
- DELETED
- AUTHORISED
- SUBMITTED
2024-07-08 17:06:23 +02:00
- name: line_amount_tax_inclusiveness
data_type: character varying
description: ""
2025-01-13 16:00:35 +01:00
data_tests:
2024-07-08 17:26:10 +02:00
- accepted_values:
values:
- Inclusive
- Exclusive
- NoTax
2024-07-08 17:06:23 +02:00
- 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: accounting_root_aggregation
data_type: character varying
description: |
The root aggregation per account code. This is the main
aggregation that is used to retrieve low-level data.
- name: accounting_kpis_aggregation
data_type: character varying
description: |
The default macro-aggregation for Invoiced KPIs.
- name: accounting_financial_l1_aggregation
data_type: character varying
description: |
The Level 1 aggregation for Financial reporting.
- name: accounting_financial_l2_aggregation
data_type: character varying
description: |
The Level 2 aggregation for Financial reporting.
- name: accounting_financial_l3_aggregation
data_type: character varying
description: |
The Level 3 aggregation for Financial reporting.
- name: int_xero__sales_monthly_trends
description: |
This model provides monthly aggregated sales and credit note data with
fiscal year alignment and period-over-period comparisons.
The model is built by aggregating the `int_xero__sales_denom_mart` model
at the monthly level, computing sales amounts without taxes in GBP, and
incorporating key financial aggregations.
Additionally, it calculates prior period trends:
- Previous month sales
- Previous year (same month) sales
- Year-to-date (YTD) sales for the current fiscal year
- YTD sales for the previous fiscal year
The fiscal year is determined based on an April-March cycle, where a
fiscal year is labeled by the year in which it ends (e.g., FY 2025
represents April 2024 March 2025).
columns:
- name: document_issued_month_utc
data_type: date
description: "The first day of the month when the document was issued, truncated to the month level."
data_tests:
- not_null
- name: fiscal_year
data_type: integer
description: |
"The fiscal year in which the document's issued month falls.
The fiscal year runs from April to March and is labeled by the year in which it ends
(e.g., FY 2025 represents April 2024 March 2025)."
- name: previous_fiscal_year
data_type: integer
description: "The fiscal year prior to the current one, based on the April-March cycle."
- name: document_status
data_type: text
description: "The status of the document (e.g., PAID, VOIDED, AUTHORISED, etc.)."
- name: document_type
data_type: text
description: "The type of document, indicating whether it is an invoice or credit note."
- name: id_deal
data_type: text
description: "The deal associated with the transaction, if applicable. Defaults to 'UNSET' if not provided."
- name: accounting_financial_l1_aggregation
data_type: text
description: "The Level 1 aggregation for Financial reporting."
- name: accounting_financial_l2_aggregation
data_type: text
description: "The Level 2 aggregation for Financial reporting."
- name: accounting_financial_l3_aggregation
data_type: text
description: "The Level 3 aggregation for Financial reporting."
- name: amount_wo_taxes_in_gbp
data_type: numeric
description: "Total sales amount without taxes, converted to GBP, aggregated at the monthly level."
- name: previous_month_amount_wo_taxes_in_gbp
data_type: numeric
description: "The sales amount without taxes (GBP) for the previous month within the same category."
- name: previous_year_amount_wo_taxes_in_gbp
data_type: numeric
description: "The sales amount without taxes (GBP) for the same month in the previous year within the same category."
- name: ytd_amount_wo_taxes_in_gbp
data_type: numeric
description: |
"Year-to-date (YTD) total of sales amount without taxes (GBP) from the start of the current fiscal
year up to the current month."
- name: previous_year_ytd_amount_wo_taxes_in_gbp
data_type: numeric
description: |
"Year-to-date (YTD) total of sales amount without taxes (GBP) from the start of the previous fiscal
year up to the same month."