Skip to content

Commit

Permalink
Merge pull request #44 from fivetran/bugfix/passthrough
Browse files Browse the repository at this point in the history
Bugfix: apply persist-passthrough-column logic to end models
  • Loading branch information
fivetran-jamie authored Aug 16, 2022
2 parents f3a5599 + ea1b98e commit 1a8f890
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 55 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# dbt_netsuite v0.6.1

## Bug Fixes 🐞
- Properly applies new passthrough column logic to allow for the use of `alias` and `transform_sql` (see v0.6.0 below). ([#43](https://github.com/fivetran/dbt_netsuite/issues/43))

# dbt_netsuite v0.6.0
🎉 [Netsuite2](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/article_163465025391.html) Compatibility 🎉
PR [#41](https://github.com/fivetran/dbt_netsuite/pull/41) includes the following update to the dbt_netsuite package:
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config-version: 2
name: 'netsuite'
version: '0.6.0'
version: '0.6.1'
profile: 'integration'
require-dbt-version: [">=1.0.0", "<2.0.0"]

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: 'netsuite_integration_tests'
version: '0.6.0'
version: '0.6.1'
profile: 'integration_tests'
config-version: 2

Expand Down
17 changes: 6 additions & 11 deletions models/netsuite2/netsuite2__balance_sheet.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,10 @@ balance_sheet as (
case
when not accounts.is_balancesheet then null
else accounts.account_number
end as account_number,
end as account_number

--The below script allows for accounts table pass through columns.
{% if var('accounts_pass_through_columns') %}

accounts.{{ var('accounts_pass_through_columns') | join (", accounts.")}} ,

{% endif %}
{{ fivetran_utils.persist_pass_through_columns('accounts_pass_through_columns', identifier='accounts') }},

case
when not accounts.is_balancesheet or lower(transactions_with_converted_amounts.account_category) = 'equity' then -converted_amount_using_transaction_accounting_period
Expand Down Expand Up @@ -95,7 +91,7 @@ balance_sheet as (
when not accounts.is_balancesheet then 14
else null
end as balance_sheet_sort_helper

--Below is only used if balance sheet transaction detail columns are specified dbt_project.yml file.
{% if var('balance_sheet_transaction_detail_columns') %}

Expand Down Expand Up @@ -143,11 +139,10 @@ balance_sheet as (
null as account_id,
null as account_number,

--The below script allows for accounts table pass through columns.
{% if var('accounts_pass_through_columns') %}

null as {{ var('accounts_pass_through_columns') | join (", null as ")}} ,

{% for field in var('accounts_pass_through_columns') %}
null as {{ field.alias if field.alias else field.name }},
{% endfor %}
{% endif %}

case
Expand Down
26 changes: 7 additions & 19 deletions models/netsuite2/netsuite2__income_statement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,22 @@ income_statement as (
accounts.account_number,
subsidiaries.subsidiary_id,
subsidiaries.full_name as subsidiary_full_name,
subsidiaries.name as subsidiary_name,
subsidiaries.name as subsidiary_name

--The below script allows for accounts table pass through columns.
{% if var('accounts_pass_through_columns') %}

accounts.{{ var('accounts_pass_through_columns') | join (", accounts.")}} ,

{% endif %}
{{ fivetran_utils.persist_pass_through_columns('accounts_pass_through_columns', identifier='accounts') }},

{{ dbt_utils.concat(['accounts.account_number',"'-'", 'accounts.name']) }} as account_number_and_name,
classes.full_name as class_full_name,

--The below script allows for classes table pass through columns.
{% if var('classes_pass_through_columns') %}

classes.{{ var('classes_pass_through_columns') | join (", classes.")}} ,
classes.full_name as class_full_name

{% endif %}
--The below script allows for accounts table pass through columns.
{{ fivetran_utils.persist_pass_through_columns('classes_pass_through_columns', identifier='classes') }},

locations.full_name as location_full_name,
departments.full_name as department_full_name,
departments.full_name as department_full_name

--The below script allows for departments table pass through columns.
{% if var('departments_pass_through_columns') %}

departments.{{ var('departments_pass_through_columns') | join (", departments.")}} ,

{% endif %}
{{ fivetran_utils.persist_pass_through_columns('departments_pass_through_columns', identifier='departments') }},

transactions_with_converted_amounts.account_category as account_category,
case when lower(accounts.type_name) = 'income' then 1
Expand Down
30 changes: 7 additions & 23 deletions models/netsuite2/netsuite2__transaction_details.sql
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,13 @@ transaction_details as (
transactions.transaction_date,
transactions.due_date_at as transaction_due_date,
transactions.transaction_type as transaction_type,
transactions.is_intercompany_adjustment as is_transaction_intercompany_adjustment,
transactions.is_intercompany_adjustment as is_transaction_intercompany_adjustment

--The below script allows for transactions table pass through columns.
{% if var('transactions_pass_through_columns') %}

transactions.{{ var('transactions_pass_through_columns') | join (", transactions.")}} ,

{% endif %}
{{ fivetran_utils.persist_pass_through_columns('transactions_pass_through_columns', identifier='transactions') }}

--The below script allows for transaction lines table pass through columns.
{% if var('transaction_lines_pass_through_columns') %}

transaction_lines.{{ var('transaction_lines_pass_through_columns') | join (", transaction_lines.")}} ,

{% endif %}
{{ fivetran_utils.persist_pass_through_columns('transaction_lines_pass_through_columns', identifier='transaction_lines') }},

accounting_periods.ending_at as accounting_period_ending,
accounting_periods.name as accounting_period_name,
Expand All @@ -108,14 +100,10 @@ transaction_details as (
accounts.name as account_name,
accounts.type_name as account_type_name,
accounts.account_id as account_id,
accounts.account_number,
accounts.account_number

--The below script allows for accounts table pass through columns.
{% if var('accounts_pass_through_columns') %}

accounts.{{ var('accounts_pass_through_columns') | join (", accounts.")}} ,

{% endif %}
{{ fivetran_utils.persist_pass_through_columns('accounts_pass_through_columns', identifier='accounts') }},

accounts.is_leftside as is_account_leftside,
lower(accounts.type_name) like 'accounts payable%' as is_accounts_payable,
Expand Down Expand Up @@ -143,14 +131,10 @@ transaction_details as (
vendors.create_date_at as vendor_create_date,
currencies.name as currency_name,
currencies.symbol as currency_symbol,
departments.name as department_name,
departments.name as department_name

--The below script allows for departments table pass through columns.
{% if var('departments_pass_through_columns') %}

departments.{{ var('departments_pass_through_columns') | join (", departments.")}} ,

{% endif %}
{{ fivetran_utils.persist_pass_through_columns('departments_pass_through_columns', identifier='departments') }},

subsidiaries.name as subsidiary_name,
case
Expand Down

0 comments on commit 1a8f890

Please sign in to comment.