From 8dc31f348942d2a283320fe19fbad070ef8b3be5 Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Tue, 25 Jun 2024 14:29:46 +0200 Subject: [PATCH] add accounts to staging --- models/staging/xero/_xero_sources.yml | 4 +++ models/staging/xero/schema.yml | 15 +++++++++++ models/staging/xero/stg_xero__accounts.sql | 29 ++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 models/staging/xero/stg_xero__accounts.sql diff --git a/models/staging/xero/_xero_sources.yml b/models/staging/xero/_xero_sources.yml index 88cbb79..2833340 100644 --- a/models/staging/xero/_xero_sources.yml +++ b/models/staging/xero/_xero_sources.yml @@ -23,3 +23,7 @@ sources: identifier: bank_transactions description: | Bank transactions that have been created within our accounting books. + - name: accounts + identifier: accounts + description: | + Accounts from our accounting trees. diff --git a/models/staging/xero/schema.yml b/models/staging/xero/schema.yml index b2490f8..09704d1 100644 --- a/models/staging/xero/schema.yml +++ b/models/staging/xero/schema.yml @@ -774,3 +774,18 @@ models: - name: dwh_extracted_at_utc data_type: timestamp with time zone description: "" + - name: stg_xero__accounts + description: | + Accounts in our accounting tree. + columns: + - name: id_account + data_type: character varying + description: Xero's unique identifier for the account. + tests: + - not_null + - unique + - name: account_code + data_type: character varying + description: Human readable account code. + tests: + - unique diff --git a/models/staging/xero/stg_xero__accounts.sql b/models/staging/xero/stg_xero__accounts.sql new file mode 100644 index 0000000..8aa0f53 --- /dev/null +++ b/models/staging/xero/stg_xero__accounts.sql @@ -0,0 +1,29 @@ +with + raw_accounts as (select * from {{ source("xero", "accounts") }}), + stg_xero__accounts as ( + select + {{ adapter.quote("AccountID") }} as id_account, + {{ adapter.quote("Code") }} as account_code, + {{ adapter.quote("Name") }} as account_name, + {{ adapter.quote("Type") }} as account_type, + {{ adapter.quote("Class") }} as account_class, + {{ adapter.quote("Status") }} as is_active, + {{ adapter.quote("TaxType") }} as account_tax_type, + {{ adapter.quote("Description") }} as account_description, + {{ adapter.quote("CurrencyCode") }} as account_currency_iso_4217, + {{ adapter.quote("ReportingCode") }} as reporting_code, + {{ adapter.quote("ReportingCodeName") }} as reporting_name, + {{ adapter.quote("SystemAccount") }} as system_account, + {{ adapter.quote("HasAttachments") }} as has_attachments, + {{ adapter.quote("BankAccountType") }} as bank_account_type, + {{ adapter.quote("BankAccountNumber") }} as bank_account_number, + {{ adapter.quote("ShowInExpenseClaims") }} as show_in_expense_claims, + {{ adapter.quote("EnablePaymentsToAccount") }} + as enable_payments_to_account, + {{ adapter.quote("UpdatedDateUTC") }} as updated_at_utc, + {{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc + + from raw_accounts + ) +select * +from stg_xero__accounts