Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .quickstart/quickstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ schema_key: xero_schema
dbt_versions: ">=1.3.0 <3.0.0"

table_variables:
xero__using_invoice:
- _invoice
xero__using_invoice_line_item:
- _invoice_line_item
xero__using_credit_note:
- _credit_note
xero__using_bank_transaction:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# dbt_xero v1.4.1

[PR #79](https://github.com/fivetran/dbt_xero/pull/79) includes the following updates:

## Feature Update
- Adds the `xero__using_invoice` and `xero__using_invoice_line_item` variables (both default `true`) so you can run the package without `invoice` or `invoice_line_item` data. See [Disabling and Enabling Models](https://github.com/fivetran/dbt_xero/blob/main/README.md#disabling-and-enabling-models) for details.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sources we'll want to update src.yml like this line. I also noticed credit_note and bank_transaction need the config added (nothing to do with this I realize but it's a small fix).

Also let's add the new vars to the CI tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point about the CI tests! Will need to keep reminding myself until it becomes habit. Added the variable configs to the src.yml for these and the missing ones. Thanks!


# dbt_xero v1.4.0

[PR #73](https://github.com/fivetran/dbt_xero/pull/73) includes the following updates:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ By default, all variables are assumed to be `true`. You only need to add variabl
config-version: 2

vars:
xero__using_invoice: false # default is true
xero__using_invoice_line_item: false # default is true
xero__using_credit_note: false # default is true
xero__using_bank_transaction: false # default is true
xero__using_invoice_line_item_tracking_category: false # default is true
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'xero'
version: '1.4.0'
version: '1.4.1'
config-version: 2
require-dbt-version: [">=1.3.0", "<3.0.0"]

Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions integration_tests/ci/test_scenarios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ test_scenarios:
xero__using_invoice_line_item_tracking_category: false
xero__using_journal_line_tracking_category: false
xero__using_tracking_categories: false
xero__using_invoice: false
xero__using_invoice_line_item: false
include_incremental: false

- name: "MDLS"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'xero_integration_tests'
version: '1.4.0'
version: '1.4.1'
profile: 'integration_tests'
config-version: 2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{ config(enabled=(var('xero__using_invoice_line_item_tracking_category', True)
and var('xero__using_tracking_categories', True))) }}
and var('xero__using_tracking_categories', True)
and var('xero__using_invoice', True)
and var('xero__using_invoice_line_item', True))) }}

{% set pivot_values = dbt_utils.get_column_values(
ref('int_xero__tracking_categories_with_options'),
Expand Down
8 changes: 8 additions & 0 deletions models/staging/src_xero.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ sources:
- name: invoice_line_item
identifier: "{{ var('xero_invoice_line_item_identifier', 'invoice_line_item')}}"
description: Each record in this able represents an invoice line item in Xero.
config:
enabled: "{{ var('xero__using_invoice_line_item', true) and var('xero_sources', []) == [] }}"
columns:
- name: _fivetran_synced
description: "{{ doc('_fivetran_synced') }}"
Expand Down Expand Up @@ -71,6 +73,8 @@ sources:
- name: invoice
identifier: "{{ var('xero_invoice_identifier', 'invoice')}}"
description: Each record in this table represents an invoice in Xero.
config:
enabled: "{{ var('xero__using_invoice', true) and var('xero_sources', []) == [] }}"
columns:
- name: invoice_id
description: Xero identifier for the invoice
Expand Down Expand Up @@ -169,6 +173,8 @@ sources:
- name: bank_transaction
identifier: "{{ var('xero_bank_transaction_identifier', 'bank_transaction')}}"
description: Each record represents a bank transaction in Xero.
config:
enabled: "{{ var('xero__using_bank_transaction', true) and var('xero_sources', []) == [] }}"
columns:
- name: bank_transaction_id
description: Xero identifier for the bank transaction.
Expand All @@ -178,6 +184,8 @@ sources:
- name: credit_note
identifier: "{{ var('xero_credit_note_identifier', 'credit_note')}}"
description: Each record represents a credit note in Xero.
config:
enabled: "{{ var('xero__using_credit_note', true) and var('xero_sources', []) == [] }}"
columns:
- name: credit_note_id
description: Xero identifier for the credit note.
Expand Down
3 changes: 2 additions & 1 deletion models/staging/stg_xero__invoice.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{{ config(enabled=var('xero__using_invoice', True)) }}

with base as (

select *
select *
from {{ ref('stg_xero__invoice_tmp') }}

),
Expand Down
3 changes: 2 additions & 1 deletion models/staging/stg_xero__invoice_line_item.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{{ config(enabled=var('xero__using_invoice_line_item', True)) }}

with base as (

select *
select *
from {{ ref('stg_xero__invoice_line_item_tmp') }}

),
Expand Down
2 changes: 2 additions & 0 deletions models/staging/tmp/stg_xero__invoice_line_item_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ config(enabled=var('xero__using_invoice_line_item', True)) }}

{% if var('union_schemas', []) | length > 0 or var('union_databases', []) | length > 0 %}

{{
Expand Down
2 changes: 2 additions & 0 deletions models/staging/tmp/stg_xero__invoice_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ config(enabled=var('xero__using_invoice', True)) }}

{% if var('union_schemas', []) | length > 0 or var('union_databases', []) | length > 0 %}

{{
Expand Down
29 changes: 15 additions & 14 deletions models/xero__general_ledger.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ with journals as (
select *
from {{ ref('stg_xero__account') }}

{% if var('xero__using_invoice', True) %}
), invoices as (

select *
from {{ ref('stg_xero__invoice') }}
{% endif %}

{% if var('xero__using_bank_transaction', True) %}
), bank_transactions as (
Expand Down Expand Up @@ -120,28 +122,27 @@ with journals as (

), first_contact as (

select
select
joined.*,
{% if fivetran_utils.enabled_vars_one_true(['xero__using_bank_transaction','xero__using_credit_note']) %}
coalesce(
invoices.contact_id
{% if var('xero__using_bank_transaction', True) %}
, bank_transactions.contact_id
{% endif %}

{% if var('xero__using_credit_note', True) %}
, credit_notes.contact_id
{% endif %}
)
{%- set contact_cols = [] -%}
{%- do contact_cols.append('invoices.contact_id') if var('xero__using_invoice', True) -%}
{%- do contact_cols.append('bank_transactions.contact_id') if var('xero__using_bank_transaction', True) -%}
{%- do contact_cols.append('credit_notes.contact_id') if var('xero__using_credit_note', True) -%}
{% if contact_cols | length > 1 %}
coalesce({{ contact_cols | join(', ') }})
{% elif contact_cols | length == 1 %}
{{ contact_cols[0] }}
{% else %}
invoices.contact_id
cast(null as {{ dbt.type_string() }})
{% endif %}

as contact_id
from joined
left join invoices
{% if var('xero__using_invoice', True) %}
left join invoices
on (joined.invoice_id = invoices.invoice_id
and joined.source_relation = invoices.source_relation)
{% endif %}
{% if var('xero__using_bank_transaction', True) %}
left join bank_transactions
on (joined.bank_transaction_id = bank_transactions.bank_transaction_id
Expand Down
5 changes: 5 additions & 0 deletions models/xero__invoice_line_items.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
-- depends_on: {{ ref('stg_xero__invoice') }}

{{ config(enabled=(
var('xero__using_invoice', True)
and var('xero__using_invoice_line_item', True)
)) }}

{%- set using_tracking_categories = (
var('xero__using_invoice_line_item_tracking_category', True)
and var('xero__using_tracking_categories', True)
Expand Down
Loading