diff --git a/models/reporting/xero/schema.yml b/models/reporting/xero/schema.yml index 0511906..2109406 100644 --- a/models/reporting/xero/schema.yml +++ b/models/reporting/xero/schema.yml @@ -849,6 +849,222 @@ models: fees. It might be the case that net fees are negative in some month, if it happens to be that we have given back to customers more than we have invoiced them. + - name: xero__bank_transactions + description: | + Bank transactions that have happened in any of our bank accounts. + + You can read more here: https://developer.xero.com/documentation/api/accounting/banktransactions + + columns: + - name: id_bank_transaction + data_type: character varying + description: Xero's unique identifier for the transaction. + data_tests: + - not_null + - unique + + - name: id_prepayment + data_type: character varying + description: | + Xero generated identifier for a Prepayment (unique within + organisations). This will be returned on BankTransactions with a Type + of SPEND-PREPAYMENT or RECEIVE-PREPAYMENT. + + - name: id_overpayment + data_type: character varying + description: Xero generated identifier for an Overpayment (unique within + organisations). This will be returned on BankTransactions with a Type + of SPEND-OVERPAYMENT or RECEIVE-OVERPAYMENT. + + - name: id_contact + data_type: text + description: | + Xero's unique id for the contact related to this transaction. + + - name: id_bank_account + data_type: text + description: | + Xero's unique id for the bank account related to this transaction. + + - name: reference + data_type: character varying + description: | + Reference for the transaction. Only supported for SPEND and RECEIVE + transactions. + + - name: transaction_type + data_type: character varying + description: | + What kind of transaction is this record. + + Can be one of: RECEIVE, RECEIVE-OVERPAYMENT, RECEIVE-PREPAYMENT, + SPEND, SPEND-OVERPAYMENT, SPEND-PREPAYMENT, RECEIVE-TRANSFER, + SPEND-TRANSFER + + The type will affect the sign of all amounts. Amounts we send are + negative, amounts we receive are positive. + + You can read more here: https://developer.xero.com/documentation/api/accounting/types#bank-transactions + data_tests: + - not_null + - accepted_values: + values: + - RECEIVE + - RECEIVE-OVERPAYMENT + - RECEIVE-PREPAYMENT + - SPEND + - SPEND-OVERPAYMENT + - SPEND-PREPAYMENT + - RECEIVE-TRANSFER + - SPEND-TRANSFER + + - name: transaction_sign + data_type: numeric + description: | + The sign for the transactions. Spending transactions show as -1, + receiving transactions show as 1. This helps in converting the + transaction amounts in the right sign, since Xero brings all amounts + as positive by default. + data_tests: + - not_null + - accepted_values: + values: + - 1 + - -1 + + - name: transaction_status + data_type: character varying + description: | + The status of this transaction. + + Can be one of: AUTHORISED, DELETED. + + You can read more here: https://developer.xero.com/documentation/api/accounting/types#bank-transaction-status-codes + data_tests: + - not_null + - accepted_values: + values: + - AUTHORISED + - DELETED + + - name: transaction_at_utc + data_type: timestamp with time zone + description: When did the transaction happen. + + - name: transaction_date_utc + data_type: date + description: The date on which the transaction happened. + + - name: date_string + data_type: timestamp with time zone + description: When did the transaction happened, as a string. + + - name: total_amount_local_curr + data_type: numeric + description: | + Total of bank transaction tax inclusive, in the currency the + transaction is denominated in. + data_tests: + - not_null + + - name: total_amount_in_gbp + data_type: numeric + description: | + Total of bank transaction tax inclusive, presented in GBP. + + - name: total_amount_wo_tax_local_curr + data_type: numeric + description: | + Total of bank transaction excluding taxes, in the currency the + transaction is denominated in. + + - name: total_amount_wo_tax_in_gbp + data_type: numeric + description: | + Total of bank transaction excluding taxes, presented in GBP. + + - name: total_tax_local_curr + data_type: numeric + description: | + Total tax on bank transaction, in the currency the transaction is + denominated in. + + - name: total_tax_in_gbp + data_type: numeric + description: | + Total tax on bank transaction, presented in GBP. + + - name: transaction_currency_iso_4217 + data_type: character varying + description: The ISO 4217 code for the currency of the transaction. + data_tests: + - not_null + - length_between: + min_length: 3 + max_length: 3 + + - name: exchange_rate_to_gbp + data_type: numeric + description: | + + ATTENTION! unlike in many other Xero entities, here this field is not + completed by Xero always. It has been complemented with the general + rates data used in the DWH. Xero's rates are preferent, so DWH rates + will only be used where Xero didn't provide a rate. + + The implied exchange rate between the transaction currency and GBP. + + This is the XXX to GBP rate. So the number represented in this field + is the units of currency GBP that 1 unit of XXX buys you. + + For example, if the transaction is 135 ZAR, and this rate is 0.0167, + the transaction value in GBP is 2.25 (135ZAR * 0.0167GBP/ZAR = + 2.25GBP). + data_tests: + - not_negative + + - name: line_amount_tax_inclusiveness + data_type: character varying + description: | + Indicates whether the amounts included in line items are tax + inclusive (Inclusive), tax exclusive (Exclusive) or simply, + there are no taxes on the invoice (NoTax). + data_tests: + - accepted_values: + values: + - Inclusive + - Exclusive + - NoTax + + - name: is_reconciled + data_type: boolean + description: A flag indicating if the transaction has been reconciled. + data_tests: + - not_null + + - name: has_attachments + data_type: boolean + description: "" + + - name: url + data_type: character varying + description: "" + + - name: external_link_provider_name + data_type: character varying + description: "" + + - name: updated_at_utc + data_type: timestamp with time zone + description: "" + + - name: updated_date_utc + data_type: date + description: "" + + - name: dwh_extracted_at_utc + data_type: timestamp with time zone + description: "" - name: xero__bank_transaction_line_items description: | @@ -954,6 +1170,26 @@ models: The transaction currency is defined at the Bank Transaction level, and the values you see in this field should always be the same as the currency of the Bank Transaction this line item belongs to. + + - name: xero__bank_transaction_denom_mart + description: | + This model is a denormalized mart, which only exists for presentation + purposes in a PBI report. + + The data is the same that lives in `xero__bank_transaction_line_items`, + `xero__bank_transactions` and `xero__contacts`. + + The granularity is at line item level, so be careful when doing + aggregations. Most aggregations on data on the transaction or contact + level will be wrong due to duplicates. + + columns: + - name: id_line_item + data_type: text + description: Xero's unique identifier for the line item. + data_tests: + - not_null + - unique - name: xero__sales_denom_mart description: | diff --git a/models/reporting/xero/xero__bank_transactions.sql b/models/reporting/xero/xero__bank_transactions.sql index ef19ecc..4806243 100644 --- a/models/reporting/xero/xero__bank_transactions.sql +++ b/models/reporting/xero/xero__bank_transactions.sql @@ -10,6 +10,7 @@ select bt.id_bank_account as id_bank_account, bt.reference as reference, bt.transaction_type as transaction_type, + bt.transaction_sign as transaction_sign, bt.transaction_status as transaction_status, bt.transaction_at_utc as transaction_at_utc, bt.transaction_date_utc as transaction_date_utc,