contacts model and schema
This commit is contained in:
parent
cf0f1f9a0c
commit
7d79dc8e4b
2 changed files with 223 additions and 0 deletions
171
models/staging/xero/schema.yml
Normal file
171
models/staging/xero/schema.yml
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
version: 2
|
||||
|
||||
models:
|
||||
- name: stg_xero__contacts
|
||||
description: |
|
||||
Xero contacts identify other parties we transact with: customers, suppliers, employees, etc.
|
||||
|
||||
The most interesting contacts are our customers.
|
||||
columns:
|
||||
- name: id_contact
|
||||
data_type: character varying
|
||||
description: Xero's unique identifier for the contact.
|
||||
|
||||
- name: account_number
|
||||
data_type: character varying
|
||||
description: A Superhog set identifier. For customers, this is Hubspot's Deal Id.
|
||||
|
||||
- name: contact_name
|
||||
data_type: character varying
|
||||
description: The name for the customer.
|
||||
|
||||
- name: is_customer
|
||||
data_type: boolean
|
||||
description: Flag that shows if the contact is a Superhog customer.
|
||||
|
||||
- name: is_supplier
|
||||
data_type: boolean
|
||||
description: Flag that shows if the contact is a Superhog supplier.
|
||||
|
||||
- name: tax_number
|
||||
data_type: character varying
|
||||
description: Tax number for this contact.
|
||||
|
||||
- name: contact_first_name
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: contact_last_name
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: phones
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: website
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: balances
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: discount
|
||||
data_type: numeric
|
||||
description: ""
|
||||
|
||||
- name: addresses
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: attachments
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: email_addresses
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: payment_terms
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: batch_payments
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: branding_theme
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: contact_groups
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: contact_number
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: contact_status
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: skyper_user_name
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: contact_persons
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: has_attachments
|
||||
data_type: boolean
|
||||
description: ""
|
||||
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: ""
|
||||
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: ""
|
||||
|
||||
- name: xero_network_key
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: default_currency_iso_4217
|
||||
data_type: character varying
|
||||
description: |
|
||||
The default currency used to interact with this contact.
|
||||
|
||||
For customers, this is the currency we will usually use to invoice.
|
||||
|
||||
- name: validation_errors
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: bank_account_details
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: has_validation_errors
|
||||
data_type: boolean
|
||||
description: ""
|
||||
|
||||
- name: tracking_category_name
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: account_payable_tax_type
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: tracking_category_option
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: sales_default_account_code
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: sales_tracking_categories
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: account_receivable_tax_type
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: purchases_default_account_code
|
||||
data_type: character varying
|
||||
description: ""
|
||||
|
||||
- name: purchases_tracking_categories
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: ""
|
||||
52
models/staging/xero/stg_xero__contacts.sql
Normal file
52
models/staging/xero/stg_xero__contacts.sql
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
with
|
||||
raw_contacts as (select * from {{ source("xero", "contacts") }}),
|
||||
stg_xero__contacts as (
|
||||
select
|
||||
{{ adapter.quote("ContactID") }} as id_contact,
|
||||
{{ adapter.quote("AccountNumber") }} as account_number,
|
||||
{{ adapter.quote("Name") }} as contact_name,
|
||||
{{ adapter.quote("IsCustomer") }} as is_customer,
|
||||
{{ adapter.quote("IsSupplier") }} as is_supplier,
|
||||
{{ adapter.quote("TaxNumber") }} as tax_number,
|
||||
{{ adapter.quote("FirstName") }} as contact_first_name,
|
||||
{{ adapter.quote("LastName") }} as contact_last_name,
|
||||
{{ adapter.quote("Phones") }} as phones,
|
||||
{{ adapter.quote("Website") }} as website,
|
||||
{{ adapter.quote("Balances") }} as balances,
|
||||
{{ adapter.quote("Discount") }} as discount,
|
||||
{{ adapter.quote("Addresses") }} as addresses,
|
||||
{{ adapter.quote("Attachments") }} as attachments,
|
||||
{{ adapter.quote("EmailAddress") }} as email_addresses,
|
||||
{{ adapter.quote("PaymentTerms") }} as payment_terms,
|
||||
{{ adapter.quote("BatchPayments") }} as batch_payments,
|
||||
{{ adapter.quote("BrandingTheme") }} as branding_theme,
|
||||
{{ adapter.quote("ContactGroups") }} as contact_groups,
|
||||
{{ adapter.quote("ContactNumber") }} as contact_number,
|
||||
{{ adapter.quote("ContactStatus") }} as contact_status,
|
||||
{{ adapter.quote("SkypeUserName") }} as skyper_user_name,
|
||||
{{ adapter.quote("ContactPersons") }} as contact_persons,
|
||||
{{ adapter.quote("HasAttachments") }} as has_attachments,
|
||||
{{ adapter.quote("UpdatedDateUTC") }} as updated_at_utc,
|
||||
cast({{ adapter.quote("UpdatedDateUTC") }} as date) as updated_date_utc,
|
||||
{{ adapter.quote("XeroNetworkKey") }} as xero_network_key,
|
||||
{{ adapter.quote("DefaultCurrency") }} as default_currency_iso_4217,
|
||||
{{ adapter.quote("ValidationErrors") }} as validation_errors,
|
||||
{{ adapter.quote("BankAccountDetails") }} as bank_account_details,
|
||||
{{ adapter.quote("HasValidationErrors") }} as has_validation_errors,
|
||||
{{ adapter.quote("TrackingCategoryName") }} as tracking_category_name,
|
||||
{{ adapter.quote("AccountsPayableTaxType") }} as account_payable_tax_type,
|
||||
{{ adapter.quote("TrackingCategoryOption") }} as tracking_category_option,
|
||||
{{ adapter.quote("SalesDefaultAccountCode") }}
|
||||
as sales_default_account_code,
|
||||
{{ adapter.quote("SalesTrackingCategories") }} as sales_tracking_categories,
|
||||
{{ adapter.quote("AccountsReceivableTaxType") }}
|
||||
as account_receivable_tax_type,
|
||||
{{ adapter.quote("PurchasesDefaultAccountCode") }}
|
||||
as purchases_default_account_code,
|
||||
{{ adapter.quote("PurchasesTrackingCategories") }}
|
||||
as purchases_tracking_categories,
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
|
||||
from raw_contacts
|
||||
)
|
||||
select *
|
||||
from stg_xero__contacts
|
||||
Loading…
Add table
Add a link
Reference in a new issue