version: 2 models: - name: int_xero__invoices columns: - name: id_invoice 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 - name: int_xero__contacts columns: - name: id_contact data_type: character varying description: | Unique identifier of a contact. data_tests: - not_null - unique - name: id_deal data_type: character varying description: | Identifier of the account. It can be null. - name: is_contact_missing_id_deal data_type: boolean description: | Indicates whether id deal is null or not. - name: is_latest_updated_contact_per_deal data_type: boolean description: | Indicates whether a contact is the most recently updated one associated with a given id_deal. When id_deal is provided, this field helps identify the latest updated contact for that deal, ensuring that only the most relevant contact is considered. This is useful for deduplicating records when modeling data per deal. - name: int_xero__credit_notes columns: - name: id_credit_note 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 - name: int_xero__invoice_line_items columns: - name: id_line_item data_tests: - not_null - unique - name: int_xero__credit_note_line_items columns: - name: id_line_item data_tests: - not_null - unique - name: int_xero__bank_transactions columns: - name: id_bank_transaction data_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: "" data_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. data_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: "" data_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: "" data_tests: - not_null - 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 - 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. - name: document_type data_type: character varying description: "" data_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: "" data_tests: - not_null - not_negative - name: document_status data_type: character varying description: "" data_tests: - not_null - accepted_values: values: - PAID - VOIDED - DRAFT - DELETED - AUTHORISED - SUBMITTED - name: line_amount_tax_inclusiveness data_type: character varying description: "" data_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: 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). data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - document_issued_month_utc - document_status - document_type - id_deal - accounting_financial_l3_aggregation 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." - name: int_xero__host_resolutions_payments description: | This model provides a view of transactions related to resolutions, including details such as transaction date, associated account, and transaction amount. Previously, all resolution-related transaction data was stored in the `int_xero__bank_transactions` model. However, some resolution transactions have been, and will continue to be, credited through the standard invoicing process — these are stored in the `int_xero__sales_denom_mart` model. This model is built by joining the `int_xero__bank_transactions` and `int_xero__sales_denom_mart` models to provide a unified view of resolution transactions. columns: - name: id_line_item data_type: text description: "Unique identifier of the line item associated with the transaction." data_tests: - not_null - unique - name: id_account data_type: text description: "Unique identifier of the account associated with the transaction." data_tests: - not_null - name: account_code data_type: text description: "The code of the account associated with the transaction." data_tests: - not_null - name: account_name data_type: text description: "The name of the account associated with the transaction." data_tests: - not_null - name: line_description data_type: text description: "Description of the transaction line item." - name: document_class data_type: text description: "Indicates whether the record belongs in an a credit note or a bank transaction." data_tests: - not_null - accepted_values: values: - "credit note" - "bank transaction" - name: transaction_date_utc data_type: date description: "The date of the transaction in UTC." - name: id_deal data_type: text description: | "Unique identifier of an account associated with the transaction." - name: quantity data_type: numeric description: "The quantity of transactions." - name: unit_amount data_type: numeric description: "The unit amount of the transaction." - name: line_amount_local_curr data_type: numeric description: "The transaction amount in the local currency." - name: line_amount_in_gbp data_type: numeric description: "The transaction amount in GBP." - name: line_amount_wo_taxes_local_curr data_type: numeric description: "The transaction amount without taxes in the local currency." - name: line_amount_wo_taxes_in_gbp data_type: numeric description: "The transaction amount without taxes in GBP." - name: tax_amount_local_curr data_type: numeric description: "The tax amount in the local currency." - name: tax_amount_in_gbp data_type: numeric description: "The tax amount in GBP." - name: transaction_currency_iso_4217 data_type: character varying description: "The currency of the transaction, represented in ISO 4217 format."